---
openapi: 3.0.1
info:
  title: Connect a voice API
  version: v1
paths:
  "/api/v1/login":
    post:
      summary: Retrieve Token
      tags:
      - Authorization
      parameters: []
      responses:
        '201':
          description: API token created
          content: {}
        '401':
          description: Unauthorized
          content: {}
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                api_password:
                  type: string
              required:
              - email
              - api_password
  "/api/v1/consumers":
    get:
      summary: Retrieve all active consumers
      tags:
      - Consumer
      security:
      - BearerAuth: []
      responses:
        '200':
          description: Consumers found
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  first_name:
                    type: string
                  last_name:
                    type: string
                  middle_name:
                    type: string
                  team_id:
                    type: integer
                  created_at:
                    type: string
                  deactivated_on:
                    type: string
  "/api/v1/all_consumers":
    get:
      summary: Retrieve all consumers
      tags:
      - Consumer
      security:
      - BearerAuth: []
      responses:
        '200':
          description: Consumers found
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  first_name:
                    type: string
                  last_name:
                    type: string
                  middle_name:
                    type: string
                  team_id:
                    type: integer
                  created_at:
                    type: string
                  deactivated_on:
                    type: string
                  consumer_status:
                    type: string
  "/api/v1/all_staff_members":
    get:
      summary: Retrieve all staff members
      tags:
      - StaffMember
      security:
      - BearerAuth: []
      responses:
        '200':
          description: Staff members found
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  user_id:
                    type: integer
                  team_id:
                    type: integer
                  first_name:
                    type: string
                  last_name:
                    type: string
                  phone:
                    type: string
                  created_at:
                    type: string
                  updated_at:
                    type: string
                  middle_name:
                    type: string
                  employee_number:
                    type: integer
                  deactivated_on:
                    type: string
                  has_santana_errors:
                    type: boolean
                  email:
                    type: string
                  consumers:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        name:
                          type: string
                        deactivated_on:
                          type: string
                        team_id:
                          type: integer
  "/api/v1/staff_members":
    get:
      summary: Retrieve all active staff members
      tags:
      - StaffMember
      security:
      - BearerAuth: []
      responses:
        '200':
          description: Staff members found
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  user_id:
                    type: integer
                  team_id:
                    type: integer
                  first_name:
                    type: string
                  last_name:
                    type: string
                  phone:
                    type: string
                  created_at:
                    type: string
                  updated_at:
                    type: string
                  middle_name:
                    type: string
                  employee_number:
                    type: integer
                  deactivated_on:
                    type: string
                  has_santana_errors:
                    type: boolean
                  email:
                    type: string
                  consumers:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        name:
                          type: string
                        deactivated_on:
                          type: string
                        team_id:
                          type: integer
    post:
      summary: Create staff member
      tags:
      - StaffMember
      security:
      - BearerAuth: []
      parameters: []
      responses:
        '201':
          description: Staff member created
          content: {}
        '422':
          description: Email address is invalid or duplicated
          content: {}
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                first_name:
                  type: string
                last_name:
                  type: string
                phone:
                  type: string
                middle_name:
                  type: string
                employee_number:
                  type: string
                ssn:
                  type: string
                email:
                  type: string
                team_id:
                  type: integer
                consumer_ids:
                  type: array
                  items:
                    type: integer
              required:
              - first_name
              - last_name
              - employee_number
              - email
              - team_id
  "/api/v1/staff_members/{id}":
    put:
      summary: Update staff member
      tags:
      - StaffMember
      security:
      - BearerAuth: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        '202':
          description: Staff member updated
          content: {}
        '404':
          description: Staff member not found
          content: {}
        '403':
          description: Staff member is deactivated
          content: {}
        '422':
          description: Staff member not updated
          content: {}
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                first_name:
                  type: string
                last_name:
                  type: string
                phone:
                  type: string
                middle_name:
                  type: string
                employee_number:
                  type: string
                ssn:
                  type: string
                email:
                  type: string
                team_id:
                  type: integer
                consumer_ids:
                  type: array
                  items:
                    type: integer
    get:
      summary: Retrieve staff member
      tags:
      - StaffMember
      security:
      - BearerAuth: []
      parameters:
      - in: path
        name: id
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Staff member found
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  user_id:
                    type: integer
                  team_id:
                    type: integer
                  first_name:
                    type: string
                  last_name:
                    type: string
                  phone:
                    type: string
                  created_at:
                    type: string
                  updated_at:
                    type: string
                  middle_name:
                    type: string
                  employee_number:
                    type: integer
                  deactivated_on:
                    type: string
                  has_santana_errors:
                    type: boolean
                  email:
                    type: string
                  consumers:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        name:
                          type: string
                        deactivated_on:
                          type: string
                        team_id:
                          type: integer
        '404':
          description: Staff member not found
          content: {}
  "/api/v1/staff_members/deactivate/{id}":
    put:
      summary: Deactivate staff member
      tags:
      - StaffMember
      security:
      - BearerAuth: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: date
        in: query
        required: true
        schema:
          type: string
          example: yy-mm-dd
      responses:
        '202':
          description: Staff member deactivated
          content: {}
        '404':
          description: Staff member not found
          content: {}
        '403':
          description: Staff member is already inactive
          content: {}
        '422':
          description: Staff member not deactivated
          content: {}
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                date:
                  type: string
                  example: '2021-09-13'
  "/api/v1/staff_members/activate/{id}":
    put:
      summary: Activate staff member
      tags:
      - StaffMember
      security:
      - BearerAuth: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        '202':
          description: Staff member activated
          content: {}
        '404':
          description: Staff member not found
          content: {}
        '403':
          description: Staff member is already active
          content: {}
        '422':
          description: Staff member not activated
          content: {}
servers:
- url: http://localhost:3000
  description: Development server
- url: https://stage.api.connectavoice.com
  description: Staging server
- url: https://api.connectavoice.com
  description: Production server
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
