openapi: 3.0.0
info:
  description: |
    ## Overview 

    This is the API description for Sniffie's Omnibus API.
  version: 1.0.0
  title: Sniffie Omnibus API
tags:
  - name: omnibus
    description: Get omnibus info of account
servers:
  - url: https://api.sniffie.fi/    # The "url: " prefix is required    
paths:
  /omnibus/:
    post:
      tags:
        - omnibus
      summary: Gets omnibus info for the product via POST protocol (preferred protocol)
      requestBody:
        description: POST request body
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: "#/components/schemas/PostBody"
      responses:
        200:
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OmnibusResult'
        500:
          $ref: '#/components/responses/5XX'
    get:
      tags:
        - omnibus
      summary: Gets omnibus info for the product via GET protocol (POST is preferred protocol)
      parameters:
        - name: apiKey
          in: query
          description: API key
          required: true
          schema:
            type: string
        - name: limit
          in: query
          description: How many results are returned. Default 100, maximum 1000.
          example: 100
          schema:
            type: integer
            default: 100
        - name: offset
          in: query
          description: Offset for results, default 0.
          example: 0
          schema:
            type: integer
            default: 0
        - name: skuList
          in: query
          description: List of SKUs omnibus price is wanted for. If empty, gets everything.
          schema:
            type: array
            items:
              type: "string"
              example: ["sku1", "sku2", "sku3"]
        - name: websiteList
          in: query
          description: List of websites omnibus price is wanted for. If empty, gets everything.
          schema:
            type: array
            items:
              type: "string"
              example: ["website1", "website2", "website3"]
      responses:
        200:
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OmnibusResult'
        500:
          $ref: '#/components/responses/5XX'
components:
  responses:
    5XX:
      description: Unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    404:
      description: Item not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    PostBody:
      type: object
      required: [apiKey]
      properties:
        apiKey:
          type: string
          description: API key
          example: "API_KEY_HERE"
        skuList:
          description: List of SKUs omnibus price is wanted for. If empty, gets everything.
          type: array
          items:
            type: "string"
            example: ["sku1", "sku2", "sku3"] 
        websiteList:
          description: List of websites omnibus price is wanted for. If empty, gets everything.
          type: array
          items:
            type: "string"
            example: ["website1", "website2", "website3"]    
        limit:
          type: integer
          description: How many results are returned. Default 100, maximum 1000.
          example: 0
          default: 0
        offset:
          type: integer
          description: Offset for results, default 0.
          example: 0
          default: 0

    Error:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
      required:
        - code
        - message
    OmnibusResult:
      type: object
      properties:
        success:
          type: boolean
          description: Whether the request was successful
        info:
          type: string
          description: Some information about the request (mostly if unsuccessful)
        errorCode:
          type: integer
          description: If error happens, some information about it her
        result:
          $ref: '#/components/schemas/OmnibusRow'
        totalCount:
          type: integer
          description: How many rows of information is available overall based on the filters
        requestInfo:
          $ref: '#/components/schemas/RequestInfo'
    RequestInfo:
      properties:
        limit:
          type: integer
          description: What was the used limit in the query
        offset:
          type: integer
          description: What was the used offset in the query
        filteredSkus:
          type: integer
          description: How many SKUs were provided in SKU list query parameter
        filteredWebsites:
          type: integer
          description: How many Websites were provided in SKU list query parameter
    OmnibusRow:
      properties:
        SKU:
          type: string
          description: SKU for the product
        website:
          type: string
          description: website for the product,
        infoJson:
          $ref: "#/components/schemas/InfoJson"
    InfoJson:
      properties:
        OmnibusPrice:
          $ref: "#/components/schemas/OmnibusPriceObject"
    OmnibusPriceObject:
      properties:
        lowestPrice:
          type: number
          description: Lowest price (including possible coupons)
        date:
          type: string
          description: Date when the lowest price has occurred
        evaluationPeriod:
          $ref: "#/components/schemas/EvaluationPeriod"
        cause:
          $ref: "#/components/schemas/Cause"
    Cause:
      properties:
        price:
          type: number
          description: Price without coupons
        coupon:
          $ref: "#/components/schemas/Coupon"
    Coupon:
      properties:
        id:
          type: number
          description: ID for the coupon
        discountPercentage:
          type: number
          description: Discount percentage for coupon. Empty if discountValue is used
        discountValue:
          type: number
          description: Discount value for coupon. Empty if discountPercentage is used
        priceType:
          type: string
          description: if the coupon applies to all products or normal priced products only
          example: 'all'
        couponCode:
          type: string
          description: Coupon code for the coupon in question
        startsFrom:
          type: string
          description: Date when the coupon starts to work.
        endsOn:
          type: string
          description: Date when the coupon code expires. Empty if coupon does not have an expiry date.
    EvaluationPeriod:
      properties:
        to:
          type: string
          description: Last date for evaluation
        from:
          type: string
          description: First date for evaluation
