openapi: 3.0.1
info:
  title: Partners Layer
  description: 'Partners Layer'
  version: 2.1.0
servers:
  - url: https://partners.sta.masstack.com/v2
    description: Staging environment
    variables: { }
  - url: https://partners.masstack.com/v2
    description: Production environment
    variables: { }

paths:
  /{service_type}/{service_id}/barrings:
    patch:
      tags:
        - Barrings Operations
      summary: Update service barring
      description: Update service barring
      operationId: manageServiceBarring
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: mobile
        - name: service_id
          in: path
          description: Service identifier whose barring will be updated
          required: true
          schema:
            type: string
            example: 12344411234
          example: 612123456
      requestBody:
        description: Contain barring to be updated, the value to be set and the callbacks to be used
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/barringRequestDTO'
        required: true
      responses:
        "202":
          description: The operation request was successfully accepted, returned the request external reference identifier
          headers:
            Request-Correlation-Id:
              required: false
              schema:
                type: string
              description: Workflow Id (unique identifier)
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error
      callbacks:
        success_event:
          '{$request.body#/callback_success_url}':
            post:
              operationId: manageServiceBarringSuccess
              parameters:
                - $ref: '#/components/parameters/Request-Correlation-Id-Response'
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/barringCallbackDTO'
              responses:
                '200':
                  description: OK
                '400':
                  description: Not found
                '500':
                  description: Internal Error
        error_event:
          '{$request.body#/callback_error_url}':
            post:
              operationId: manageServiceBarringError
              parameters:
                - $ref: '#/components/parameters/Request-Correlation-Id-Response'
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/barringCallbackDTO'
              responses:
                '200':
                  description: OK
                '400':
                  description: Not found
                '500':
                  description: Internal Error
    get:
      tags:
        - Barrings Operations
      summary: Get service barring detail
      description: Get service barring detail
      operationId: getServiceBarringDetail
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: mobile
        - name: service_id
          in: path
          description: Service identifier whose barring will be updated
          required: true
          schema:
            type: string
            example: 12344411234
          example: 612123456
      responses:
        "200":
          description: Successfully getting barring detail
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/barringsDetailResponseDTO'
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error

  /{service_type}/{service_id}/billing/movements-non-subscribable-services:
    post:
      tags:
        - Billing Operations
      summary: Create movement for non subscribable services
      description: Create movement for non subscribable services
      operationId: createMovementNonSubscribable
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: mobile
        - name: service_id
          in: path
          description: Service identifier for movement creation
          required: true
          schema:
            type: string
          example: 612123456
      requestBody:
        description: Contains movement information to be created
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/movementNonSubscribableRequestDTO'
        required: true
      responses:
        "201":
          description: Successfully created the operation request, returned the result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/movementSuccessResponseDTO'
              example:
                code: CREATED
                title: Movement created correctly
                movement_id: 8da2b117-ef72-413d-98ce-36d1eb544e44
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: NOT_FOUND
                title: "Msisdn not found: 100000000"
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error
  /{service_type}/{service_id}/billing/movements-non-subscribable-services/{movement_id}:
    put:
      tags:
        - Billing Operations
      summary: Update movement for non subscribable services
      description: Update movement for non subscribable services
      operationId: updateMovementNonSubscribable
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: mobile
        - name: service_id
          in: path
          description: Service identifier for movement update
          required: true
          schema:
            type: string
          example: 612123456
        - name: movement_id
          in: path
          description: Movement to be updated identifier
          required: true
          schema:
            type: string
          example: 4d9d437f-ef3b-41e7-b474-067b1917cc4e
      requestBody:
        description: Contains movement information to be updated
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/movementNonSubscribableRequestDTO'
        required: true
      responses:
        "200":
          description: Successfully updated the movement.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/movementUpdateResponseDTO'
              example:
                code: CREATED
                title: Movement updated correctly
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: NOT_FOUND
                title: "Msisdn not found: 100000000"
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error
    delete:
      tags:
        - Billing Operations
      summary: Delete movement for non subscribable services
      description: Delete movement for non subscribable services
      operationId: deleteMovementNonSubscribable
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: mobile
        - name: service_id
          in: path
          description: Service identifier for the movement to be deleted
          required: true
          schema:
            type: string
          example: 612123456
        - name: movement_id
          in: path
          description: Movement to be updated identifier
          required: true
          schema:
            type: string
          example: 4d9d437f-ef3b-41e7-b474-067b1917cc4e
      responses:
        "200":
          description: Successfully deleted de movement resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/movementUpdateResponseDTO'
              example:
                code: DELETED
                title: Movement deleted correctly
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: NOT_FOUND
                title: "Msisdn not found: 100000000"
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error

  /{service_type}/{service_id}/billing/refund-non-subscribable-services:
    post:
      tags:
        - Billing Operations
      summary: Create refund for non subscribable services
      description: Create refund for non subscribable services
      operationId: createRefundNonSubscribable
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: mobile
        - name: service_id
          in: path
          description: Service identifier for refund creation
          required: true
          schema:
            type: string
          example: 612123456
      requestBody:
        description: Contains refund information to be created
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/refundNonSubscribableRequestDTO'
        required: true
      responses:
        "201":
          description: Successfully accepted the operation request, returned the result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/refundSuccessResponseDTO'
              example:
                code: CREATED
                title: Refund created correctly
                refund_id: 8da2b117-ef72-413d-98ce-36d1eb544e44
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: NOT_FOUND
                title: "Msisdn not found: 100000000"
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error

  /{service_type}/{service_id}/billing/movements:
    post:
      tags:
        - Billing Operations
      summary: Create movement for services
      description: Create movement for services
      operationId: createMovement
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: mobile
        - name: service_id
          in: path
          description: Service identifier for movement creation
          required: true
          schema:
            type: string
          example: 612123456
      requestBody:
        description: Contains movement information to be created
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/movementRequestDTO'
        required: true
      responses:
        "201":
          description: Successfully created the operation request, returned the result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/movementSuccessResponseDTO'
              example:
                code: CREATED
                title: Movement created correctly
                movement_id: 8da2b117-ef72-413d-98ce-36d1eb544e44
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: NOT_FOUND
                title: "Msisdn not found: 100000000"
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error

  /{service_type}/{service_id}/billing/movements/{movement_id}:
    delete:
      tags:
        - Billing Operations
      summary: Delete movement for services
      description: Delete movement for services
      operationId: deleteMovement
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: mobile
        - name: service_id
          in: path
          description: Service identifier for the movement to be deleted
          required: true
          schema:
            type: string
          example: 612123456
        - name: movement_id
          in: path
          description: Movement to be updated identifier
          required: true
          schema:
            type: string
          example: 4d9d437f-ef3b-41e7-b474-067b1917cc4e
      responses:
        "200":
          description: Successfully deleted de movement resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/movementUpdateResponseDTO'
              example:
                code: DELETED
                title: Movement deleted correctly
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: NOT_FOUND
                title: "Msisdn not found: 100000000"
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error
  /{service_type}/{service_id}/billing/refunds:
    post:
      tags:
        - Billing Operations
      summary: Create refund for services
      description: Create refund for services
      operationId: createRefund
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: mobile
        - name: service_id
          in: path
          description: Service identifier for refund creation
          required: true
          schema:
            type: string
          example: 612123456
      requestBody:
        description: Contains refund information to be created
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/refundRequestDTO'
        required: true
      responses:
        "201":
          description: Successfully accepted the operation request, returned the result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/refundSuccessResponseDTO'
              example:
                code: CREATED
                title: Refund created correctly
                refund_id: 8da2b117-ef72-413d-98ce-36d1eb544e44
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: NOT_FOUND
                title: "Msisdn not found: 100000000"
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error
  /{service_type}/{service_id}/promotions:
    post:
      tags:
        - Promotions Operations
      summary: Activate a new promotion for a service
      description: Activate a new promotion for a service
      operationId: createPromotion
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: mobile
        - name: service_id
          in: path
          description: Service identifier
          required: true
          schema:
            type: string
            example: 12344411234
          example: 612123456
      requestBody:
        description: Contain promotion information to be activated
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/createPromotionRequestDTO'
        required: true
      responses:
        "201":
          description: Successfully created the operation request, returned the result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PromotionSuccessResponseDTO'
              example:
                code: CREATED
                title: Promotion created correctly
                promotion_id: 8da2b117-ef72-413d-98ce-36d1eb544e44
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: NOT_FOUND
                title: "Msisdn not found: 100000000"
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error

  /{service_type}/{service_id}/promotions/{promotion_id}:
    patch:
      tags:
        - Promotions Operations
      summary: Update a promotion for a service
      description: Update a promotion for a service
      operationId: updatePromotion
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: mobile
        - name: service_id
          in: path
          description: Service identifier
          required: true
          schema:
            type: string
            example: 12344411234
          example: 612123456
        - name: promotion_id
          in: path
          description: Promotion identifier
          required: true
          schema:
            type: string
            example: 12344411234
          example: 612123456
      requestBody:
        description: Update an existing promotion
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updatePromotionRequestDTO'
        required: true

      responses:
        "200":
          description: Successfully completed the operation request, returned the result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/promotionUpdateResponseDTO'
              example:
                code: OK
                title: Promotion updated correctly
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: NOT_FOUND
                title: "Msisdn not found: 100000000"
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error

  /{service_type}/:
    post:
      tags:
        - Service Operations
      summary: New service creation
      description: New service creation
      operationId: createService
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: applewatch
      requestBody:
        description: Create a new service
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/createServiceRequestDTO'
        required: true
      responses:
        "202":
          description: Successfully accepted the operation request, returned the request external reference identifier
          headers:
            Request-Correlation-Id:
              required: false
              schema:
                type: string
              description: Workflow Id (unique identifier)
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error
      callbacks:
        success_event:
          '{$request.body#/callback_success_url}':
            post:
              operationId: createServiceSuccess
              parameters:
                - $ref: '#/components/parameters/Request-Correlation-Id-Response'
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/serviceCallbackDTO'
              responses:
                '200':
                  description: OK
                '400':
                  description: Not found
                '500':
                  description: Internal Error
        error_event:
          '{$request.body#/callback_error_url}':
            post:
              operationId: createServiceError
              parameters:
                - $ref: '#/components/parameters/Request-Correlation-Id-Response'
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/serviceCallbackDTO'
              responses:
                '200':
                  description: OK
                '400':
                  description: Not found
                '500':
                  description: Internal Error
  /netflix/{service_id}:
    patch:
      tags:
        - Netflix Service Operations
      summary: Update a Netflix service
      description: Update a Netflix service
      operationId: updateNetflixService
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_id
          in: path
          description: Service identifier whose device will be updated
          required: true
          schema:
            type: string
            example: 12344411234
          example: 612123456
      requestBody:
        description: Update an existing service
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updateNetflixServiceRequestDTO'
        required: true
      responses:
        "200":
          description: Successfully accepted the operation request, returned the request external reference identifier
          headers:
            Request-Correlation-Id:
              required: false
              schema:
                type: string
              description: Workflow Id (unique identifier)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/updateNetflixServiceResponseDTO'
              example:
                transaction_id: define
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error
  /netflix/{service_id}/simyo:
    post:
      tags:
        - Netflix Service Operations
      summary: Notify Simyo about a Netflix product change
      description: Notify Simyo about a Netflix product change
      operationId: notifySimyoUpdateNetflixService
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_id
          in: path
          description: Service identifier whose device will be updated
          required: true
          schema:
            type: string
            example: 12344411234
          example: 612123456
      requestBody:
        description: Update an existing service
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/simyoNotificationDTO'
        required: true
      responses:
        "200":
          description: Successfully accepted the operation request, returned the request external reference identifier
          headers:
            Request-Correlation-Id:
              required: false
              schema:
                type: string
              description: Workflow Id (unique identifier)
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error
  /{service_type}/{service_id}/devices/{device_id}:
    patch:
      tags:
        - Device Operations
      summary: Update device for a service  (e.g. eSIM, SIM ...)
      description: Update device for a service  (e.g. eSIM, SIM ...)
      operationId: updateServiceDevices
      parameters:
        - $ref: '#/components/parameters/Request-Correlation-Id'
        - name: service_type
          in: path
          description: Service type indicator
          required: true
          schema:
            $ref: '#/components/schemas/serviceTypeDTO'
          example: mobile
        - name: service_id
          in: path
          description: Service identifier whose device will be updated
          required: true
          schema:
            type: string
            example: 12344411234
          example: 612123456
        - name: device_id
          in: path
          description: Device identifier to be updated
          required: true
          schema:
            type: string
      requestBody:
        description: Update an existing service device
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updateServiceDeviceRequestDTO'
        required: true
      responses:
        "202":
          description: Successfully accepted the operation request, returned the request external reference identifier
          headers:
            Request-Correlation-Id:
              required: false
              schema:
                type: string
              description: Workflow Id (unique identifier)
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: BAD_REQUEST
                title: MISSING CALLBACK URL
        "401":
          description: Unauthorized request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: UNAUTHORIZED_REQUEST
                title: Missing credentials
        "403":
          description: Forbidden resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: FORBIDDEN_RESOURCE
                title: Request forbidden by administrative rules
        "406":
          description: Not Acceptable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: DUPLICATE_WORKFLOW_ID
                title: Duplicate workflow id
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/genericErrorResponseDTO'
              example:
                code: INTERNAL_SERVER_ERROR
                title: Server is not working due to some error
      callbacks:
        success_event:
          '{$request.body#/callback_success_url}':
            post:
              operationId: updateServiceDevicesSuccess
              parameters:
                - $ref: '#/components/parameters/Request-Correlation-Id-Response'
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/serviceCallbackDTO'
              responses:
                '200':
                  description: OK
                '400':
                  description: Not found
                '500':
                  description: Internal Error
        error_event:
          '{$request.body#/callback_error_url}':
            post:
              operationId: updateServiceDevicesError
              parameters:
                - $ref: '#/components/parameters/Request-Correlation-Id-Response'
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/serviceCallbackDTO'
              responses:
                '200':
                  description: OK
                '400':
                  description: Not found
                '500':
                  description: Internal Error
