openapi: 3.0.3
info:
  title: Contacts API
  description: This API provides methods to manage dealer contacts information.
  version: 1.32.8
servers:
  - url: 'https://dealers.masstack.com/v1'
    description: Production server (public)
  - url: 'https://dealers.sta.masstack.com/v1'
    description: Staging server (public)
  - url: 'https://mas-dealers.private.dev.k8s.masmovil.com/masdealers'
    description: Develop server (private)
tags:
  - name: dealer
    description: Contain all the operations related to dealers.
  - name: fiscal data
    description: Contain all the operations related to fiscal data.
  - name: custom information
    description: Contain all the operations related to custom information.
  - name: request
    description: Contain all the operations related to request management.
  - name: campaign
    description: Contain all the operations related to campaigns.
  - name: subchannel
    description: Contain all the operations related to subchannel.
  - name: store
    description: Contain all the operations related to stores.
  - name: Requests
    description: >-
      Contain all the operations related to requests. The objective is to keep a
      record of the requests that are made to third parties for the creation of
      dealers with their corresponding permissions.
paths:
  /contacts:
    get:
      summary: Get contacts
      description: This service returns all contacts. Always return empty dealers.
      responses:
        '200':
          description: Successful response. Contacts have been found.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ContactResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Dealer not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: NOT_FOUND
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
    post:
      summary: Create contact
      description: This service returns all contacts.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContactRequest'
      responses:
        '200':
          description: Successful response. Contact has been created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Dealer not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
                errors:
                  - code: NOT_FOUND
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
  '/contacts/{contactId}':
    get:
      summary: Get information from received contact.
      description: This service receives contactId and returns contact detail.
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response. Contact has been found.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ContactResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
    patch:
      summary: Partial update from contactId.
      description: >-
        This service receives contactId and body with fields to update. The
        fields that are specified will be overwritten. In the case of the fields
        of purposes and distributors, they require a list of IDs. If they are
        empty, they will overwrite the previous empty.
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContactRequest'
      responses:
        '200':
          description: Successful response. Contact has been updated.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ContactResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: BAD_REQUEST
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Dealer not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
                errors:
                  - code: NOT_FOUND
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
    delete:
      summary: Delete from contactId.
      description: This service receives contactId to delete.
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: Successful response. Contact has been deleted.
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: BAD_REQUEST
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Dealer not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: NOT_FOUND
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
  '/contacts/{contactId}/dealers/{dealerId}':
    delete:
      summary: Delete a dealer's contact
      description: >-
        This service receives dealerId and contactId and delete this
        relationship.
      parameters:
        - name: contactId
          in: path
          required: true
          schema:
            type: integer
        - name: dealerId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: Successful response.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Dealer not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: NOT_FOUND
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
  /dealers/id:
    get:
      summary: Get dealer identifier
      description: >-
        This service receives external system code and dealer code in that
        system and returns dealerId asociated to mas-dealers.
      tags:
        - dealer
      parameters:
        - name: system
          in: query
          required: true
          schema:
            type: string
        - name: code
          in: query
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response. Dealer has been found.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DealerAccessResponse'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  '/dealers/{dealer_id}':
    get:
      summary: Get information from received dealer and hierarchy up.
      description: >-
        This service receives dealerId and returns dealer detail and the
        hierarchy up.
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: >-
            Successful response. Dealer has been found and the hierarchy up is
            returned.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DealerInHierarchyResponse'
        '401':
          $ref: '#/components/responses/Unauthorized1'
    patch:
      summary: Partial update from dealerId.
      description: This service receives dealerId and body with fields to update.
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              properties:
                code:
                  type: string
                commercialName:
                  type: string
                level:
                  type: integer
                status:
                  type: string
                parentCode:
                  type: string
                subchannel:
                  type: string
                commissioningSection:
                  type: string
                storeType:
                  type: string
                address:
                  type: string
                city:
                  type: string
                province:
                  type: string
                postalCode:
                  type: string
                country:
                  type: string
                startDate:
                  type: string
                  format: date-time
                endDate:
                  type: string
                  format: date-time
                internalManagerId:
                  type: integer
                externalManagerId:
                  type: integer
                fiscalDataId:
                  type: integer
                storeDelivery:
                  type: boolean
                  default: false
                deviceReturn:
                  type: boolean
                  default: false
      responses:
        '200':
          description: Successful response. Dealer has been updated.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      summary: Set a dealer as cancelled or inactive
      description: >-
        This service receives the id of a dealer and a cancellation status
        (cancelled or inactive), and sets it as the dealer's status, setting as
        well the end date for itself and all his brands. This operation is also
        performed for all the hierarchy under the dealer.
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
        - name: cancellationStatus
          in: query
          required: true
          schema:
            type: string
            enum:
              - CANC
              - INAC
        - name: cancellationDate
          in: query
          required: false
          schema:
            type: string
      responses:
        '201':
          description: Successful response. Everything has been removed.
          content:
            application/json:
              schema:
                type: string
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  /dealers:
    get:
      summary: Get information from received dealers and hierarchy up.
      description: >-
        This service receives multiple dealerId (ids) and returns dealer details
        and the hierarchy up.
      tags:
        - dealer
      parameters:
        - name: ids
          in: query
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DealerHierarchyResponse'
        '401':
          $ref: '#/components/responses/Unauthorized1'
    post:
      summary: Create a new dealer and hierarchy up.
      description: .
      tags:
        - dealer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DealerRequest'
        required: true
      responses:
        '201':
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DealerResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
  /dealers/accounting-system:
    post:
      summary: Create a new accounting-system information of a dealer
      description: >-
        This operation creates a dealer's accounting-system with the information
        received.
      tags:
        - dealer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DealerAccountingSystemPostRequest'
        required: true
      responses:
        '204':
          description: Successful response.
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  '/dealers/accounting-system/{dealer_accounting_system_id}':
    delete:
      summary: Delete accounting-system information of a dealer
      description: This service receives a dealer accounting system id and deletes it.
      tags:
        - dealer
      parameters:
        - name: dealerAccSysId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: Successful response.
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  '/dealers/{dealer_id}/accounting-system':
    get:
      summary: Get accounting system information from specified dealer
      description: >-
        This service receive a dealer Id and returns the accounting system
        information
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DealerAccountingSystemResponseList'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
    patch:
      summary: Updates the accounting-system information of a dealer
      description: >-
        This operation updates the dealer's accounting-system with the
        information received.
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DealerAccountingSystemRequest'
        required: true
      responses:
        '204':
          description: Successful response.
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  '/dealers/full-info/{dealer_id}':
    get:
      summary: Get full information from specified dealer.
      description: This service receives a dealer Id and returns its generic info.
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DealerFullInfoResponse'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  /dealers/simple-list:
    get:
      summary: Retrieve the list of dealers by the filter indicated.
      description: >-
        This operation only returns the information necessary to identify each
        dealer in the list, to know who his parent is and to which sub-channel
        he belongs. This operation does not provide the detail of a dealer. A
        search filter can be defined in this operation. If the filter is not
        defined, it returns the last 100 updated or modified dealers sorted by
        date.
      tags:
        - dealer
      parameters:
        - name: name
          description: >-
            Filters code, commercialName, dealerCode(dealerAccountingSystem),
            postalCode, province, documentNumber or companyName.
          in: query
          required: false
          schema:
            type: string
        - name: validAt
          description: Filters by valid at the specified date
          in: query
          required: false
          schema:
            type: string
            example: '2020-11-02T00:00:00%2B01:00'
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DealerSimpleListResponse'
        '401':
          $ref: '#/components/responses/Unauthorized1'
  '/dealers/{dealer_id}/contacts':
    get:
      summary: Get list of the contacts of dealer.
      description: >-
        This service receives dealerId and returns a contact list of that
        dealer.
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ContactResponse1'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  '/dealers/{dealer_id}/contacts/{contact_id}':
    delete:
      summary: Delete a dealer's contact
      description: >-
        This service receives dealerId and contactId and delete this
        relationship.
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
        - name: contact_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: Successful response.
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  /dealers/contacts:
    post:
      summary: Create a dealer's contact
      description: >-
        This service receives dealerId and contactId and create this
        relationship.
      tags:
        - dealer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DealerContact'
        required: true
      responses:
        '201':
          description: Successful response.
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  /fiscal-data:
    post:
      summary: Create a new fiscal data
      description: This operation create a new fiscal data from the input data.
      tags:
        - fiscal data
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FiscalDataPost'
        required: true
      responses:
        '201':
          description: Successful creation.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
    get:
      summary: Returns a list with the fiscall data in the system.
      description: This operation returns a list with all the fiscall data in the system.
      tags:
        - fiscal data
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/FiscalData'
        '204':
          description: No content.
        '401':
          $ref: '#/components/responses/Unauthorized1'
  '/fiscal-data/{fiscal_data_id}':
    get:
      summary: Retrieves the detail of a fiscal data.
      description: Retrieves the detail of a fiscal data for a given id.
      tags:
        - fiscal data
      parameters:
        - name: fiscal_data_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FiscalDataDetail'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
    patch:
      summary: Updates the information of a fiscal data
      description: This operation updates the fiscal data with the information received.
      tags:
        - fiscal data
      parameters:
        - name: fiscal_data_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FiscalDataPatch'
        required: true
      responses:
        '204':
          description: Successful response.
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      summary: Deletes a fiscal data.
      description: >-
        This operation deletes a fiscal data for a given id and also delete the
        relationship with its associated dealers.
      tags:
        - fiscal data
      parameters:
        - name: fiscal_data_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: Successful delete. Not content.
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  '/dealers/{dealer_id}/migration':
    post:
      summary: Migrate a dealer.
      description: Migrate a dealer
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DealerMigrationRequest'
        required: true
      responses:
        '201':
          description: Successful migration.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DealerMigrationResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '500':
          $ref: '#/components/responses/InternalServerError'
    get:
      summary: Check whether a dealer is migratable.
      description: Check whether a dealer is migratable
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: The dealer is valid for migration.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '500':
          $ref: '#/components/responses/InternalServerError'
  '/dealers/{dealer_id}/custom-information':
    get:
      summary: Get custom information from received dealer.
      description: This service receives dealerId and returns dealer custom information.
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: >-
            Successful response. Dealer has been found and the hierarchy up is
            returned.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DealerCustomInfoResponse'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  /dealers/custom-information:
    post:
      summary: Create a new custom information from received dealer.
      description: .
      tags:
        - dealer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DealerCustomInfoRequest'
        required: true
      responses:
        '201':
          description: Successful response.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
  '/dealers/{dealer_id}/custom-information/{custom_info_id}':
    patch:
      summary: Update custom information from received dealer and customInfo.
      description: This service receives dealerId and body with fields to update.
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
        - name: custom_info_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              properties:
                fieldValue:
                  type: string
      responses:
        '200':
          description: Successful response. Dealer has been updated.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      summary: Delete custom information from received dealer.
      description: .
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
        - name: custom_info_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: Successful response. Everything has been removed.
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  /custom-information:
    get:
      summary: Get custom information.
      description: This service returns custom information.
      tags:
        - custom information
      responses:
        '200':
          description: Successful response. Custom information has been found.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CustomInfoResponse'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      summary: Create a new custom information.
      description: .
      tags:
        - custom information
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomInfoRequest'
        required: true
      responses:
        '201':
          description: Successful response. Custom information has been created.
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/CustomInfoResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
  '/custom-information/{custom_info_id}':
    patch:
      summary: Update custom information from received customInfo.
      description: This service receives customInfoId and body with fields to update.
      tags:
        - custom information
      parameters:
        - name: custom_info_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomInfoRequest'
      responses:
        '200':
          description: Successful response. Custom information has been updated.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      summary: Delete custom information from received customInfo.
      description: .
      tags:
        - custom information
      parameters:
        - name: custom_info_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: Successful response. Everything has been removed.
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          description: Dealer not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: NOT_FOUND
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
  '/custom-information/{custom_info_id}/dealers':
    get:
      summary: Get dealers from customInfo.
      description: >-
        This service receives customInfoId and returns a list of dealers that
        use this custom information.
      tags:
        - custom information
      parameters:
        - name: custom_info_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DealerWithCustomFieldValueResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  '/dealers/{dealer_id}/children':
    get:
      summary: Children dealers.
      description: Obtain all children of a dealer.
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/FiscalDataAssociatedDealer'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '500':
          $ref: '#/components/responses/InternalServerError'
  '/dealers/{dealer_id}/block':
    post:
      summary: Block Dealer and offspring.
      description: Block dealer and offspring
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: No content.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '500':
          $ref: '#/components/responses/InternalServerError'
  '/dealers/{dealer_id}/change-status':
    post:
      summary: Change the status of a dealer
      description: >-
        This endpoint currently only makes status changes to 'Active'. That is,
        it is used to activate or reactivate a dealer.
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DealerChangeStatusRequest'
      responses:
        '200':
          description: No content.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /commercial-profiles:
    get:
      summary: Get list of commercial profiles for IAM.
      description: This service returns a list of commercial profiles.
      tags:
        - iam
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CommercialProfiles'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          description: Commercial profiles not found into config.yaml
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: NOT_FOUND
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
  /brands:
    get:
      summary: Get all the brands
      description: This service returns a list of all the brands
      tags:
        - brand
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Brand'
        '401':
          $ref: '#/components/responses/Unauthorized1'
  '/dealers/{dealer_id}/brands':
    get:
      summary: Get the brands of a dealer_id
      description: This service returns a list of all the brands of a dealer
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DealerBrandResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
    patch:
      summary: Update the brands
      description: This service update a list of brands of a dealer
      tags:
        - dealer
      parameters:
        - name: dealer_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DealerBrandRequest'
      responses:
        '200':
          description: Successful response. Brand has been updated.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
  /accounting-system:
    get:
      summary: Get all the accounting systems
      description: This service returns a list of all the accounting systems
      tags:
        - brand
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AccountingSystem'
        '401':
          $ref: '#/components/responses/Unauthorized1'
  /campaigns:
    post:
      summary: Create a new campaign
      description: >-
        Create a new active campaign. Returns the created campaign. It can be
        associated with one or more subchannels, using the subchannel code.
      tags:
        - campaign
      parameters:
        - in: header
          name: x-retool-groups
          schema:
            type: string
            example: 'tester, campaignTester'
          required: false
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CampaignRequest'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Campaign'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '500':
          $ref: '#/components/responses/InternalServerError'
  '/campaigns/{campaign_id}':
    get:
      summary: Gets the campaign with its details.
      description: >-
        Obtains the indicated campaign, the associated subchannels and the list
        of conditions that said campaign has.
      tags:
        - campaign
      parameters:
        - name: campaign_id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Campaign'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalServerError'
    put:
      summary: Update a campaign.
      description: >-
        Update  campaign. It can be associated with one or more subchannels,
        using the subchannel code.
      tags:
        - campaign
      parameters:
        - in: header
          name: x-retool-groups
          schema:
            type: string
            example: 'tester, campaignTester'
          required: false
        - name: campaign_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CampaignRequest'
      responses:
        '204':
          description: No Content
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalServerError'
  '/campaigns/{campaign_id}/change-status':
    post:
      summary: Change campaign status
      description: >-
        Change the status of a campaign. If the campaign goes from active to
        inactive: all dealers associated with the campaign (if any) will no
        longer be associated, that is, the dealers would not have any associated
        campaign. Additionally, the business profile in the IAM is deleted.
      tags:
        - campaign
      parameters:
        - in: header
          name: x-retool-groups
          schema:
            type: string
            example: 'tester, campaignTester'
          required: false
        - name: campaign_id
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CampaignChangeStatusRequest'
      responses:
        '204':
          description: No content.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /campaigns/search:
    post:
      summary: Returns the list of campaigns that match with the filter provided
      description: Returns the list of campaigns that match with the filter provided.
      tags:
        - campaign
      parameters:
        - in: header
          name: x-retool-groups
          schema:
            type: string
            example: 'tester, campaignTester'
          required: false
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CampaignSearchRequest'
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Campaign'
        '204':
          description: No content.
        '401':
          $ref: '#/components/responses/Unauthorized1'
  /campaigns/users:
    get:
      summary: >-
        Returns the list of users (dealers with Agents account) that match with
        the filter provided.
      description: >-
        Returns the list of users (dealers with Agents account) matching the
        specified filter. If the campaignManager role is  specified in the
        'x-retool-groups' header, the users assigned to the manager itself or
        one of its descendants in the hierarchy will be returned.
      tags:
        - campaign
      parameters:
        - in: header
          name: x-retool-groups
          schema:
            type: string
            example: 'tester, campaignTester'
          required: false
        - name: users
          in: query
          required: false
          schema:
            type: string
            example: >-
              agent1@asesormasmovil.es,agent2@asesormasmovil.es,agent3@asesormasmovil.es
        - name: subchannel
          in: query
          required: false
          schema:
            type: string
        - name: campaign
          in: query
          schema:
            type: string
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CampaignUser'
        '204':
          description: No content.
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: BAD_REQUEST
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
        '401':
          $ref: '#/components/responses/Unauthorized1'
  /users/change-campaign:
    post:
      summary: modifies a dealer's campaign
      description: modifies a dealer's campaign
      tags:
        - campaign
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChangeCampaignRequest'
        required: true
      responses:
        '200':
          description: No content.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /subchannels:
    get:
      summary: Get list of subchannel
      description: >-
        Return the list of subchannel. If the 'x-retool-groups' header is
        received with the value campaignManager, the result is filtered. Only
        the subchannels of the dealers of said manager or his hierarchy are
        returned.
      tags:
        - subchannel
      parameters:
        - in: header
          name: x-retool-groups
          schema:
            type: string
            example: 'tester, campaignTester'
          required: false
      responses:
        '200':
          description: List of subchannel
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Subchannel'
        '204':
          description: No content.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /stores:
    get:
      summary: Get stores
      description: >-
        This service returns the N nearest stores to the postal code given as a
        parameter. The list can be filtered by the rest of the parameters.
      tags:
        - store
      parameters:
        - name: limit
          description: Maximum number of stores to be returned.
          in: query
          required: false
          schema:
            type: string
            default: 10
        - name: postalCode
          description: Postal code to obtain the N nearest stores.
          in: query
          required: true
          schema:
            type: string
        - name: storeDelivery
          description: Indicates that the shop must have a store delivery service.
          in: query
          required: false
          schema:
            type: boolean
            default: false
        - name: deviceReturn
          description: Indicates that the shop must have a device return service.
          in: query
          required: false
          schema:
            type: boolean
            default: false
        - name: subchannels
          description: >-
            List of subchannels to which the shops to be consulted should
            belong.
          in: query
          required: false
          example: 'MI,OU'
          schema:
            type: string
        - name: brands
          description: List of brands sold by the shops to be returned.
          in: query
          required: false
          example: 'yoigo,masmovil'
          schema:
            type: string
      responses:
        '200':
          description: Successful response. Stores has been found.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Store'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized1'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /managers:
    get:
      summary: Get managers
      description: >-
        This service returns all managers, regardless if it receives the filter
        by manager type.
      parameters:
        - name: type
          in: query
          description: filter by manager type
          schema:
            type: string
            enum:
              - INT
              - EXT
            description: INT -> Interno EXT -> Externo
      responses:
        '200':
          description: Successful response. Managers has been found.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ManagerResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /requests:
    post:
      summary: Create request
      description: Create a record of the requested request
      tags:
        - Request
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequestsRequest'
        required: true
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestCreatedResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: BAD_REQUEST
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: INTERNAL_SERVER_ERROR
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
  /requests/approve:
    post:
      summary: Approves and processes requests.
      description: >-
        Approves the given requests and includes the users in the groups
        indicated in the detail of each request. If the users do not exist, they
        will be created and if there is any incompatibility with the groups, the
        existing incompatible groups will be deleted and the user will be
        included in those indicated in the request.
      tags:
        - Request
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                type: integer
                example: '1234,123'
        required: true
      responses:
        '200':
          description: No content.
        '207':
          description: Some request couldn't be processed.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/RequestResponse'
                example:
                  id: 43
                  dealerId: 28
                  dealerCode: MDEA_TEST
                  platform: IAM
                  status: ERROR
                  userCreated: juan.nadie
                  comment: Invalid Bearer token
                  creationDate: '2023-06-19T21:31:26.272975+02:00'
                  requestDetails:
                    email: mdeatest15@asesormasmovil.es
                    orgUnit: /1.Otras/Energia
                    salesRole: pruebasmasdealers
                    commercialProfile:
                      - perfil_comercial.ecare
                    simReplacement: true
                    eSIMReplacement: false
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: BAD_REQUEST
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: INTERNAL_SERVER_ERROR
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
  '/requests/{requestId}':
    patch:
      summary: Update status request or comment request
      description: >-
        The only data that will be modified from the request entity will be
        status and comment, the other data if sent will be ignored.
      tags:
        - Request
      parameters:
        - name: requestId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequestModificationBody'
      responses:
        '200':
          description: Successful response.
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: BAD_REQUEST
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
              example:
                errors:
                  - code: INTERNAL_SERVER_ERROR
                    title: Error message
                    ref: some_ref
                    details: Detailed error message
