openapi: 3.0.0
info:
  title: Leads LG
  version: 1.0.0
  description: This API was developed to get LG leads

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: string
  schemas:
    Lead:
      type: object
      required:
        - id
        - name
        - email
        - phone
        - created_at
        - updated_at
      properties:
        id:
          type: uuid
          description: The auto-generated id of the lead
        name:
          type: string
          description: The name of the lead
        email:
          type: string
          description: The email of the lead
        phone:
          type: string
          description: The phone of the lead
        created_at:
          type: date
          description: The created date lead
        updated_at:
          type: date
          description: The lats updated date lead
      example:
        id: fa9fb2f0-4d3d-48a3-bd79-a9750bcc8d10
        name: 'John Doe'
        email: 'johndoe@email.com'
        phone: '11999009900'
        created_at: 2024-02-03T06:38:34.000Z 
        updated_at: 2024-04-03T09:28:04.000Z 
    LeadDetails:
      type: object
      required:
        - lead_id
        - name
        - email
        - phone
        - created_at
        - updated_at
        - origin
      properties:
        lead_id:
          type: uuid
          description: The auto-generated id of the lead
        name:
          type: string
          description: The name of the lead
        email:
          type: string
          description: The email of the lead
        phone:
          type: string
          description: The phone of the lead
        created_at:
          type: date
          description: The created date lead
        updated_at:
          type: date
          description: The lats updated date lead
        origin:
          type: object
          description: The info of origin for the lead
          properties:
            name: 
              type: string
              description: The origin name
            origin_id: 
              type: string
              description: The origin id
            origin_status: 
              type: enum
              enum: 
                - ACTIVE
                - DISABLED
              description: The origin status
            origin_type: 
              type: enum
              enum: 
                - KIOSK
                - TRUCK
              description: The origin type

      example:
        lead_id: fa9fb2f0-4d3d-48a3-bd79-a9750bcc8d10
        name: 'John Doe'
        email: 'johndoe@email.com'
        phone: '11999009900'
        created_at: 2024-02-03T06:38:34.000Z 
        updated_at: 2024-04-03T09:28:04.000Z 
        origin:
          name: 'Test e2e'
          origin_id: '21cc51a9-4927-4493-9427-8e96b3a7fef1'
    Origin:
      type: object
      required:
        - id
        - name
        - created_at
        - updated_at
      properties:
        id:
          type: uuid
          description: The auto-generated id of the origin
        name:
          type: string
          description: The name of the orgin
        status:
          type: enum
          enum: 
            - ACTIVE
            - DISABLED
          description: The status of the orgin
        type:
          type: enum
          enum: 
            - KIOSK
            - TRUCK
          description: The type of the orgin
        created_at:
          type: date
          description: The created date origin
        updated_at:
          type: date
          description: The lats updated date origin
      example:
        id: fa9fb2f0-4d3d-48a3-bd79-a9750bcc8d10
        name: 'Stand'
        status: 'ACTIVE'
        type: 'KIOSK'
        created_at: 2024-02-03T06:38:34.000Z 
        updated_at: 2024-04-03T09:28:04.000Z 

tags:
  name: Lead
  name: Origin

