openapi: 3.1.0
info:
  title: Disposition API
  version: 1.0.0
servers:
  - url: https://usjobs-dev.jobs2careers.com:7011
    description: Development server
  - url: https://api.stage.talroo.com
    description: Staging server
  - url: https://api.talroo.com
    description: Production server
paths:
  /disposition/v1/events:
    post:
      summary: Post disposition events
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/PostEventRequest'
                - $ref: '#/components/schemas/PostEventsRequest'
            examples:
              Single Event:
                $ref: '#/components/examples/SingleEventRequest'
              Multiple Events:
                $ref: '#/components/examples/MultipleEventsRequest'
      responses:
        '200':
          description: Events accepted
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/PostEventResponse'
                  - $ref: '#/components/schemas/PostEventsResponse'
              examples:
                Single Event:
                  value:
                    success: true
                Multiple Events:
                  value:
                    num_succeeded_events: 10
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/FailedPostEventResponse'
                  - $ref: '#/components/schemas/FailedPostEventsResponse'
              examples:
                Single Event:
                  $ref: '#/components/examples/SingleEventFailedResponse'
                Multiple Events:
                  $ref: '#/components/examples/MultipleEventsFailedResponse'
        '500':
          description: Internal server error
components:
  examples:
    SingleEventRequest:
      value:
        tlr_sid: 9dc3d611-e014-4ddb-a87f-d36e3e10a813
        event: application_completed
        raw_event: new application
        event_time: '2024-02-25T12:56:33Z'
    MultipleEventsRequest:
      value: &ref_0
        - tlr_sid: 9dc3d611-e014-4ddb-a87f-d36e3e10a813
          event: application_completed
          raw_event: new application
          event_time: '2024-02-25T12:56:33Z'
        - tlr_application_id: ba0fbcff-1488-11f0-9d88-121fb3094105
          event: rejected
          reason: uncertified
          meta_data:
            detail_reason: Candidate did not have the required certification
          event_time: '2024-03-21T19:23:00-05:00'
    SingleEventFailedResponse:
      value:
        message: Validation failed
        tlr_sid: 9dc3d611-e014-4ddb-a87f-d36e3e10a813
        errors:
          - message: This value should not be null.
            field: event
            value: null
    MultipleEventsFailedResponse:
      value: &ref_1
        num_succeeded_events: 8
        failed_events:
          - message: Validation failed
            tlr_sid: 9dc3d611-e014-4ddb-a87f-d36e3e10a813
            errors:
              - message: This value should not be null.
                field: event
                value: null
          - message: Invalid input
            tlr_application_id: ba0fbcff-1488-11f0-9d88-121fb3094105
            errors:
              - message: This value is not a valid datetime
                field: event_time
                value: 03/21/2024 19:23:00-05:00
  schemas:
    PostEventRequest:
      $ref: '#/components/schemas/Event'
      example:
        $ref: '#/components/examples/SingleEventRequest'
    PostEventsRequest:
      type: array
      items:
        $ref: '#/components/schemas/Event'
      example:
        value: *ref_0
    PostEventResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
    PostEventsResponse:
      type: object
      properties:
        num_succeeded_events:
          type: int32
          example: 10
    FailedPostEventResponse:
      $ref: '#/components/schemas/FailedEvent'
      example:
        $ref: '#/components/examples/SingleEventFailedResponse'
    FailedPostEventsResponse:
      allOf:
        - $ref: '#/components/schemas/PostEventsResponse'
        - type: object
          properties:
            failed_events:
              type: array
              items:
                $ref: '#/components/schemas/FailedEvent'
          example:
            value: *ref_1
    Event:
      type: object
      properties:
        tlr_sid:
          type: string
          minLength: 36
          maxLength: 36
          format: uuid
        tlr_application_id:
          type: string
          minLength: 36
          maxLength: 36
        event:
          type: string
          enum:
            - registration
            - lead
            - application_started
            - application_completed
            - application_qualified
            - application_unqualified
            - application_withdrawn
            - contacted
            - screening
            - assessment
            - interview_scheduled
            - interviewed
            - background_check
            - offered
            - offer_declined
            - hired
            - rejected
            - onboarded
            - other
        reason:
          type: string
          enum:
            - failed_checks
            - unresponsive
            - uncertified
            - out_of_area
            - job_closed
            - hired_different_role
            - other
        raw_event:
          type: string
          maxLength: 128
        meta_data:
          type: object
        event_time:
          type: string
          format: date-time
      required:
        - tlr_sid
        - tlr_application_id
        - event
        - event_time
    FailedEvent:
      type: object
      properties:
        message:
          type: string
        tlr_sid:
          type: string
        tlr_application_id:
          type: string
        errors:
          type: array
          items:
            $ref: '#/components/schemas/EventError'
    EventError:
      type: object
      properties:
        message:
          type: string
        field:
          type: string
        value:
          type: string
