swagger: '2.0'
info:
  title: Store Availability API Specifications
  version: 0.0.1
host: ows-store-availability.theorchard.io
basePath: /
schemes:
  - https
paths:
  '/admin/produce-job-messages/{store_id}':
    post:
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - in: path
          name: store_id
          required: true
          type: string
        - description: UUID
          in: header
          name: Correlation-Id
          type: string
        - description: Grass account type.
          enum:
            - vendor
            - subaccount
          in: header
          name: Grass-Account-Type
          type: string
        - description: Grass account id.
          in: header
          name: Grass-Account-Id
          pattern: ^\d+$
          type: string
      responses:
        '200':
          description: Messages for given store were generated and sent to SQS.
        '404':
          description: Store with specified ID not found.
      description: Produce polling job messages for specified store and send them to SQS.
  /admin/products:
    post:
      parameters:
        - description: UUID
          in: header
          name: Correlation-Id
          type: string
          format: string
        - description: Grass account id.
          in: header
          name: Grass-Account-Id
          pattern: ^\d+$
          type: string
        - description: Grass account type.
          in: header
          name: Grass-Account-Type
          type: string
          enum:
            - vendor
            - subaccount
        - description: Add products to admin/products
          in: body
          name: body
          required: true
          schema:
            $ref: '#/definitions/add-products-to-poll-post'
      responses:
        '204':
          description: Releases were saved to DB.
        '400':
          description: >
            HTTP 400 Bad Request.

            ---------------------

            The body contains the fields that did not pass validation with a
            validation context message.
      description: >
        Add releases which should be polled for status in provided store.

        Idempotent, second submission of same release in same store will be
        ignored.
  /hello/:
    get:
      responses:
        '200':
          description: 200 OK
      description: Check the health of the application.
  /status:
    get:
      parameters:
        - description: >-
            Release ids to check status for. Can be either single ID or
            multiple, separated by comma.
          in: query
          name: product_ids
          required: true
          type: string
        - description: UUID
          in: header
          name: Correlation-Id
          required: false
          type: string
        - description: Grass account type.
          enum:
            - vendor
            - subaccount
          in: header
          name: Grass-Account-Type
          required: false
          type: string
        - description: Grass account id.
          in: header
          name: Grass-Account-Id
          pattern: ^\d+$
          required: false
          type: string
      responses:
        '200':
          description: >
            HTTP 200 OK.

            ---------------

            JSON object containing array of releases with statuses in each
            store.
        '400':
          description: Request parameter/header validation failure.
        '403':
          description: Not authorized to check status of release.
      description: >
        Get release status of products for each store where particular product
        exists.

        Can retrieve status only for products that belong to account in
        Grass-Account-Id header.
  /admin/import_store_links:
    post:
      parameters:
        - description: UUID
          in: header
          name: Correlation-Id
          type: string
          format: string
        - description: OA user ID
          in: header
          name: Orchard-User-Id
          type: string
          format: string
        - description: Import store links
          in: body
          name: body
          required: true
          schema:
            $ref: '#/definitions/admin/import_store_links'
      responses:
        '200':
          description: Product links imported.
      description: >
        Import store link(s).
definitions:
  Product:
    type: object
    properties:
      delivery_date:
        format: date-time
        type: string
      force_polling:
        type: boolean
      itunes_vendor_id:
        pattern: '^[0-9]{0,25}$'
        type: string
      orchard_product_id:
        type: number
      product_id:
        type: number
      provider:
        enum:
          - orchard
          - ioda
        type: string
      sales_start_date:
        format: date-time
        type: string
      store_id:
        type: integer
        enum:
          - 1
          - 286
          - 348
      upc:
        type: string
    required:
      - upc
      - store_id
      - product_id
      - orchard_product_id
  add-products-to-poll-post:
    type: object
    properties:
      products:
        type: array
        items:
          $ref: '#/definitions/Product'
  import_store_links:
    type: array
securityDefinitions: {}
