Loop Returns Cart API

The Cart API from Loop Returns — 2 operation(s) for cart.

OpenAPI Specification

loop-returns-cart-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Loop Returns Cart API
  description: API for managing shop carts in Shop Now On-Store exchanges.
  version: v1
servers:
- url: https://api.loopreturns.com/api/v1
tags:
- name: Cart
paths:
  /cart:
    post:
      summary: Create Cart
      operationId: createCart
      description: Create a cart object and populate it with one or more product variants.
      tags:
      - Cart
      security:
      - api_key: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCartRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                oneOf:
                - $ref: '#/components/schemas/CreatedCart'
                - $ref: '#/components/schemas/EmptyCart'
                - $ref: '#/components/schemas/VariantNotFound'
                - $ref: '#/components/schemas/CartNotSaved'
                - $ref: '#/components/schemas/InvalidCart'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
  /cart/{token}:
    get:
      summary: Get Cart
      operationId: getCart
      description: Get an existing cart by cart token.
      tags:
      - Cart
      security:
      - api_key: []
      parameters:
      - in: path
        name: token
        schema:
          type: string
        required: true
        description: The unique identifier token associated with a cart.
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cart'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
    post:
      summary: Update Cart
      operationId: updateCart
      description: Modify an existing cart. The array of product variants will overwrite the cart's existing contents.
      tags:
      - Cart
      security:
      - api_key: []
      parameters:
      - in: path
        name: token
        schema:
          type: string
        required: true
        description: The unique identifier token associated with a cart.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCartRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                oneOf:
                - $ref: '#/components/schemas/UpdatedCart'
                - $ref: '#/components/schemas/CartNotUpdated'
                - $ref: '#/components/schemas/EmptyCart'
                - $ref: '#/components/schemas/VariantNotFound'
                - $ref: '#/components/schemas/InvalidCart'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
    delete:
      tags:
      - Cart
      summary: Delete Cart
      operationId: deleteCart
      security:
      - api_key: []
      description: Delete an existing cart in Shop Now On-Store.
      parameters:
      - in: path
        name: token
        schema:
          type: string
        required: true
        description: The unique identifier token associated with a cart.
      responses:
        '200':
          description: Successful
          content:
            application/json:
              schema:
                oneOf:
                - $ref: '#/components/schemas/CartNotFound'
                - $ref: '#/components/schemas/CartNotDeleted'
                - $ref: '#/components/schemas/DeletedCart'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
components:
  schemas:
    CartNotUpdated:
      type: object
      properties:
        errors:
          type: object
          properties:
            message:
              type: string
              example: Error saving cart update.
    DeletedCart:
      type: boolean
      example: true
    UpdatedCart:
      type: object
      properties:
        updated:
          type: boolean
          example: true
        data:
          type: object
          properties:
            cart:
              type: array
              items:
                $ref: '#/components/schemas/Variant'
    CreateCartRequest:
      type: object
      required:
      - cart
      properties:
        cart:
          type: array
          items:
            $ref: '#/components/schemas/Variant'
          description: An array of product variants.
        shopify:
          description: A Base64-encoded liquid cart object, used to reflect additional transaction details in Shopify such as discounts.
          type: string
          example: c2FtcGxlLXN0cmluZw==
    UnauthorizedResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '401'
            http_code:
              type: string
              example: GEN-UNAUTHORIZED
            message:
              type: string
              example: Unauthorized.
    InvalidCart:
      type: object
      properties:
        errors:
          type: object
          properties:
            message:
              type: string
              example: Cart should contain a list of variant IDs.
    VariantNotFound:
      type: object
      properties:
        errors:
          type: object
          properties:
            message:
              type: string
              example: Variant ID 777777 not found.
        data:
          type: object
          properties:
            cart:
              type: array
              items:
                $ref: '#/components/schemas/Variant'
    UpdateCartRequest:
      type: object
      required:
      - cart
      properties:
        cart:
          type: array
          description: An array of product variant identifiers.
          items:
            $ref: '#/components/schemas/Variant'
    CartNotSaved:
      type: object
      properties:
        errors:
          type: object
          properties:
            message:
              type: string
              example: There was an error attempting to create the cart.
    Variant:
      type: number
      example: 39076568408247
      description: The unique identifier associated with a product variant.
    CreatedCart:
      type: object
      properties:
        token:
          type: string
          example: 46923497728c9a7b5o8a433zz5c0bbbb683319824778
          description: The cart's unique identifier.
        data:
          type: object
          properties:
            cart:
              type: array
              items:
                $ref: '#/components/schemas/Variant'
    CartNotFound:
      type: object
      properties:
        errors:
          type: object
          properties:
            message:
              type: string
              example: No cart found for the provided token.
    Cart:
      type: object
      properties:
        cart:
          type: array
          items:
            type: integer
            example: 39076568408247
    EmptyCart:
      type: object
      properties:
        errors:
          type: object
          properties:
            message:
              type: string
              example: Cart is empty.
        data:
          type: object
          properties:
            cart:
              type: array
              items:
                $ref: '#/components/schemas/Variant'
    CartNotDeleted:
      type: object
      properties:
        errors:
          type: object
          properties:
            message:
              type: string
              example: Failed to delete cart.
  securitySchemes:
    api_key:
      type: apiKey
      name: X-Authorization
      in: header