components:
  schemas:
    ApiError:
      required:
        - code
        - details
        - ref
        - title
      type: object
      properties:
        code:
          type: string
          description: code of the error
        title:
          type: string
          description: title of the error
        ref:
          type: string
          description: ref of the error
        details:
          type: string
          description: details of the error
    ApiErrorResponse:
      type: object
      properties:
        restErrors:
          type: array
          items:
            $ref: '#/components/schemas/ApiError'
      description: API Error Response
    ContactRequest:
      description: Contact generic info simplified object.
      type: object
      properties:
        name:
          type: string
        email:
          type: string
          example: test@test.es
        phoneNumber:
          type: string
          example: '987654321'
        purposes:
          type: array
          items:
            $ref: '#/components/schemas/IntegerList'
        dealers:
          type: array
          items:
            $ref: '#/components/schemas/IntegerList'
    ContactResponse:
      description: Contact generic info simplified object.
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        email:
          type: string
          example: test@test.es
        phoneNumber:
          type: string
          example: '987654321'
        purposes:
          type: array
          items:
            $ref: '#/components/schemas/PurposeResponse'
        dealers:
          type: array
          items:
            $ref: '#/components/schemas/SimpleDealerResponse'
    IntegerList:
      type: object
      properties:
        id:
          type: integer
    PurposeResponse:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
    SimpleDealerResponse:
      type: object
      properties:
        id:
          type: integer
        code:
          type: string
        commercialName:
          type: string
        level:
          type: integer
        levelDescription:
          type: string
        status:
          type: string
        parentId:
          type: integer
        parentCode:
          type: string
        subchannelCode:
          type: string
        internalManagerFullName:
          type: string
        externalManagerFullName:
          type: string
        internalManagerCode:
          type: string
        externalManagerCode:
          type: string
        commissioningSection:
          type: string
        storeType:
          type: string
        address:
          type: string
        city:
          type: string
        province:
          type: string
        country:
          type: string
        postalCode:
          type: string
        startDate:
          type: string
        endDate:
          type: string
        userCreated:
          type: string
        userUpdated:
          type: string
        creationDate:
          type: string
        updateDate:
          type: string
        channelType:
          type: string
        channelCode:
          type: string
        channelName:
          type: string
        sellType:
          type: string
        subchannelGroup:
          type: string
        segment:
          type: string
        ine:
          type: string
        migratedFromDealerId:
          type: integer
        migratedFromDealerCode:
          type: string
        migratedToDealerId:
          type: integer
        migratedToDealerCode:
          type: string
        storeDelivery:
          type: boolean
        deviceReturn:
          type: boolean
    DealerResponse:
      description: Dealer response ok
      allOf:
        - $ref: '#/components/schemas/DealerBase'
      type: object
      properties:
        dealerId:
          type: integer
        migratedFromDealerId:
          type: integer
        migratedToDealerId:
          type: integer
    DealerAccessResponse:
      description: Dealer access response ok
      type: object
      properties:
        dealerId:
          type: integer
        startDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        endDate:
          type: string
          example: '2020-05-21T12:00:00Z'
    DealerInHierarchyResponse:
      description: Dealer hierarchy response ok
      type: object
      properties:
        dealerCode:
          type: string
        dealerId:
          type: integer
        commercialName:
          type: string
        mainChannelCode:
          type: string
        subchannelCode:
          type: string
        level:
          type: integer
        parentCode:
          type: string
        internalManager:
          type: string
        externalManager:
          type: string
        storeType:
          type: string
        commissioningSection:
          type: string
        companyType:
          type: string
        documentType:
          type: string
        documentNumber:
          type: string
        companyName:
          type: string
        status:
          type: string
        address:
          type: string
        city:
          type: string
        province:
          type: string
        country:
          type: string
        postalCode:
          type: string
        contactInformation:
          type: array
          items:
            $ref: '#/components/schemas/ContactInformation'
        segment:
          type: string
        ine:
          type: string
        storeDelivery:
          type: boolean
          default: false
        deviceReturn:
          type: boolean
          default: false
    DealerHierarchyResponse:
      type: object
      properties:
        id:
          type: integer
        hierarchy:
          type: array
          items:
            $ref: '#/components/schemas/DealerInHierarchyResponse'
    ContactInformation:
      type: object
      properties:
        contactName:
          type: string
        contactEmail:
          type: string
        contactPhone:
          type: string
        contactPurposes:
          type: array
          items:
            type: string
            enum:
              - PUBLIC
              - REPORTS
              - LOGISTICS
              - INVOICING
              - COMMERCIAL
              - INCIDENCES
              - MANAGEMENT
    DealerChangeStatusRequest:
      type: object
      properties:
        status:
          type: string
          enum:
            - Activo
            - Bloqueado
            - Baja
            - Inactivo
            - Pendiente
    CampaignChangeStatusRequest:
      type: object
      properties:
        status:
          type: string
          enum:
            - ACTIVATED
            - DEACTIVATED
    DealerRequest:
      description: Dealer request info simplified object.
      allOf:
        - $ref: '#/components/schemas/DealerBase'
      type: object
      required:
        - code
        - commercialName
        - level
        - statusCode
        - subchannel
    DealerBase:
      description: Dealer base info simplified object.
      allOf:
        - $ref: '#/components/schemas/Address'
      type: object
      properties:
        code:
          type: string
        commercialName:
          type: string
        level:
          type: integer
        statusCode:
          type: string
        parentCode:
          type: string
        subchannel:
          type: string
        internalManager:
          type: integer
        externalManager:
          type: integer
        commissioningSection:
          type: string
        storeType:
          type: string
        fiscalDataId:
          type: integer
        startDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        endDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        segment:
          type: string
        ine:
          type: string
        storeDelivery:
          type: boolean
          default: false
        deviceReturn:
          type: boolean
          default: false
    LevelBase:
      description: .
      type: object
      properties:
        id:
          type: integer
        hierarchicalLevel:
          type: integer
    SubchannelBase:
      description: .
      type: object
      properties:
        id:
          type: integer
        code:
          type: string
    ManagerBase:
      description: .
      type: object
      properties:
        id:
          type: integer
        code:
          type: string
    InternalManager:
      allOf:
        - $ref: '#/components/schemas/ManagerBase'
      type: object
    ExternalManager:
      allOf:
        - $ref: '#/components/schemas/ManagerBase'
      type: object
    DealerFullInfoResponse:
      description: Dealer full info object.
      type: object
      properties:
        genericInfo:
          $ref: '#/components/schemas/SimpleDealerResponse1'
        fiscalDataInfo:
          $ref: '#/components/schemas/FiscalData'
        billingInfo:
          $ref: '#/components/schemas/BillingInfo'
    BillingInfo:
      description: Billing info object.
      type: object
      properties:
        dealerId:
          type: integer
        code:
          type: string
        commercialName:
          type: string
        documentType:
          type: string
        documentNumber:
          type: string
    SimpleDealerResponse1:
      description: Dealer generic info simplified object.
      type: object
      properties:
        id:
          type: integer
        code:
          type: string
        commercialName:
          type: string
        level:
          type: integer
        levelDescription:
          type: string
        status:
          type: string
        parentId:
          type: integer
        parentCode:
          type: string
        subchannelCode:
          type: string
        internalManagerFullName:
          type: string
        externalManagerFullName:
          type: string
        internalManagerCode:
          type: string
        externalManagerCode:
          type: string
        commissioningSection:
          type: string
        storeType:
          type: string
        address:
          type: string
        city:
          type: string
        province:
          type: string
        country:
          type: string
        postalCode:
          type: string
        startDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        endDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        userCreated:
          type: string
        userUpdated:
          type: string
        creationDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        updateDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        channelType:
          type: string
        sellType:
          type: string
        subchannelGroup:
          type: string
        segment:
          type: string
        ine:
          type: string
        migratedFromDealerId:
          type: integer
        migratedToDealerId:
          type: integer
        migratedFromDealerCode:
          type: string
        migratedToDealerCode:
          type: string
        storeDelivery:
          type: boolean
          default: false
        deviceReturn:
          type: boolean
          default: false
        documentType:
          type: string
        documentNumber:
          type: string
    SummarizedDealerInfo:
      description: Summarized dealer info.
      type: object
      properties:
        id:
          type: integer
        code:
          type: string
        commercialName:
          type: string
        level:
          type: integer
        status:
          type: string
        parentCode:
          type: string
        subchannelCode:
          type: string
        email:
          type: string
    ListDealerResponse:
      description: Dealer generic info simplified object.
      type: object
      properties:
        id:
          type: integer
        code:
          type: string
        commercialName:
          type: string
        level:
          type: integer
        status:
          type: string
        parentId:
          type: integer
        parentCode:
          type: string
        subchannelCode:
          type: string
        internalManagerFullName:
          type: string
        externalManagerFullName:
          type: string
        commissioningSection:
          type: string
        storeType:
          type: string
        address:
          type: string
        city:
          type: string
        province:
          type: string
        country:
          type: string
        postalCode:
          type: string
        startDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        endDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        userCreated:
          type: string
        userUpdated:
          type: string
        creationDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        updateDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        channelType:
          type: string
        sellType:
          type: string
        subchannelGroup:
          type: string
        segment:
          type: string
        ine:
          type: string
    DealerSimpleList:
      description: Dealer generic info simplified object.
      type: object
      properties:
        id:
          type: integer
        code:
          type: string
        commercialName:
          type: string
        level:
          type: integer
        parentCode:
          type: string
        subchannelCode:
          type: string
        status:
          type: string
    DealerSimpleListResponse:
      type: array
      items:
        $ref: '#/components/schemas/SummarizedDealerInfo'
    ContactResponse1:
      description: Contact generic info simplified object.
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        email:
          type: string
          example: test@test.es
        phoneNumber:
          type: string
          example: '987654321'
        purposes:
          type: array
          items:
            $ref: '#/components/schemas/PurposeResponse'
        dealers:
          type: array
          items:
            $ref: '#/components/schemas/SimpleDealerResponse1'
    DealerContact:
      type: object
      properties:
        contactId:
          type: integer
          example: 154
        dealerId:
          type: integer
          example: 130
    CompanyBase:
      type: object
      properties:
        companyType:
          type: string
          enum:
            - AUTÓNOMO
            - EMPRESA
        companyName:
          type: string
          maxLength: 60
          example: FOO S.L.
    Document:
      type: object
      properties:
        documentType:
          type: string
          enum:
            - NIF
            - CIF
            - NIE
        documentNumber:
          type: string
          example: 1234567X
    Address:
      type: object
      properties:
        address:
          type: string
          maxLength: 60
          example: C/Ocaña 9
        city:
          type: string
          maxLength: 40
          example: Madrid
        province:
          type: string
          example: Madrid
        postalCode:
          type: string
          maxLength: 8
          example: 28011
        country:
          type: string
          enum:
            - ES
            - PT
            - AD
            - PE
            - CO
            - MA
          example: ES
    FiscalDataAssociatedDealer:
      type: object
      properties:
        id:
          type: string
        code:
          type: string
        commercialName:
          type: string
        level:
          type: integer
        subChannelCode:
          type: string
    FiscalData:
      allOf:
        - $ref: '#/components/schemas/CompanyBase'
        - $ref: '#/components/schemas/Document'
        - $ref: '#/components/schemas/Address'
      type: object
      properties:
        id:
          type: integer
    FiscalDataPost:
      allOf:
        - $ref: '#/components/schemas/FiscalData'
      required:
        - companyType
        - companyName
        - documentType
        - documentNumber
        - address
        - city
        - province
        - postalCode
        - country
    FiscalDataDetail:
      type: object
      properties:
        dealers:
          type: array
          items:
            $ref: '#/components/schemas/FiscalDataAssociatedDealer'
    FiscalDataPatch:
      properties:
        companyName:
          type: string
          maxLength: 60
          example: FOO S.L.
      allOf:
        - $ref: '#/components/schemas/Address'
    DealerTarget:
      description: Dealer migration info.
      type: object
      required:
        - code
        - subchannel
      properties:
        code:
          type: string
        commercialName:
          type: string
        level:
          type: integer
        subchannel:
          type: string
        parentCode:
          type: string
    DealerMigrationRequest:
      description: Dealer migration info.
      allOf:
        - $ref: '#/components/schemas/DealerTarget'
      type: object
      properties:
        migrationDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        copyGenericInfo:
          type: boolean
        copyContactInfo:
          type: boolean
        copyFiscalData:
          type: boolean
        copyAccountingSystems:
          type: boolean
        copyCustomInfo:
          type: boolean
        migratedSalesBase:
          type: boolean
    DealerMigrationResponse:
      allOf:
        - $ref: '#/components/schemas/DealerResponse'
    DealerCustomInfoRequest:
      description: Dealer custom-info.
      type: object
      properties:
        fieldId:
          type: integer
        dealerId:
          type: integer
        fieldValue:
          type: string
    DealerCustomInfoResponse:
      description: Dealer custom-info.
      allOf:
        - $ref: '#/components/schemas/DealerCustomInfoRequest'
      type: object
      properties:
        id:
          type: integer
        fieldName:
          type: string
        userCreated:
          type: string
        userUpdated:
          type: string
        creationDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        updateDate:
          type: string
          example: '2020-05-21T12:00:00Z'
    CustomInfoBase:
      description: Dealer custom-info.
      type: object
      properties:
        fieldName:
          type: string
        fieldDescription:
          type: string
        fieldType:
          type: string
    CustomInfoRequest:
      description: Dealer custom-info.
      allOf:
        - $ref: '#/components/schemas/CustomInfoBase'
    CustomInfoResponse:
      description: Dealer custom-info.
      allOf:
        - $ref: '#/components/schemas/CustomInfoBase'
      type: object
      properties:
        id:
          type: integer
        values:
          type: string
        userCreated:
          type: string
        userUpdated:
          type: string
        creationDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        updateDate:
          type: string
          example: '2020-05-21T12:00:00Z'
    CommercialProfiles:
      description: commercial profile.
      type: string
      example: perfil_comercial.ecare
    CampaignUser:
      description: Level 4 Dealer that operate from Agents
      type: object
      properties:
        id:
          type: integer
          example: 12345
        code:
          type: string
          example: CDRDealer
        commercialName:
          type: string
          example: Agent
        subchannel:
          type: string
          example: ATC
        systemAccounts:
          type: array
          items:
            $ref: '#/components/schemas/SystemAccount'
        campaign:
          description: A commercial campaign
          type: object
          properties:
            id:
              type: integer
              example: 12345
            name:
              type: string
              example: campaign
            commercialProfile:
              type: string
              example: Commercial profile
            active:
              type: boolean
              example: true
            subchannels:
              type: array
              items:
                $ref: '#/components/schemas/Subchannel'
            conditions:
              example: null
      required:
        - id
        - code
        - name
        - user
    SystemAccount:
      description: A Dealer's system account
      type: object
      properties:
        id:
          type: integer
          example: 12345
        account:
          type: string
          example: CDRDealer
        accountingSystem:
          $ref: '#/components/schemas/AccountingSystem'
    Subchannel:
      description: A subchannel
      type: object
      properties:
        id:
          type: integer
          example: 123
        code:
          type: string
          example: MS
        name:
          type: string
          example: MasSubchannel
        mainChannel:
          $ref: '#/components/schemas/Channel'
        sellType:
          type: string
          example: mySellType
        subchannelGroup:
          type: string
          example: mySubchannelGroup
    Channel:
      description: A subchannel
      type: object
      properties:
        id:
          type: integer
          example: 12345
        code:
          type: string
          example: M
        name:
          type: string
          example: Mas
        channelType:
          type: string
          example: myChannelType
    Campaign:
      description: A commercial campaign
      type: object
      properties:
        id:
          type: integer
          example: 12345
        name:
          type: string
          example: campaign
        commercialProfile:
          type: string
          example: Commercial profile
        active:
          type: boolean
          example: true
        subchannels:
          type: array
          items:
            $ref: '#/components/schemas/SubchannelSummary'
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/CampaignRules'
    AccountingSystem:
      description: An accounting system
      type: object
      properties:
        id:
          type: integer
          example: 12345
        code:
          type: string
          example: IAM
        description:
          type: string
          example: System of MM
    DealerAccountingSystemResponseList:
      type: array
      items:
        $ref: '#/components/schemas/DealerAccountingSystemResponse'
    DealerAccountingSystemPostRequest:
      description: A dealer accounting system
      type: object
      properties:
        dealerId:
          type: integer
          example: 1234
        systemId:
          type: integer
          example: 1
        dealerCode:
          type: string
        example: it's called dealerCode but it's the system's username
    DealerAccountingSystemRequest:
      description: A dealer accounting system
      type: object
      properties:
        systemId:
          type: integer
          example: 1
        dealerCode:
          type: string
          example: it's called dealerCode but it's the system's username
    DealerAccountingSystemResponse:
      description: A dealer accounting system
      type: object
      properties:
        id:
          type: integer
          example: 21234
        dealerId:
          type: integer
          example: 1234
        systemId:
          type: integer
          example: 1
        systemCode:
          type: string
          example: IAM
        systemDescription:
          type: string
          example: IAM System
        dealerCode:
          type: string
          example: TEST_DEALER
    ChangeCampaignRequest:
      description: Dealer custom-info.
      type: object
      properties:
        campaignId:
          type: integer
          example: 123
        requestId:
          type: integer
          example: 123
        dealerId:
          type: array
          items:
            $ref: '#/components/schemas/DealerId'
    CampaignRequest:
      description: >-
        Body required to create/update campaign. It is created active by
        default.
      type: object
      properties:
        name:
          type: string
          example: campaign
        commercialProfile:
          type: string
          example: Commercial profile
        subchannels:
          type: array
          items:
            type: string
            example: MS
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/CampaignRules'
      required:
        - name
        - commercialProfile
        - subchannels
    DealerId:
      type: integer
      example: 154
    SubchannelSummary:
      description: SubchannelSummary
      type: object
      properties:
        id:
          type: integer
          example: 123
        code:
          type: string
          example: MS
        name:
          type: string
          example: MasSubchannel
    CampaignRules:
      description: CampaignRules
      type: object
      properties:
        id:
          type: integer
          example: 123
        concept:
          type: string
          example: SEGMENT
        operator:
          type: string
          example: EQ
        values:
          type: string
          example: RESIDENCIAL
        type:
          type: string
          example: String
    CampaignSearchRequest:
      type: object
      properties:
        active:
          type: boolean
          example: true
        subchannels:
          type: array
          items:
            type: string
            example: MS1
            uniqueItems: true
        dealers:
          type: array
          items:
            type: integer
            example: 1
            uniqueItems: true
    Store:
      description: Store response ok
      type: object
      properties:
        dealerCode:
          type: string
        commercialName:
          type: string
        addressInfo:
          $ref: '#/components/schemas/Address'
        phoneNumber:
          type: string
        email:
          type: string
        location:
          $ref: '#/components/schemas/Location'
        distance:
          type: number
          format: double
          example: 330.15
        storeDelivery:
          type: boolean
          default: false
        deviceReturn:
          type: boolean
          default: false
        brands:
          type: array
          items:
            $ref: '#/components/schemas/Brand'
        customInformation:
          type: array
          items:
            $ref: '#/components/schemas/DealerCustomInfoRequest'
    Location:
      type: object
      properties:
        latitude:
          type: number
          format: double
          example: 40.4124967
        longitude:
          type: number
          format: double
          example: -3.8706208
    Brand:
      type: object
      properties:
        code:
          type: string
          example: MM
        description:
          type: string
          example: masmovil
    DealerBrandResponse:
      type: object
      properties:
        id:
          type: integer
          example: 12
        dealerId:
          type: integer
          example: 13
        brandId:
          type: integer
          example: 123
        brandCode:
          type: string
          example: MM
        brandDescription:
          type: string
          example: MasMovil
    DealerBrandRequest:
      type: object
      properties:
        id:
          type: integer
          example: 12
        startDate:
          type: string
          format: date-time
        endDate:
          type: string
          format: date-time
    DealerWithCustomFieldValueResponse:
      type: object
      properties:
        dealerId:
          type: integer
          example: 123
        dealerCode:
          type: string
          example: testCode
        dealerCommercialName:
          type: string
          example: testCommercialName
        fieldValue:
          type: string
          example: testfieldValue
    GenericError:
      type: object
      properties:
        message:
          type: string
        code:
          type: string
        status:
          type: string
        detailMsg:
          type: string
    ManagerBase1:
      description: Contact generic info simplified object.
      type: object
      properties:
        id:
          type: integer
        code:
          type: string
          example: t.test
    ManagerResponse:
      allOf:
        - $ref: '#/components/schemas/ManagerBase1'
      description: Contact generic info simplified object.
      type: object
      properties:
        name:
          type: string
          example: Test
        surname:
          type: string
          example: Test
        type:
          type: string
          enum:
            - INT
            - EXT
          example: INT
          description: INT -> Interno EXT -> Externo
        parent:
          $ref: '#/components/schemas/ManagerBase1'
    RequestResponse:
      description: >-
        Body for multisystem subscription call. Fields for identification
        relationship plattform + issue + dealerId for JIRA CASE.
      type: object
      properties:
        id:
          type: integer
        dealerId:
          type: integer
        dealerCode:
          type: string
        platform:
          type: string
          enum:
            - JIRA
            - IAM
        status:
          type: string
          enum:
            - PENDING
            - CREATED
            - REJECTED
            - COMPLETED
            - ERROR
        userCreated:
          type: string
        creationDate:
          type: string
          example: '2020-05-21T12:00:00Z'
        requestDetails:
          type: object
          properties:
            email:
              type: string
            orgUnit:
              type: string
            salesRole:
              type: string
            commercialProfile:
              type: array
              items:
                type: string
            simReplacement:
              type: boolean
            eSIMReplacement:
              type: boolean
      required:
        - dealerId
        - platform
        - requestType
        - status
    RequestsRequest:
      description: >-
        Body for multisystem subscription call. Fields for identification
        relationship plattform + issue + dealerId for JIRA CASE.
      type: object
      properties:
        dealerId:
          type: integer
        platform:
          type: string
          enum:
            - JIRA
            - IAM
        issue:
          type: string
        requestType:
          type: string
          enum:
            - DEALER_CREATION
        status:
          type: string
          enum:
            - PENDING
            - CREATED
            - REJECTED
            - COMPLETED
            - ERROR
        requestDetail:
          nullable: true
          oneOf:
            - $ref: '#/components/schemas/RequestDetailIamCreateDealer'
            - $ref: '#/components/schemas/RequestDetailIamChangeCampaign'
      required:
        - dealerId
        - platform
        - requestType
        - status
    RequestDetailIamCreateDealer:
      type: object
      properties:
        email:
          type: string
        pass:
          type: string
        recoveryPhone:
          type: string
        orgUnitId:
          type: integer
        orgUnit:
          type: string
        salesRole:
          type: string
        commercialProfile:
          type: array
          items:
            type: string
        SIMReplacement:
          type: boolean
        eSIMReplacement:
          type: boolean
    RequestDetailIamChangeCampaign:
      type: object
      properties:
        campaignId:
          type: integer
        dealerIds:
          type: array
          items:
            type: integer
    RequestModificationBody:
      description: Request modification body.
      type: object
      properties:
        status:
          type: string
          enum:
            - PENDING
            - CREATED
            - REJECTED
            - COMPLETED
            - ERROR
        comment:
          type: string
    RequestCreatedResponse:
      description: Request response body.
      type: object
      properties:
        id:
          type: integer
        dealerId:
          type: integer
        platform:
          type: string
          enum:
            - JIRA
            - IAM
        issue:
          type: string
        requestType:
          type: string
        comment:
          type: string
        status:
          type: string
          enum:
            - PENDING
            - CREATED
            - REJECTED
            - COMPLETED
            - ERROR
  responses:
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            type: string
          example: Origin authentication failed.
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            errors:
              - code: BAD_REQUEST
                title: Error message
                ref: some_ref
                details: Detailed error message
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            errors:
              - code: INTERNAL_SERVER_ERROR
                title: Error message
                ref: some_ref
                details: Detailed error message
    Unauthorized1:
      description: Unauthorized
      content:
        application/json:
          schema:
            type: string
          example:
            code: '0003'
            status: UNAUTHORIZED
            message: Unauthorized
            detailMsg: Audience not found to access URI /example-uri
    NotFound:
      description: Custom information not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorResponse'
          example:
            errors:
              - code: NOT_FOUND
                title: Error message
                ref: some_ref
                details: Detailed error message
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
