openapi: 3.0.1

info:
  title: Alchemy Base API
  version: 1.0.0
security:
  - BearerAuth: [ ]
paths:
  # Sale Order
  /sale-orders:
    post:
      tags:
        - sale-orders
      summary: "Create new sale Orders from Cart"
      description: "API Sale Order"
      operationId: "CreateFromCart"
      responses:
        "200":
          $ref: "#/components/responses/PostSaleOrdersRestResponse"
        default:
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
  /sale-orders/summary:
    get:
      tags:
        - sale-orders
      summary: "Get Sale Order Summary"
      description: "API Sale Order Summary"
      operationId: "GetSOSummary"
      responses:
        "200":
          $ref: "#/components/responses/PostSaleOrdersRestResponse"
        default:
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
  /sale-orders/{order_reference}:
    post:
      tags:
        - sale-orders
      summary: "update sale Orders adding documents/ updating status"
      description: "API Sale Order"
      operationId: "UpdateSaleOrder"
      parameters:
        - $ref: "#/components/parameters/OrderReference"
      requestBody:
        $ref: "#/components/requestBodies/UpdateSaleOrder"
      responses:
        "200":
          $ref: "#/components/responses/PostUpdateSaleOrdersRestResponse"
        default:
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
  /sale-orders/{order_reference}/asn/export:
    get:
      tags:
        - sale-orders
      summary: "Export ASN data into a file in the specified format"
      description: "Export ASN data into a file in the specified format"
      operationId: "ExportASNToFile"
      parameters:
        - $ref: "#/components/parameters/OrderReference"    
        - in: query
          name: format
          required: true
          description: The desired file format (e.g., csv)
          schema:
            type: string
            enum:
              - csv
      responses:
        "200":
          $ref: "#/components/responses/GetSaleOrdersASNExportedFileResponse"
        default:
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
  # bids
  /bids/{bid_id}/winner:
    put:
      tags:
        - bids
      summary: "award  winner"
      description: "Endpoint to award the winner bid ,ending with the creation of an order from Auction"
      operationId: "CreateFromAuction"
      parameters:
        - $ref: "#/components/parameters/BidID"
      responses:
        "200":
          $ref: "#/components/responses/PutBidAwardWinnerResponse"
        default:
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestError'
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
  parameters:
    BidID:
      name: bid_id
      in: path
      required: true
      description: winner bid id
      schema:
        type: string
    OrderReference:
      name: order_reference
      in: path
      required: true
      description: reference string of one order
      schema:
        type: string
  requestBodies:
    UpdateAddNote:
      content:
        application/json:
          schema:
            type: object
            properties:
              note:
                type: string
              user_id:
                type: integer
                format: uint64
    UpdateSaleOrder:
      content:
        multipart/form-data:
          schema:
            type: object
            properties:
              _method:
                type: string
              note:
                type: string
              incoterm_id:
                type: integer
                format: uint64
              shipped_date:
                type: string
              collect_date:
                type: string
              sku_release_time:
                type: string
              shipping_method_id:
                type: integer
                format: uint64
              tracking_code:
                type: string
              tracking_url:
                type: string
              courier_name:
                type: string
              doc_type_id:
                type: integer
                format: uint32
              no_airbill:
                type: integer
                format: boolean
                x-oapi-codegen-extra-tags:
                  validate: "min=0,max=1"
              payment_overdue:
                type: integer
                format: uint64
                x-oapi-codegen-extra-tags:
                  validate: "min=0,max=1"
              type:
                type: string
              status:
                type: integer
                format: uint32
              _types:
                type: string
              document:
                type: string
  responses:
    PostSaleOrdersRestResponse:
      description: Post Sale Orders Rest Response
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Response"
    GetSaleOrderSummaryRestResponse:
      description: Get Sale Order Summary  Rest Response
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Response"
    PostUpdateSaleOrdersRestResponse:
      description: Post Update Sale Orders Rest Response
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ResponseUpdate"
    PutBidAwardWinnerResponse:
      description: Put Bid Award Winner
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Response"
    GetSaleOrdersASNExportedFileResponse:
      description: Get Sale Orders ASN data as file Rest Response
      content:
        application/octet-stream:
          schema:
            type: string
            format: binary
      headers:
        Content-Type:
          description: The media type of the file
          schema:
            type: string
            example: text/csv
        Content-Disposition:
          description: The disposition type and filename for the file
          schema:
            type: string
            example: 'attachment; filename=exported_file.csv'
  schemas:
    Response:
      type: object
      required:
        - "success"
        - "result"
      optional:
        - "error"
      properties:
        success:
          type: boolean
        result:
          AnyValue: { }
        error:
          type: object
    ResponseUpdate:
      schemas:
        AnyValue: { }
    RestError:
      type: object
      properties:
        message:
          type: string
        success:
          type: boolean
        status_text:
          type: string