components:
  schemas:
    barringRequestDTO:
      required:
        - barring_name
        - active
        - success-callback
        - error-callback
      allOf:
        - $ref: '#/components/schemas/callbackDTO'
      type: object
      properties:
        active:
          type: boolean
        barring_name:
          description: Name of the barring to be updated
          type: string
          enum:
            - ROAMING
            - INTERNATIONAL_DESTINATIONS
            - OUTGOING_VOICE
            - OUTGOING_SMS
            - INCOMING_VOICE
            - INCOMING_SMS
            - INTERNET
            - VOICE_PREMIUM_ENTERTAINMENT
            - VOICE_PREMIUM_INFORMATION
            - SMS_PREMIUM
            - SUBSCRIPTION_PREMIUM
          example: ROAMING
      description: Request to update barrings
    barringCallbackDTO:
      required:
        - codeResult
        - titleResult
      type: object
      properties:
        codeResult:
          type: string
          example: OK
        titleResult:
          type: string
          example: Barring update was successfully finished
      description: Body request to callback operation

    movementNonSubscribableRequestDTO:
      type: object
      required:
        - type
        - movement_datetime
        - amount
        - transaction_type_id
      properties:
        type:
          type: string
          enum:
            - RECURRING_CHARGE
            - ONE_TIME_FEE
            - INSTALLATION_FEE
            - SUSPENSION_SERVICE_FEE
            - UNRETURNED_EQUIPMENT_FEE
            - DISCOUNT
          example: "RECURRING_CHARGE"
        movement_datetime:
          type: string
          format: date-time
          example: "2022-02-24T13:45:10Z"
        period_start_datetime:
          type: string
          format: date-time
          description: Mandatory just if period_end_datetime is  set
          example: "2022-01-31T23:00:00Z"
        period_end_datetime:
          type: string
          format: date-time
          description: Mandatory just if period_start_datetime is  set
          example: "2022-02-28T23:00:00Z"
        amount:
          $ref: '#/components/schemas/amountDTO'
        external_invoice_id:
          type: string
          description: "this field is informative. We are not doing any further processing apart from persisting it"
          example: "123456789"
        external_movement_unique_id:
          type: string
          example: "123456789"
        transaction_type_id:
          type: string
          example: "5432167890"
        description:
          type: string
          example: "February invoice"

    movementRequestDTO:
      type: object
      required:
        - type
        - movement_datetime
        - amount
        - billable
        - external_movement_unique_id
      properties:
        type:
          type: string
          enum:
            - RECURRING_CHARGE
            - ONE_TIME_FEE
            - INSTALLATION_FEE
            - SUSPENSION_SERVICE_FEE
            - UNRETURNED_EQUIPMENT_FEE
            - DISCOUNT
          example: "RECURRING_CHARGE"
        movement_datetime:
          type: string
          format: date-time
          example: "2022-02-24T13:45:10Z"
        period_start_datetime:
          type: string
          format: date-time
          description: Mandatory just if period_end_datetime is  set
          example: "2022-01-31T23:00:00Z"
        period_end_datetime:
          type: string
          format: date-time
          description: Mandatory just if period_start_datetime is  set
          example: "2022-02-28T23:00:00Z"
        amount:
          $ref: '#/components/schemas/amountDTO'
        external_invoice_id:
          type: string
          description: "this field is informative. We are not doing any further processing apart from persisting it"
          example: "123456789"
        external_movement_unique_id:
          type: string
          example: "123456789"
        billable:
          type: boolean
          example: false
        concept_id:
          type: string
          example: "5432167890"
        campaign_id:
          type: string
          description: "promotion identifier. This field is only used for discount movement type"
          example: "234"
        description:
          type: string
          example: "February invoice"

    refundNonSubscribableRequestDTO:
      type: object
      required:
        - refund_datetime
        - amount
        - transaction_type_id
        - movement_id
      properties:
        refund_datetime:
          type: string
          format: date-time
          example: "2022-02-24T13:45:10Z"
        period_start_datetime:
          type: string
          format: date-time
          description: Mandatory just if period_end_datetime is  set
          example: "2022-01-31T23:00:00Z"
        period_end_datetime:
          type: string
          format: date-time
          description: Mandatory just if period_start_datetime is  set
          example: "2022-02-28T23:00:00Z"
        amount:
          $ref: '#/components/schemas/amountDTO'
        external_invoice_id:
          type: string
          description: "this field is informative. We are not doing any further processing apart from persisting it"
          example: "123456789"
        external_refund_unique_id:
          type: string
          example: "123456789"
        transaction_type_id:
          type: string
          example: "5432167890"
        movement_id:
          type: string
          example: "5432167890"
        description:
          type: string
          example: "February invoice"

    refundRequestDTO:
      type: object
      required:
        - refund_datetime
        - amount
        - billable
        - movement_id
        - external_refund_unique_id
      properties:
        refund_datetime:
          type: string
          format: date-time
          example: "2022-02-24T13:45:10Z"
        period_start_datetime:
          type: string
          format: date-time
          description: Mandatory just if period_end_datetime is  set
          example: "2022-01-31T23:00:00Z"
        period_end_datetime:
          type: string
          format: date-time
          description: Mandatory just if period_start_datetime is  set
          example: "2022-02-28T23:00:00Z"
        amount:
          $ref: '#/components/schemas/amountDTO'
        external_invoice_id:
          type: string
          description: "this field is informative. We are not doing any further processing apart from persisting it"
          example: "123456789"
        external_refund_unique_id:
          type: string
          example: "123456789"
        billable:
          type: boolean
          example: false
        movement_id:
          type: string
          example: "5432167890"
        description:
          type: string
          example: "February invoice"

    createPromotionRequestDTO:
      type: object
      required:
        - promotion
      properties:
        promotion:
          $ref: '#/components/schemas/promotionDTO'

    updatePromotionRequestDTO:
      type: object
      required:
        - deactivation_date
      properties:
        deactivation_date:
          type: string
          format: date-time
          example: "2022-02-24T13:45:10Z"

    promotionDTO:
      type: object
      properties:
        promotion_id:
          type: string
          description: Catalogue unique promotion identifier
          example: 76
        activation_date:
          type: string
          description: promotion activation date
          format: date-time
          example: "2017-09-15T22:00:00Z"
        deactivation_date:
          type: string
          description: promotion deactivation date
          format: date-time
          example: "2017-09-15T22:00:00Z"

    amountDTO:
      type: object
      properties:
        value_with_taxes:
          type: number
          format: float
          minimum: 0
          example: 12.10
        value_without_taxes:
          type: number
          format: float
          minimum: 0
          example: 10.00
        tax:
          $ref: '#/components/schemas/taxDTO'

    taxDTO:
      type: object
      required: [ type, percentage ]
      properties:
        type:
          type: string
          enum:
            - EXEMPTED
            - IGIC
            - IVA
            - IPSI_CEUTA
            - IPSI_MELILLA
            - NOT_APPLY
            - NOT_TAXED
          example: "IVA"
        percentage:
          type: number
          format: float
          minimum: 0
          example: 21

    genericErrorResponseDTO:
      required:
        - code
        - title
      type: object
      properties:
        code:
          type: string
          description: Error code string for fast identification
          example: INVALID_MSISDN
        title:
          type: string
          description: Message description or detail of error
          example: 'MSISDN does not belong to an active service'
      description: Rest service error response

    movementUpdateResponseDTO:
      required:
        - code
        - title
      type: object
      properties:
        code:
          type: string
          description: Code string for fast identification
          example: OK
        title:
          type: string
          description: Message description
          example: 'Movement updated correctly'
      description: Rest service billing response

    barringsDetailResponseDTO:
      required:
        - subscriptionId
        - appliedBarringsMaskCodes
      type: object
      properties:
        subscriptionId:
          type: integer
          format: int64
          description: Code string for subscription id
          example: 234234234
        appliedBarringsMaskCodes:
          type: array
          items:
            type: string
          description: applied barrings for subscription id
          example: [ DEBT_MOBILE_LP ]
      description: Rest service barrings detail response

    promotionUpdateResponseDTO:
      required:
        - code
        - title
      type: object
      properties:
        code:
          type: string
          description: Code string for fast identification
          example: OK
        title:
          type: string
          description: Message description
          example: 'Promotion updated correctly'
      description: Rest service billing response

    movementSuccessResponseDTO:
      required:
        - code
        - title
        - movement_id
      type: object
      properties:
        code:
          type: string
          description: Code string for fast identification
          example: CREATED
        title:
          type: string
          description: Message description
          example: 'Movement created correctly'
        movement_id:
          type: string
          description: Identifier of the created movement
          example: '8da2b117-ef72-413d-98ce-36d1eb544e44'
      description: Rest service billing response

    refundSuccessResponseDTO:
      required:
        - code
        - message
        - refund_id
      type: object
      properties:
        code:
          type: string
          description: Code string for fast identification
          example: CREATED
        title:
          type: string
          description: Message description
          example: 'Refund created correctly'
        refund_id:
          type: string
          description: Identifier of the created refund
          example: '8da2b117-ef72-413d-98ce-36d1eb544e44'
      description: Rest service billing response

    PromotionSuccessResponseDTO:
      required:
        - code
        - message
        - promotion_id
      type: object
      properties:
        code:
          type: string
          description: Code string for fast identification
          example: CREATED
        title:
          type: string
          description: Message description
          example: 'Promotion created correctly'
        promotion_id:
          type: string
          description: Identifier of the created refund
          example: '8da2b117-ef72-413d-98ce-36d1eb544e44'
      description: Rest service billing response
    createServiceRequestDTO:
      required:
        - service_details
      allOf:
        - $ref: '#/components/schemas/callbackDTO'
      type: object
      properties:
        service_id:
          type: string
        service_details:
          $ref: '#/components/schemas/serviceDetailsDTO'
          discriminator:
            propertyName: service_type
      description: Request to activate a service
    serviceCallbackDTO:
      required:
        - code
        - title
        - service_id
      type: object
      properties:
        code:
          type: string
          example: OK
        title:
          type: string
          example: Service was successfully created
        service_id:
          type: string
          example: 600000000
      description: Body request to callback operation
    serviceDetailsDTO:
      type: object
      oneOf:
        - $ref: '#/components/schemas/multisimServiceDTO'

    updateServiceDeviceRequestDTO:
      required:
        - category
        - new_service_device_details
      allOf:
        - $ref: '#/components/schemas/callbackDTO'
      type: object
      properties:
        category:
          type: string
          example: eSIM
          enum:
            - STB
            - SMARTWATCH
            - TABLET
            - ROUTER
            - PBX
            - SMARTPHONE
            - WIFI_EXTENDER
            - OTHER
            - SIM
            - eSIM
        new_service_device_details:
          $ref: '#/components/schemas/deviceDetailsDTO'
          discriminator:
            propertyName: category
      description: Request to update a service

    deviceDetailsDTO:
      type: object
      oneOf:
        - $ref: '#/components/schemas/eSIMDeviceDTO'

    eSIMDeviceDTO:
      type: object
      properties:
        iccid:
          type: string
          description: Circuit Card Identification Number associated to the eSIM
          example: 8934011411551283144
        eid:
          type: string
          description: eUICC Identifier associated to the eSIM
          example: 89033023312170000000005421143542


    multisimServiceDTO:
      type: object
      required:
        - secondary_eid
        - secondary_iccid
      properties:
        secondary_eid:
          type: string
        secondary_iccid:
          type: string

    updateMultisimServiceDTO:
      type: object
      required:
        - new_secondary_eid
        - new_secondary_iccid
      properties:
        new_secondary_eid:
          type: string
        new_secondary_iccid:
          type: string

    serviceTypeDTO:
      type: string
      enum:
        - multisim
        - security
        - tv
        - datasharing
        - mobile
        - applewatch
        - deviceinsurance
    callbackDTO:
      type: object
      required:
        - callback_success_url
        - callback_error_url
      properties:
        callback_success_url:
          type: string
          format: uri
          example: https://myserver.com/send/callback/here
        callback_error_url:
          type: string
          format: uri
          example: https://myserver.com/send/callback/here

    updateNetflixServiceRequestDTO:
      required:
        - offer_id
        - plan_type
        - transaction_id
      type: object
      properties:
        offer_id:
          type: string
          example: define
        plan_type:
          type: string
          example: define
        transaction_id:
          type: string
          example: define
      description: Request to update a netflix service

    simyoNotificationDTO:
      type: object
      properties:
        pai:
          type: string
          description: PAI
        netflixOfferId:
          type: string
          description: netflixOfferId
        changeDate:
          type: string
          description: changeDate

    updateNetflixServiceResponseDTO:
      required:
        - transaction_id
      type: object
      properties:
        transactionId:
          type: string
          example: define
      description: Request to update a netflix service

  parameters:
    Request-Correlation-Id:
      in: header
      name: Request-Correlation-Id
      required: false
      schema:
        type: string
        format: uuid
      description: Correlation Id for tracing (unique identifier)
    Request-Correlation-Id-Response:
      in: header
      name: Request-Correlation-Id
      required: false
      schema:
        type: string
      description: Workflow Id (unique identifier)
