{
  "swagger": "2.0",
  "info": {
    "title": "Tax Free Partner API",
    "version": "1.0",
    "description": "Адрес окружения и X-API-Key предоставляет команда Tax Free. Укажите host выбранного окружения перед выполнением запросов."
  },
  "schemes": ["https"],
  "basePath": "/",
  "produces": ["application/json"],
  "paths": {
    "/api/v1/partner/applications": {
      "post": {
        "security": [
          {
            "PartnerKeyAuth": []
          }
        ],
        "description": "Requires applications:create permission and a key bound to an active store employee. Tourist is created once or resolved by passport/QR; EAEU citizens are rejected. Exactly one refund method and one receipt input mode are required. All changes are atomic.",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["Partner Tax Free"],
        "summary": "Create a Tax Free application from tourist, refund and receipt data",
        "parameters": [
          {
            "description": "Tourist, refund details and OFD receipt",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/dtosvc.PartnerApplicationRequest"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "schema": {
              "$ref": "#/definitions/partner_application.Response"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          },
          "409": {
            "description": "Conflict",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          },
          "503": {
            "description": "Service Unavailable",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          }
        }
      }
    },
    "/api/v1/partner/tourists/lookup": {
      "post": {
        "security": [
          {
            "PartnerKeyAuth": []
          }
        ],
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["Partner Tax Free"],
        "summary": "Find an existing verified tourist and return their QR as a base64 PNG",
        "parameters": [
          {
            "description": "Exactly one of passport_number or qr_code",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/resthttp.PartnerTouristLookupRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/resthttp.PartnerTouristResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          },
          "409": {
            "description": "Conflict",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/dtohttp.ErrorResponse"
            }
          }
        }
      }
    },
    "/api/v1/nationalities": {
      "get": {
        "description": "Retrieve a list of all valid nationality codes",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "tags": ["Partner Tax Free"],
        "summary": "Get all nationalities",
        "responses": {
          "200": {
            "description": "List of nationality codes",
            "schema": {
              "$ref": "#/definitions/dtohttp.NationalitiesResponse"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "dtohttp.ErrorResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "error": {
          "type": "string"
        },
        "errors": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "dtohttp.NationalitiesResponse": {
      "type": "object",
      "properties": {
        "nationalities": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      }
    },
    "dtosvc.PartnerApplicationRequest": {
      "type": "object",
      "properties": {
        "receipt": {
          "$ref": "#/definitions/dtosvc.PartnerReceiptInput"
        },
        "refund": {
          "$ref": "#/definitions/dtosvc.PartnerRefundInput"
        },
        "tourist": {
          "$ref": "#/definitions/dtosvc.PartnerTouristInput"
        }
      }
    },
    "dtosvc.PartnerReceiptInput": {
      "type": "object",
      "properties": {
        "datetime": {
          "type": "string"
        },
        "fiscal_mark": {
          "type": "string"
        },
        "link": {
          "type": "string"
        },
        "ofd_type": {
          "type": "string"
        },
        "reg_number": {
          "type": "string"
        },
        "sum": {
          "type": "string"
        }
      }
    },
    "dtosvc.PartnerRefundInput": {
      "type": "object",
      "properties": {
        "bank_address": {
          "type": "string"
        },
        "bank_country": {
          "type": "string"
        },
        "bank_name": {
          "type": "string"
        },
        "card_number": {
          "type": "string"
        },
        "correspondent_bank": {
          "type": "string"
        },
        "iban": {
          "type": "string"
        },
        "recipient_address": {
          "type": "string"
        },
        "recipient_name": {
          "type": "string"
        },
        "swift_bic": {
          "type": "string"
        }
      }
    },
    "dtosvc.PartnerTouristInput": {
      "type": "object",
      "properties": {
        "first_name": {
          "type": "string"
        },
        "last_name": {
          "type": "string"
        },
        "nationality": {
          "type": "string"
        },
        "passport_number": {
          "type": "string"
        },
        "patronymic": {
          "type": "string"
        },
        "qr_code": {
          "type": "string"
        }
      }
    },
    "partner_application.Response": {
      "type": "object",
      "properties": {
        "application_id": {
          "type": "string"
        },
        "card_id": {
          "type": "string"
        },
        "created_at": {
          "type": "string"
        },
        "organization_id": {
          "type": "string"
        },
        "qr_code": {
          "type": "string"
        },
        "qr_code_base64": {
          "type": "string"
        },
        "receipt_link": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "total_nds_sum": {
          "type": "number"
        },
        "total_price": {
          "type": "number"
        },
        "tourist_created": {
          "type": "boolean"
        },
        "tourist_id": {
          "type": "string"
        },
        "tourist_qr_code": {
          "type": "string"
        },
        "tourist_qr_code_base64": {
          "type": "string"
        }
      }
    },
    "resthttp.PartnerTouristLookupRequest": {
      "type": "object",
      "properties": {
        "passport_number": {
          "type": "string"
        },
        "qr_code": {
          "type": "string"
        }
      }
    },
    "resthttp.PartnerTouristResponse": {
      "type": "object",
      "properties": {
        "first_name": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "last_name": {
          "type": "string"
        },
        "nationality": {
          "type": "string"
        },
        "passport_number": {
          "type": "string"
        },
        "patronymic": {
          "type": "string"
        },
        "qr_code": {
          "type": "string"
        },
        "qr_code_base64": {
          "type": "string"
        }
      }
    }
  },
  "securityDefinitions": {
    "PartnerKeyAuth": {
      "description": "Individual partner API key issued by an administrator",
      "type": "apiKey",
      "name": "X-API-Key",
      "in": "header"
    }
  }
}
