openapi: 3.0.0
info:
  title: Orders
  version: "2023"
  description: The Orders service provides all the functionality to access orders
    once a basket has been successfully checked out. The id of the order is the
    same id as the basket that was checkoud out.
tags:
  - name: Orders
paths:
  /orders:
    get:
      tags:
        - Orders
      operationId: getOrders
      summary: Get all orders
      description: Returns all the orders owned by the authorized user
      parameters:
        - $ref: "#/components/parameters/LocalHasApiKey"
      responses:
        "200":
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Models.Order"
  /orders/{orderId}:
    get:
      tags:
        - Orders
      operationId: getOrder
      summary: Get a specific order
      description: Returns the order with the given id
      parameters:
        - $ref: "#/components/parameters/LocalHasApiKey"
        - name: orderId
          in: path
          required: true
          description: The id of the order to retrieve. This is the same as the id of the
            basket that was checked out.
          schema:
            type: string
      responses:
        "200":
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Models.Order"
  /orders/{orderId}/status:
    get:
      tags:
        - Orders
      operationId: getOrderStatus
      summary: Get status for a specific order
      description: Returns the order status for given order
      parameters:
        - $ref: "#/components/parameters/HasApiKey"
        - name: orderId
          in: path
          required: true
          description: The id of the order to retrieve. This is the same as the id of the
            basket that was checked out.
          schema:
            type: string
      responses:
        "200":
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Models.OrderStatus"
security:
  - BearerAuth: []
