openapi: 3.0.3
info:
  title: External Orders API
  version: 1.0.0
paths:
  /v2/external-orders/{store_id}/collect:
    parameters:
      - name: store_id
        in: path
        schema:
          type: string
        required: true
        description: Store identifier
    post:
      summary: Collect external orders
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExternalOrdersCollectRequest'
      responses:
        200:
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponse'
        400:
          description: Error response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

components:
  schemas:
    SuccessResponse:
      type: object
      required:
        - status
      properties:
        status:
          type: string
          enum:
            - 'ok'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: 'Validation error'
        messages:
          type: array
          items:
            type: string
    ExternalOrdersCollectRequest:
      type: object
      required:
        - orders
      properties:
        orders:
          type: array
          items:
            $ref: '#/components/schemas/ExternalOrder'
    ExternalOrder:
      type: object
      required:
        - order_id
      properties:
        order_id:
          type: string
          example: GL198123
          description: Buyer facing order identifier
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        status:
          type: string
          enum:
            - RECEIVED
            - READY
            - ACCEPTED
            - COMPLETED
            - CANCELLED
        buyer_currency:
          $ref: '#/components/schemas/CurrencyCode'
        origin_currency:
          $ref: '#/components/schemas/CurrencyCode'
        origin_to_buyer_fx:
          type: number
        destination_country:
          $ref: '#/components/schemas/CountryCode'
        billing_country:
          $ref: '#/components/schemas/CountryCode'
        shipping_method:
          type: string
        language:
          $ref: '#/components/schemas/LanguageTag'
        payment_gateway:
          type: string
          example: paypal
        payment_amount:
          $ref: '#/components/schemas/Amount'
        features:
          $ref: '#/components/schemas/Features'
        summary:
          $ref: '#/components/schemas/Summary'
    Summary:
      type: object
      required:
        - total
      properties:
        items:
          $ref: '#/components/schemas/Charge'
        discounts:
          $ref: '#/components/schemas/Charge'
        shipping:
          $ref: '#/components/schemas/Charge'
        extra:
          $ref: '#/components/schemas/Charge'
        total:
          $ref: '#/components/schemas/Charge'
    Charge:
      type: object
      required:
        - total
      properties:
        amount_net:
          $ref: '#/components/schemas/Amount'
        tax_on_amount:
          $ref: '#/components/schemas/Amount'
        duty_on_amount:
          $ref: '#/components/schemas/Amount'
        tax_on_duty:
          $ref: '#/components/schemas/Amount'
        total:
          $ref: '#/components/schemas/Amount'
    Features:
      type: object
      properties:
        xport_tcc:
          type: boolean
        localization:
          type: boolean
        checkout:
          type: boolean
    LanguageTag:
      title: LanguageTag (Simplified IETF BCP-47 language[-script][-country])
      type: string
      pattern: '^([a-z]{2,3})(-([A-Z][a-z]{3}))?(-([A-Z]{2}))?$'
      example: 'fr-FR'
    CurrencyCode:
      type: string
      description: "ISO 4217 currency code"
      pattern: "^[A-Z]{3}$"
      example: EUR
    CountryCode:
      type: string
      description: "ISO 3166-1 alpha-2 country code"
      pattern: "^[A-Z]{2}$"
      example: FR
    Amount:
      type: number