paths:
  /leads:
    post:
      summary: Create a Lead
      tags:
        - Lead
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                email:
                  type: string
                phone:
                  type: string
                originName:
                  type: string
              example:
                name: 'John Doe'
                email: 'johndoe@email.com'
                phone: '11999009900'
                originName: 'Test e2e'
      responses:
        201:
          description: Lead Created
        409:
          description: Conflict
        400:
          description: Bad request
  /leads/list:
    get:
      summary: Get the list of all leads
      security:
        - bearerAuth: []
      tags:
        - Lead
      parameters:
        - in: query
          name: orderType
          schema:
            type: enum
            enum: 
              - ASC
              - DESC
          required: false
        - in: query
          name: orderBy
          schema:
            type: enum
            enum:
              - NAME
              - EMAIL 
              - PHONE 
              - CREATEDAT
          required: false
        - in: query
          name: page
          schema:
            type: number
          required: false
        - in: query
          name: limit
          schema:
            type: number
          required: false
      responses:
        200:
          description: The list of all leads
          content:
            application/json:
              schema:
                type: object
                properties:
                  leads:
                    type: array
                    items:
                      $ref: '#/components/schemas/LeadDetails'
                  previous_page:
                    type: number
                    example: 1
                  current_page:
                    type: number
                    example: 2
                  next_page:
                    type: number
                    example: 3
                  last_page:
                    type: number
                    example: 4
                  total:
                    type: number
                    example: 20
                  per_page:
                    type: number
                    example: 100
                  from:
                    type: number
                    example: 1
                  to:
                    type: number
                    example: 100
        400:
          description: Bad request
  /leads/filter:
    get:
      summary: Get the list of all leads based on filter parameters
      security:
        - bearerAuth: []
      tags:
        - Lead
      parameters:
        - in: query
          name: name
          schema:
            type: string
          required: false
        - in: query
          name: email
          schema:
            type: string
          required: false
        - in: query
          name: phone
          schema:
            type: string
          required: false
        - in: query
          name: originName
          schema:
            type: string
          required: false
        - in: query
          name: orderType
          schema:
            type: enum
            enum: 
              - ASC
              - DESC
          required: false
        - in: query
          name: orderBy
          schema:
            type: enum
            enum:
              - NAME
              - EMAIL 
              - PHONE 
              - CREATEDAT
              - ORIGINNAME
              - ORIGINTYPE
              - ORIGINSTATUS
          required: false
        - in: query
          name: originStatus
          schema:
            type: enum
            enum:
              - ACTIVE
              - DISABLED
          required: false
        - in: query
          name: originType
          schema:
            type: enum
            enum:
              - KIOSK
              - TRUCK
          required: false
        - in: query
          name: page
          schema:
            type: number
          required: false
        - in: query
          name: limit
          schema:
            type: number
          required: false
      responses:
        200:
          description: The list of all leads based on parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  leads:
                    type: array
                    items:
                      $ref: '#/components/schemas/LeadDetails'
                  previous_page:
                    type: number
                    example: 1
                  current_page:
                    type: number
                    example: 2
                  next_page:
                    type: number
                    example: 3
                  last_page:
                    type: number
                    example: 4
                  total:
                    type: number
                    example: 20
                  per_page:
                    type: number
                    example: 100
                  from:
                    type: number
                    example: 1
                  to:
                    type: number
                    example: 100
        400:
          description: Bad request
  /leads/origin/list:
    get:
      summary: Get the list of all leads based on origin name parameter
      security:
        - bearerAuth: []
      tags:
        - Lead
      parameters:
        - in: query
          name: originName
          schema:
            type: string
          required: true
        - in: query
          name: orderType
          schema:
            type: enum
            enum: 
              - ASC
              - DESC
          required: false
        - in: query
          name: orderBy
          schema:
            type: enum
            enum:
              - NAME
              - EMAIL 
              - PHONE 
              - CREATEDAT
          required: false
        - in: query
          name: page
          schema:
            type: number
          required: false
        - in: query
          name: limit
          schema:
            type: number
          required: false
      responses:
        200:
          description: The list of all leads based on origin name parameter
          content:
            application/json:
              schema:
                type: object
                properties:
                  leads:
                    type: array
                    items:
                      $ref: '#/components/schemas/LeadDetails'
                  previous_page:
                    type: number
                    example: 1
                  current_page:
                    type: number
                    example: 2
                  next_page:
                    type: number
                    example: 3
                  last_page:
                    type: number
                    example: 4
                  total:
                    type: number
                    example: 20
                  per_page:
                    type: number
                    example: 100
                  from:
                    type: number
                    example: 1
                  to:
                    type: number
                    example: 100
        400:
          description: Bad request
  /origins:
    post:
      summary: Create a Origin
      tags:
        - Origin
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                status:
                  type: enum
                  enum:
                    - ACTIVE
                    - DISABLED
                type:
                  type: enum
                  enum:
                    - KIOSK
                    - TRUCK
              example:
                name: 'Stand'
                status: ACTIVE
                type: KIOSK
      responses:
        201:
          description: Lead Created
        409:
          description: Conflict
        400:
          description: Bad request
    delete: 
      summary: Delete a Origin
      tags:
        - Origin
      security:
        - bearerAuth: []
      parameters:
        - in: query
          name: originName
          schema:
            type: string
          required: true
      responses:
        204:
          description: Lead Created
        400:
          description: Bad request
  /origins/list:
    get:
      summary: Get the list of all origins
      security:
        - bearerAuth: []
      tags:
        - Origin
      parameters:
        - in: query
          name: name
          schema:
            type: string
          required: false
        - in: query
          name: orderType
          schema:
            type: enum
            enum: 
              - ASC
              - DESC
          required: false
        - in: query
          name: orderBy
          schema:
            type: enum
            enum:
              - NAME
              - CREATEDAT
              - STATUS
              - TYPE
          required: false
        - in: query
          name: status
          schema:
            type: enum
            enum:
              - ACTIVE
              - DISABLED
          required: false
        - in: query
          name: type
          schema:
            type: enum
            enum:
              - KIOSK
              - TRUCK
          required: false
        - in: query
          name: page
          schema:
            type: number
          required: false
        - in: query
          name: limit
          schema:
            type: number
          required: false
      responses:
        200:
          description: The list of all origins
          content:
            application/json:
              schema:
                type: object
                properties:
                  origins:
                    type: array
                    items:
                      $ref: '#/components/schemas/Origin'
                  previous_page:
                    type: number
                    example: 1
                  current_page:
                    type: number
                    example: 2
                  next_page:
                    type: number
                    example: 3
                  last_page:
                    type: number
                    example: 4
                  total:
                    type: number
                    example: 20
                  per_page:
                    type: number
                    example: 100
                  from:
                    type: number
                    example: 1
                  to:
                    type: number
                    example: 100
        400:
          description: Bad request
  /origins/change-status/{originId}:
    patch:
      summary: Change the origin status
      security:
        - bearerAuth: []
      tags:
        - Origin
      parameters:
        - in: path
          name: originId
          schema:
            type: string
          required: true
      responses:
        204:
          description: The origin status has been changed
        400:
          description: Bad request
