components:
  schemas:
    AbacusEvent:
      additionalProperties: false
      properties:
        abacus_event_id:
          minimum: 0
          type: integer
        created_by:
          minLength: 1
          type: string
        event_date:
          format: null
          pattern: null
          type: string
        event_name:
          minLength: 1
          type: string
        previous_abacus_event_id:
          minimum: 0
          nullable: true
          type: integer
        rolled_back_at:
          format: null
          nullable: true
          pattern: null
          type: string
        statement_period_id:
          minimum: 0
          type: integer
        target_id:
          minimum: 0
          type: integer
        target_type:
          minLength: 1
          type: string
      required:
      - abacus_event_id
      - created_by
      - event_name
      - target_id
      - target_type
      type: object
    AbacusEventByTargetResponse:
      additionalProperties: false
      properties:
        abacus_event_id:
          minimum: 0
          type: integer
        event_name:
          minLength: 1
          type: string
        statement_period_id:
          minimum: 0
          type: integer
      type: object
    AbacusEventDetail:
      allOf:
      - $ref: '#/components/schemas/AbacusEventPost'
      - example:
          abacus_event_id: 10
          created_by: '12345'
          previous_abacus_event_id: 5
          rolled_back_at: 2020-02-02 02:20:02+0000
        properties:
          abacus_event_id:
            description: abacus event identifier
            type: integer
          created_by:
            description: identity id of user
            type: string
          previous_abacus_event_id:
            description: abacus event identifier related to the current one
            type: integer
          rolled_back_at:
            description: datetime when the event was rolled back
            type: string
        type: object
    AbacusEventIdsPostBody:
      example:
      - 1
      - 2
      - 3
      - 4
      items:
        description: Event ids list
        type: integer
      title: Abacus event ID's POST request body
      type: array
    AbacusEventPaymentApprovalCount:
      additionalProperties: false
      properties:
        approval_count:
          minimum: 0
          type: integer
        payment_group_payment_id:
          minimum: 0
          type: integer
      required:
      - approval_count
      - payment_group_payment_id
      type: object
    AbacusEventRollbackRequest:
      additionalProperties: false
      properties:
        event_name:
          minLength: 1
          type: string
        target_id:
          minimum: 0
          type: integer
        target_type:
          minLength: 1
          type: string
      required:
      - event_name
      - target_id
      - target_type
      type: object
    AbacusEventRetryRequest:
      additionalProperties: false
      properties:
        event_name:
          minLength: 1
          type: string
        target_id:
          minimum: 0
          type: integer
        target_type:
          minLength: 1
          type: string
      required:
        - event_name
        - target_id
        - target_type
      type: object
    DataloaderParamsPost:
      additionalProperties: false
      properties:
        ids:
          items:
            minimum: 0
            type: integer
          type: array
      required:
      - ids
      type: object
info:
  title: ows-abacus-event API Specifications
  version: 1.0.0
openapi: 3.0.0
paths:
  /abacus-event:
    post:
      description: Create abacus event
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AbacusEventPost'
        required: false
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AbacusEvent'
          description: Created
      tags:
      - abacus event
  /abacus-event/dataloader:
    post:
      description: Dataload events by event ids
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DataloaderParamsPost'
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/AbacusEvent'
                type: array
          description: OK
      tags:
      - abacus event
  /abacus-event/payment-group-payment/{payment_group_payment_id}/approval-count/:
    get:
      description: Get the number of current approval events for a Payment Group Payment.
      parameters:
      - in: path
        name: payment_group_payment_id
        required: true
        schema:
          format: int32
          type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AbacusEventPaymentApprovalCount'
          description: OK
      tags:
      - abacus event
      - payment group
  /abacus-event/rollback/:
    put:
      description: Update datetime when event is rollback.
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AbacusEventRollbackRequest'
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AbacusEvent'
          description: OK
      tags:
      - abacus event
      - rollback
  /abacus-event/retry/:
    put:
      description: Retry abacus event (for allowed events).
      parameters: [ ]
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AbacusEventRetryRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AbacusEvent'
          description: OK
      tags:
        - abacus event
        - retry
  /abacus-event/{object_id}:
    get:
      description: Get abacus-event by id
      parameters:
      - in: path
        name: object_id
        required: true
        schema:
          format: int32
          type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AbacusEvent'
          description: OK
      tags:
      - abacus event
  /abacus-event/{target_type}/{target_id}:
    get:
      description: Get all event records for a specified target_type and target_id
      parameters:
      - in: path
        name: target_id
        required: true
        schema:
          format: int32
          type: integer
      - in: path
        name: target_type
        required: true
        schema:
          type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/AbacusEventByTargetResponse'
                type: array
          description: OK
      tags:
      - abacus event
  /hello/:
    get:
      responses:
        '200':
          description: 200 OK
      summary: Check the health of the application.
servers:
  - description: QA server
    url: https://qa-ows-abacus-event.theorchard.io

