swagger: "2.0"

info:
  version: 1.0.0
  title: API Specifications

schemes:
  - https
host: qa-ows-conflict-manager.theorchard.io
paths:
  /hello/:
    get:
      summary: Check the health of the application.
      tags:
        - Health check
      responses:
        200:
          description: 200 OK
          examples:
            application/json: { "status": "ok" }
  /conflicts/new:
    get:
      summary: Get list of all new conflicts for given account ID. Account_id and account_type
        should be present either in headers or in query.
      parameters:
        - description: Grass account type
          in: header
          enum:
            - vendor
            - subaccount
          name: Grass-Account-Type
          required: false
          type: string
        - description: Grass account id
          in: header
          name: Grass-Account-Id
          pattern: ^\d+$
          required: false
          type: string
        - description: UUID
          in: header
          name: Correlation-Id
          required: false
          type: string
        - description: Grass account type
          in: query
          enum:
            - vendor
            - subaccount
          name: account_type
          required: false
          type: string
        - description: Grass account id
          in: query
          name: account_id
          pattern: ^\d+$
          required: false
          type: string
        - description: Page offset
          in: query
          name: page_offset
          required: false
          type: integer
        - description: Page limit
          in: query
          name: page_limit
          required: false
          type: integer
      tags:
        - New conflicts
      responses:
        200:
          description: 200 OK
          examples:
            application/json: {
              "items": [
                  {
                      "conflict_id": 1,
                      "track_name": "Hello",
                      "track_artists": ["some artist"],
                      "isrc": "USABC1234",
                      "product_id": "123",
                      "display_upc": "0123030399",
                      "product_name": "Hello Product",
                      "conflicting_owner": "Some Company",
                      "conflict_date": "2017-05-14 00:00:00",
                      "territory_standard": "ISO_3166_2106",
                      "territories": [
                          {
                              "name": "United States of America",
                              "code": "US",
                              "continent_name": "North America"
                          },
                      ],
                      "status": "NEW",
                      "daily_average_views": 2,
                      "tuid": 123,
                      "vendor_id": 123,
                      "subaccount_id": 456
                  },
              ],
              "pagination": {
                  "type": "standard",
                  "offset": 0,
                  "limit": 50,
                  "total_records": 1
              }
          }
        400:
          description: Bad request
  /action:
    post:
      summary: Creates an action taken by Workstation user. This endpoint is meant to handle the action request in when the user finishes the “Resolve” workflow
      parameters:
        - description: Grass account type
          in: header
          enum:
            - vendor
            - subaccount
          name: Grass-Account-Type
          required: false
          type: string
        - description: Grass account id
          in: header
          name: Grass-Account-Id
          pattern: ^\d+$
          required: false
          type: string
        - description: UUID
          in: header
          name: Correlation-Id
          required: false
          type: string
        - description: Grass account type
          in: query
          enum:
            - vendor
            - subaccount
          name: account_type
          required: false
          type: string
        - description: Grass account id
          in: query
          name: account_id
          pattern: ^\d+$
          required: false
          type: string
        - in: body
          schema:
            $ref: '#/definitions/PostActionPayload'
      responses:
        200:
          description: 200 OK
          examples:
            application/json: {'number of rows created': 2}
        400:
          description: Bad request
  /action/bulk:
    post:
      summary: Creates multiple actions taken by Workstation user. This endpoint is meant to handle the action request in when the user finishes the “Bulk Respond” workflow
      parameters:
        - description: Grass account type
          in: header
          enum:
            - vendor
            - subaccount
          name: Grass-Account-Type
          required: false
          type: string
        - description: Grass account id
          in: header
          name: Grass-Account-Id
          pattern: ^\d+$
          required: false
          type: string
        - description: UUID
          in: header
          name: Correlation-Id
          required: false
          type: string
        - description: Grass account type
          in: query
          enum:
            - vendor
            - subaccount
          name: account_type
          required: false
          type: string
        - description: Grass account id
          in: query
          name: account_id
          pattern: ^\d+$
          required: false
          type: string
        - in: body
          schema:
            type: object
            properties:
              actions:
                type: array
                items:
                  $ref: '#/definitions/PostActionPayload'
      responses:
        200:
          description: 200 OK
          examples:
            application/json: {'number of rows created': 2}
        400:
          description: Bad request

definitions:
  PostActionPayload:
    type: object
    properties:
      required:
        - territory_standard
        - conflicting_owner
        - conflict_date
        - isrc
      territory_standard:
        type: string
      conflicting_owner:
        type: string
      conflict_date:
        type: string
      isrc:
        type: string
      release_action:
        type: object
        $ref: '#/definitions/ActionItem'
      assert_action:
        type: object
        $ref: '#/definitions/ActionItem'
  ActionItem:
    properties:
      conflict_ids:
        description: List of conflict_ids to resolve, maps to fact_conflict table PKs
        type: array
        items:
          type: integer
      reason:
        description: Reason to resolve conflicts
        type: string
      additional_information:
        description: Additional information
        type: string
    required:
      - conflict_ids
      - reason
    type: object