components:
  parameters:
    HasApiKey:
      name: x-api-key
      in: header
      required: true
      description: OneBasket API Key
      schema:
        type: string
        format: password
    LocalHasApiKey:
      name: x-api-key
      in: header
      required: true
      description: OneBasket API Key
      schema:
        type: string
        format: password
  schemas:
    ApiKey:
      type: object
    Instant:
      type: string
    Models.Consumable.ConsumableLineItem:
      type: object
      required:
        - quantity
        - unitPrice
        - title
      properties:
        quantity:
          type: integer
          format: int32
          description: The number of instances of this product that was purchased.
        unitPrice:
          allOf:
            - $ref: "#/components/schemas/Money"
          description: The price of a single instance of this product, including any taxes.
        productGroupId:
          type: string
          description: Optional - The product group that the product belongs to. For
            consumables, this typically represents a menu.
        kioskId:
          type: string
          description: Optional - The kiosk from which this product is being purchased from.
        timestreamId:
          type: string
          description: Optional - The time stream that this product is being purchased
            within. For consumables, this typically represents a time period
            during an event, such as presales, early bird, half time, etc.
        validUntil:
          allOf:
            - $ref: "#/components/schemas/Instant"
          description: Optional - The time that this line item is valid until. This
            represents how long the current price of the line item is valid for.
            Pricing of products can change if they are in a time stream.
        title:
          type: string
          description: The title of the product. For example, 'Cheeseburger'.
        description:
          type: string
          description: The description of the product. For example, 'A delicious
            cheeseburger with a beef patty, cheese, lettuce, tomato, and onion.'
        allergens:
          type: string
          description: The allergens that the product contains. For example, 'Gluten,
            Dairy, Eggs'.
        image:
          type: string
          description: The image of the product.
        calories:
          type: integer
          format: int32
          description: The calories of the product.
      description: A consumable line item represents a product that a human can
        consume (eat or drink).
    Models.DeliveryMethods.DeliveryMethod:
      type: object
      required:
        - type
      properties:
        type:
          allOf:
            - $ref: "#/components/schemas/Models.DeliveryMethods.DeliveryMethodType"
          description: The type of the delivery method
      discriminator:
        propertyName: type
        mapping:
          KioskCollection: "#/components/schemas/Models.DeliveryMethods.KioskCollectionDelivery"
          InSeat: "#/components/schemas/Models.DeliveryMethods.InSeatDelivery"
      description: Represents a delivery method that is available from a given provider.
    Models.DeliveryMethods.DeliveryMethodType:
      type: string
      enum:
        - KioskCollection
        - InSeat
      description: Discriminator for delivery method types
    Models.DeliveryMethods.InSeatDelivery:
      type: object
      required:
        - type
        - kioskId
        - kioskName
        - collectionId
        - collectionTime
        - scannable
      properties:
        type:
          type: string
          enum:
            - InSeat
        kioskId:
          allOf:
            - $ref: "#/components/schemas/ProviderIdentity"
          description: The id of the kiosk where the order is placed
        kioskName:
          type: string
          description: The name of the kiosk where the order is placed
        collectionId:
          type: string
          description: The id of the collection period
        collectionTime:
          allOf:
            - $ref: "#/components/schemas/Instant"
          description: The time at which the order will be delivered to the seat
        scannable:
          allOf:
            - $ref: "#/components/schemas/Models.Scannables.Scannable"
          description: The scannable which the customer may present when receiving the order
      allOf:
        - $ref: "#/components/schemas/Models.DeliveryMethods.DeliveryMethod"
      description: Represents a seat where the customers order will be delivered.
    Models.DeliveryMethods.KioskCollectionDelivery:
      type: object
      required:
        - type
        - kioskId
        - kioskName
        - collectionId
        - collectionTime
        - scannable
      properties:
        type:
          type: string
          enum:
            - KioskCollection
        kioskId:
          allOf:
            - $ref: "#/components/schemas/ProviderIdentity"
          description: The id of the kiosk which the order can be collected from
        kioskName:
          type: string
          description: The name of the kiosk which the order can be collected from
        collectionId:
          type: string
          description: The id of the collection period
        collectionTime:
          allOf:
            - $ref: "#/components/schemas/Instant"
          description: The time at which the order can be collected from the kiosk
        scannable:
          allOf:
            - $ref: "#/components/schemas/Models.Scannables.Scannable"
          description: The scannable which the customer must present to collect the order
      allOf:
        - $ref: "#/components/schemas/Models.DeliveryMethods.DeliveryMethod"
      description: Represents a kiosk that the customer will collect their order from.
    Models.Discounts.ProviderDiscount:
      type: object
      required:
        - id
        - title
        - code
        - description
        - amount
      properties:
        id:
          type: string
        title:
          type: string
        code:
          type: string
        description:
          type: string
        amount:
          $ref: "#/components/schemas/Money"
      description: Provider discount
    Models.Fulfilment.Cancelled:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - Cancelled
        reason:
          type: string
      allOf:
        - $ref: "#/components/schemas/Models.Fulfilment.FulfilmentEvent"
    Models.Fulfilment.Fulfilled:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - Fulfilled
      allOf:
        - $ref: "#/components/schemas/Models.Fulfilment.FulfilmentEvent"
    Models.Fulfilment.FulfilmentEvent:
      type: object
      allOf:
        - $ref: "#/components/schemas/Models.ProviderOrderEvent"
      description: A discriminated type representing fulfilment events
    Models.Fulfilment.InProgress:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - InProgress
      allOf:
        - $ref: "#/components/schemas/Models.Fulfilment.FulfilmentEvent"
    Models.Fulfilment.Ready:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - Ready
      allOf:
        - $ref: "#/components/schemas/Models.Fulfilment.FulfilmentEvent"
    Models.Fulfilment.Received:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - Received
      allOf:
        - $ref: "#/components/schemas/Models.Fulfilment.FulfilmentEvent"
    Models.LineItem:
      type: object
      required:
        - id
        - type
        - productId
        - totalPrice
        - totalTax
      properties:
        id:
          allOf:
            - $ref: "#/components/schemas/ProviderIdentity"
          description: The id of the line item
        type:
          allOf:
            - $ref: "#/components/schemas/Models.LineItemType"
          description: The type of the line item.
        productId:
          allOf:
            - $ref: "#/components/schemas/ProviderIdentity"
          description: The product that has been purchased.
        totalPrice:
          allOf:
            - $ref: "#/components/schemas/Money"
          description: The price of the line item, including tax.
        totalTax:
          allOf:
            - $ref: "#/components/schemas/Money"
          description: The tax component of the total price.
        originalTotalPrice:
          allOf:
            - $ref: "#/components/schemas/Money"
          description: The total price of the line item before applying discounts.
        totalDiscount:
          allOf:
            - $ref: "#/components/schemas/Money"
          description: The total discount of the line item
        providerDiscounts:
          type: array
          items:
            $ref: "#/components/schemas/Models.Discounts.ProviderDiscount"
          description: Further details about the line item, if it is of type Ticketing
        ticketing:
          allOf:
            - $ref: "#/components/schemas/Models.Ticketing.TicketingLineItem"
          description: Further details about the line item, if it is of type Ticketing
        consumable:
          allOf:
            - $ref: "#/components/schemas/Models.Consumable.ConsumableLineItem"
          description: Further details about the line item, if it is of type Consumable
        timeSlot:
          allOf:
            - $ref: "#/components/schemas/Models.TimeSlot.TimeSlotLineItem"
          description: Further details about the line item, if it is of type TimeSlot
        variableProduct:
          allOf:
            - $ref: "#/components/schemas/Models.VariableProduct.VariableProductLineItem"
          description: Further details about the line item, if it is of type VariableProduct
      description: A line item that represents a product that has been purchased.
    Models.LineItemType:
      type: string
      enum:
        - Ticketing
        - Consumable
        - TimeSlot
        - VariableProduct
      description: The type of a line item. OneBasket supports many different product
        types that can be purchased.
    Models.Order:
      type: object
      required:
        - id
        - created
        - providerOrders
        - events
      properties:
        id:
          type: string
          description: The id of the order
        created:
          allOf:
            - $ref: "#/components/schemas/Instant"
          description: The time the order was created. Does not indicate the time the
            order completed processing.
        providerOrders:
          type: array
          items:
            $ref: "#/components/schemas/Models.ProviderOrder"
          description: A list of all providers that products have been purchased from.
        events:
          type: array
          items:
            $ref: "#/components/schemas/Models.ProviderOrderEvent"
          description: A list of all events that have occurred for this order, across all
            providers. Events are ordered by time.
      description: Represents an order placed by a customer
    Models.OrderStatus:
      type: object
      required:
        - id
        - processingCompleted
        - hasRejections
      properties:
        id:
          type: string
          description: The id of the order
        processingCompleted:
          type: boolean
          description: Indicates whether order processing is completed
        hasRejections:
          type: boolean
          description: Indicates whether order has rejections
    Models.Processing.Confirmed:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - Confirmed
      allOf:
        - $ref: "#/components/schemas/Models.Processing.ProcessingEvent"
    Models.Processing.ProcessingEvent:
      type: object
      allOf:
        - $ref: "#/components/schemas/Models.ProviderOrderEvent"
      description: A discriminated type representing processing events
    Models.Processing.Rejected:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - Rejected
      allOf:
        - $ref: "#/components/schemas/Models.Processing.ProcessingEvent"
    Models.Processing.RejectionReason:
      type: object
      required:
        - rejectionCode
      properties:
        rejectionCode:
          type: string
    Models.Processing.Sent:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - Sent
      allOf:
        - $ref: "#/components/schemas/Models.Processing.ProcessingEvent"
    Models.ProviderOrder:
      type: object
      required:
        - id
        - lineItems
        - totalPrice
        - totalTax
        - deliveryMethods
      properties:
        id:
          allOf:
            - $ref: "#/components/schemas/ProviderIdentity"
          description: The id of the provider order
        lineItems:
          type: array
          items:
            $ref: "#/components/schemas/Models.LineItem"
          description: A list of all line items included in the provider order.
        totalPrice:
          allOf:
            - $ref: "#/components/schemas/Money"
          description: The total price of the order, including tax.
        totalTax:
          allOf:
            - $ref: "#/components/schemas/Money"
          description: The total tax component of the total price.
        originalTotalPrice:
          allOf:
            - $ref: "#/components/schemas/Money"
          description: The total price of the order before appying discounts.
        totalProviderDiscounts:
          allOf:
            - $ref: "#/components/schemas/Money"
          description: The total discount sum.
        providerDiscounts:
          type: array
          items:
            $ref: "#/components/schemas/Models.Discounts.ProviderDiscount"
          description: A list of all discounts applied on the provider order.
        deliveryMethods:
          type: array
          items:
            $ref: "#/components/schemas/Models.DeliveryMethods.DeliveryMethod"
          description: A list of dilevery methods used to fulfil the order.
      description: Represents an order placed by a customer with an external provider.
    Models.ProviderOrderEvent:
      type: object
      required:
        - providerOrderId
        - category
        - eventTime
        - receivedTime
        - id
        - type
      properties:
        providerOrderId:
          allOf:
            - $ref: "#/components/schemas/ProviderIdentity"
          description: The provider order that the event occurred on.
        category:
          allOf:
            - $ref: "#/components/schemas/Models.ProviderOrderEventCategory"
          description: The category of the event.
        eventTime:
          allOf:
            - $ref: "#/components/schemas/Instant"
          description: The actual time the event occured.
        receivedTime:
          allOf:
            - $ref: "#/components/schemas/Instant"
          description: The time the event was received by OneBasket.
        id:
          type: string
          description: The id of the event
        type:
          type: string
          description: The type of the processing event
      discriminator:
        propertyName: type
        mapping:
          Sent: "#/components/schemas/Models.Processing.Sent"
          Confirmed: "#/components/schemas/Models.Processing.Confirmed"
          Rejected: "#/components/schemas/Models.Processing.Rejected"
          Received: "#/components/schemas/Models.Fulfilment.Received"
          InProgress: "#/components/schemas/Models.Fulfilment.InProgress"
          Ready: "#/components/schemas/Models.Fulfilment.Ready"
          Fulfilled: "#/components/schemas/Models.Fulfilment.Fulfilled"
          Cancelled: "#/components/schemas/Models.Fulfilment.Cancelled"
      description: Represents an event that has occurred for a provider order, across
        a number of different categories
    Models.ProviderOrderEventCategory:
      type: string
      enum:
        - Processing
        - Fulfilment
    Models.Scannables.QrCodeScannable:
      type: object
      required:
        - type
        - data
      properties:
        type:
          type: string
          enum:
            - QrCode
        data:
          type: string
          description: The data encoded in the QR code. Use this to generate the QR code.
      allOf:
        - $ref: "#/components/schemas/Models.Scannables.Scannable"
      description: Scannable of QR code type
    Models.Scannables.Scannable:
      type: object
      required:
        - type
      properties:
        type:
          allOf:
            - $ref: "#/components/schemas/Models.Scannables.ScannableType"
          description: The type of scannable
      discriminator:
        propertyName: type
        mapping:
          QrCode: "#/components/schemas/Models.Scannables.QrCodeScannable"
      description: Represents a scannable item that can be used to identify a
        customer's order.
    Models.Scannables.ScannableType:
      type: string
      enum:
        - QrCode
      description: Discriminator for scannable types
    Models.Ticketing.EventType:
      type: string
      enum:
        - SportsMatch
      description: Sub type of the TicketEvent type.
    Models.Ticketing.SportsCompetition:
      type: object
      required:
        - name
        - season
        - competitionType
      properties:
        name:
          type: string
          description: The name of the competition (Premier League 2021, Champions League
            2021, etc)
        season:
          type: string
          description: The season of the competition (2019/20, 2020/21, etc)
        competitionType:
          type: string
          description: The type of competition (Premier League, Champions League, etc)
      description: Represents a sports competition
    Models.Ticketing.SportsMatch:
      type: object
      required:
        - matchDate
        - competition
        - hostTeam
        - opponentTeam
      properties:
        matchDate:
          allOf:
            - $ref: "#/components/schemas/Instant"
          description: The date of the match, including time
        competition:
          allOf:
            - $ref: "#/components/schemas/Models.Ticketing.SportsCompetition"
          description: Which competition the match is part of
        hostTeam:
          allOf:
            - $ref: "#/components/schemas/Models.Ticketing.SportsTeam"
          description: The home team
        opponentTeam:
          allOf:
            - $ref: "#/components/schemas/Models.Ticketing.SportsTeam"
          description: The away team
      description: Represents a sports match that a ticket can be purchased for.
    Models.Ticketing.SportsTeam:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: string
          description: The id of the team
        name:
          type: string
          description: The name of the team
        logoImageUrl:
          type: string
          description: The team crest
      description: Represents a sports team (Football, Rugby, Cricket, etc)
    Models.Ticketing.Ticket:
      type: object
      required:
        - id
        - providerSeatId
        - seatCategory
        - tariff
        - section
        - row
        - seat
        - price
      properties:
        id:
          type: string
          description: The id of the ticket
        providerSeatId:
          type: string
          description: The id of the seat being purchased. This is the id that the
            provider uses to identify the seat.
        seatCategory:
          type: string
          description: The seat category of the seat being purchased.
        tariff:
          type: string
          description: The tariff of the seat being purchased.
        section:
          type: string
          description: The section the seat is in
        row:
          type: string
          description: The row the seat is in
        seat:
          type: string
          description: The seat number
        price:
          allOf:
            - $ref: "#/components/schemas/Money"
          description: The price of the ticket, including any taxes.
      description: Represens a ticket being purchased for an event.
    Models.Ticketing.TicketingLineItem:
      type: object
      required:
        - type
        - tickets
      properties:
        type:
          allOf:
            - $ref: "#/components/schemas/Models.Ticketing.TicketingType"
          description: The type of ticketing product this line item represents
        eventType:
          allOf:
            - $ref: "#/components/schemas/Models.Ticketing.EventType"
          description: If a TicketEvent type, then this indicates what sort of ticketed
            event.
        sportsMatch:
          allOf:
            - $ref: "#/components/schemas/Models.Ticketing.SportsMatch"
          description: If the event type is 'SportsMatch', contains additional information
            about the line item's event
        tickets:
          type: array
          items:
            $ref: "#/components/schemas/Models.Ticketing.Ticket"
          description: A list of tickets that have been added to the basket for this event.
      description: A ticketing line item represents a product that is related to ticketing.
    Models.Ticketing.TicketingType:
      type: string
      enum:
        - TicketedEvent
      description: A sub type of the line item type.
    Models.TimeSlot.TimeSlotLineItem:
      type: object
      required:
        - quantity
        - unitPrice
      properties:
        quantity:
          type: integer
          format: int32
        unitPrice:
          $ref: "#/components/schemas/Money"
    Models.VariableProduct.VariableProductLineItem:
      type: object
      required:
        - quantity
        - unitPrice
        - variant
      properties:
        quantity:
          type: integer
          format: int32
        unitPrice:
          $ref: "#/components/schemas/Money"
        variant:
          $ref: "#/components/schemas/Models.VariableProduct.VariableProductVariant"
    Models.VariableProduct.VariableProductVariant:
      type: object
      required:
        - id
        - name
        - sku
        - imageUrl
      properties:
        id:
          $ref: "#/components/schemas/ProviderIdentity"
        name:
          type: string
        sku:
          type: string
        imageUrl:
          type: string
    Money:
      type: object
      required:
        - minorUnits
        - currencyCode
        - precision
      properties:
        minorUnits:
          type: integer
          format: int32
        currencyCode:
          type: string
        precision:
          type: integer
          format: int32
    ProviderIdentity:
      type: string
      pattern: ^[a-z0-9]{1,5}(:[a-z0-9]{1,12})?\|[a-z0-9]{24}$
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
servers:
  - url: https://storefront.sandbox.onebasket.io
    description: Sandbox
    variables: {}
  - url: https://storefront.live.onebasket.io
    description: Live
    variables: {}
