openapi: 3.0.0
info:
  description: I am MasSubscriptions API. My intention is to provide a set of REST services for handling subscriptions and their related entities.
  version: 1.0.0
  title: MasSubscriptions
servers:
  - description: production
    url: 'https://subscriptions.masstack.com/v1/'
  - description: staging
    url: 'https://subscriptions.sta.masstack.com/v1/'
tags:
  - description: Access to subscriptions in an account bundle
    name: AccountBundles
  - description: Access to Apple Watch Subscriptions
    name: Apple Watch
  - description: Access to subscription credit limits
    name: Credit Limits
  - description: Access to subscriptions devices
    name: Devices
  - description: Access to fraud requests
    name: Fraud Requests
  - description: Access to free units packages
    name: FreeUnitsPackages
  - description: Access to promotions
    name: Promotions
  - description: Access to subscription segments
    name: Segments
  - description: Access to subscription commercial products
    name: Subscription Commercial Products
  - description: Access to subscriptions
    name: Subscriptions

paths:
  '/orgs/{org_id}/contracts':
    get:
      tags:
        - Contracts
      summary: Get contracts by parameter
      description: Get contracts providing certain search criteria
      operationId: getContractsByProperties
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: yoigo
        - name: subscription_id
          in: query
          description: Subscription unique identifier
          schema:
            type: string
          example: 26245435
        - name: account_bundle_id
          in: query
          description: Subscriptions bundle unique identifier
          schema:
            type: string
          example: 26245435
        - name: device_id
          in: query
          description: Subscription device unique identifier
          schema:
            type: string
          example: 26245435
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractSet'
        '404':
          description: A contract with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        default:
          description: Any other client or server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/account_bundles/{id}':
    get:
      tags:
        - AccountBundles
      summary: Get account bundle details for a given accountBundleId
      description: Returns details of an account bundle
      operationId: getAccountBundleById
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: masmovil
        - name: id
          in: path
          description: Account Bundle Id
          required: true
          schema:
            type: string
          example: 3821002
        - name: offset
          in: query
          description: Pagination offset
          required: false
          schema:
            type: integer
          example: 0
        - name: limit
          in: query
          description: Pagination limit
          required: false
          schema:
            type: integer
          example: 200
        - name: only_active_subscriptions
          in: query
          description: Whether only active subscriptions should be retrieved
          required: false
          schema:
            type: boolean
          example: false
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetAccountBundle'
        '404':
          description: A bundle with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"


  '/orgs/{org_id}/account_bundles/{account_bundle_id}/multisim/sell':
    post:
      tags:
        - AccountBundles
      summary: Starts the process of selling a multi-sim
      description: Starts the process of selling a multi-sim
      operationId: sellMultiSim
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: "masmovil"
        - name: account_bundle_id
          in: path
          description: account bundle identifier
          required: true
          schema:
            type: string
          example: "1"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SellMultiSimRequest'
            examples:
              sample1:
                value:
                  customer_id: 1234
                  account_id: 10096875
                  sale_details:
                    date: "2017-09-15T22:00:00Z"
                    delivery_method: "OFFLINE"
                    user_name: "test@test"
                    scoring:
                      id: "m"
                      value: ""
                    signature:
                      id: "t"
                      type: "BIOMETRIC"
                  commercial_product_id: "1"
                  main_subscription_id: 7024858
                  numeration_type: "NEW"
                  imsi: 214035453370793
                  iccid: 8934011411551283000
                  free_units_packages: [ { "id": "1" },{ "id": "2" } ]
                  promotions: [ { "id": "3" },{ "id": "4" } ]
      responses:
        '201':
          description: Sell process for multi-sim subscription successfully accepted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SellMultiSimResponse"
        '400':
          description: Invalid body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '404':
          description: A subscription or an account bundle with the specified ids was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/multisim/{id}/deactivate':
    post:
      tags:
        - AccountBundles
      summary: Starts the process of deactivating a multi-sim
      description: Starts the process of deactivating a multi-sim
      operationId: deactivateMultiSim
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: "masmovil"
        - name: id
          in: path
          description: subscription identifier
          required: true
          schema:
            type: string
          example: "1"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeactivateMultiSimRequest'
            examples:
              sample1:
                value:
                  deactivation_reason: 'Not_wanted'
                  deactivation_user: 'test@test.com'
                  requested_deactivation_date: "2023-03-15T22:00:00Z"

      responses:
        '202':
          description: Deactivation process for multi-sim subscription successfully accepted
          content: { }
        '400':
          description: Invalid body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '404':
          description: A subscription with the specified ids was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/subscriptions/{id}':
    get:
      tags:
        - Subscriptions
      summary: Get subscriptions details by subscription_id
      description: Get subscriptions details by subscription_id
      operationId: getSaasSubscriptionsById
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: yoigo
        - name: id
          in: path
          description: subscription unique identifier
          required: true
          schema:
            type: string
          example: 5652763
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetSubscription'
        '404':
          description: A subscription with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

    patch:
      tags:
        - Subscriptions
      summary: Patch subscription by subscription_id
      description: Patch subscription details by subscription_id
      operationId: patchSaasSubscriptionsById
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: yoigo
        - name: id
          in: path
          description: subscription unique identifier
          required: true
          schema:
            type: string
          example: 5652763
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchSubscription'
      responses:
        '202':
          description: subscription modification successfully done
          content: { }
        '400':
          description: Invalid body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '404':
          description: A subscription with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '409':
          description: The request could not be completed due to a conflict with the current state of the resource
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/subscriptions':
    get:
      tags:
        - Subscriptions
      summary: Get subscriptions details by filter
      description: Get subscriptions details by filter. Possible filters are
        <ul>
        <li> MSISDN -> Find mobile subscriptions by msisdn </li>
        <li> SUBSCRIPTIONEMAIL -> Find TV subscriptions SubscriptionEmail </li>
        <li> LANDLINENUMBER -> Find landline subscriptions by LandlineNumber </li>
        <li> EXTERNALID -> Find security subscriptions by ExternalID </li>
        <li> DEVICEINSURANCE -> Find device insurance subscriptions by IdentificationNr (corresponds to the SubscriptionTerminalId) </li>
        <li> INSURANCEPOLICYID -> Find device insurance subscriptions by InsurancePolicyId </li>
        </ul>
      operationId: getSaasSubscriptions
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: yoigo
        - name: filter_type
          in: query
          description: Filter type used for getting subscriptions
          required: true
          schema:
            type: string
            enum: [ MSISDN, SUBSCRIPTIONEMAIL, LANDLINENUMBER, EXTERNALID, DEVICEINSURANCE, INSURANCEPOLICYID ]
            default: MSISDN
        - name: filter_value
          in: query
          description: The value to apply to the filter_type. Should match what was in the filter, i.e. if filtering on subscription_id use a subscription_id.
          required: true
          schema:
            type: string
          example: 345652
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GetSubscription'
        '404':
          description: A subscription with the specified criteria was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/subscriptions/{id}/promotions':
    post:
      tags:
        - Promotions
      summary: Create promotion
      description: Create promotion
      operationId: postPromotion
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: masmovil
        - name: id
          in: path
          description: Subscription Id
          required: true
          schema:
            type: string
          example: 3821002
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostPromotion'
      responses:
        '201':
          description: Promotion creation successfully done
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostPromotionResponse'
        '400':
          description: Invalid body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '404':
          description: A subscription with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '409':
          description: Conflict with the current status
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/subscriptions/{id}/promotions/{promotion_id}/deactivate':
    post:
      tags:
        - Promotions
      summary: Deactivate promotion
      description: Deactivate promotion
      operationId: postPromotionDeactivate
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: masmovil
        - name: id
          in: path
          description: Subscription Id
          required: true
          schema:
            type: string
          example: 3821002
        - name: promotion_id
          in: path
          description: Promotion Id
          required: true
          schema:
            type: string
          example: 6736
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostPromotionDeactivate'
      responses:
        '204':
          description: promotion deactivation successfully done
          content: { }
        '400':
          description: Invalid body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '404':
          description: A subscription or promotion with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '409':
          description: The request could not be completed due to a conflict with the current state of the resource
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/subscriptions/{id}/credit_limits':
    get:
      tags:
        - Credit Limits
      summary: Get subscription credit limits by subscription id
      description: Get subscription credit limits by subscription id
      operationId: getCreditLimits
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: masmovil
        - name: id
          in: path
          description: Subscription Id
          required: true
          schema:
            type: string
          example: 3821002
      responses:
        '200':
          description: OK. Empty list if the correspondent subscription does not have credit limits
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GetCreditLimit'
        '400':
          description: Wrong subscription type
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '404':
          description: A subscription with the specified criteria was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
    post:
      tags:
        - Credit Limits
      summary: Create subscription credit limits for a given subscription
      description: Create subscription credit limits for a given subscription
      operationId: postCreditLimits
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: masmovil
        - name: id
          in: path
          description: Subscription Id
          required: true
          schema:
            type: string
          example: 3821002
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostCreditLimits'
      responses:
        '201':
          description: Credit Limits creation successfully done
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PostCreditLimitsResponse'
        '400':
          description: Invalid body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '404':
          description: A subscription with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
    patch:
      tags:
        - Credit Limits
      summary: Modify subscription credit limits by subscription id
      description: Modify subscription credit limits by subscription id
      operationId: patchCreditLimitBySubscriptionId
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: masmovil
        - name: id
          in: path
          description: Subscription Id
          required: true
          schema:
            type: string
          example: 3821002
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchCreditLimits'
      responses:
        '202':
          description: subscription credit limit modification successfully done
          content: { }
        '400':
          description: Invalid body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '404':
          description: A subscription with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '409':
          description: Modification not allowed because of inconsistency with the total credit limit value. This value must be greater or equal than the maximum of the other credit limits
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/credit_limits':
    get:
      tags:
        - Credit Limits
      summary: Get default credit limits by org name
      description: Get default credit limits by org name
      operationId: getDefaultCreditLimits
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: masmovil
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DefaultCreditLimit'
        '404':
          description: An org with the specified criteria was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/subscriptions/{id}/free_units_packages':
    get:
      tags:
        - FreeUnitsPackages
      summary: Get subscription free units packages by subscription id
      description: Get subscription free units packages by subscription id
      operationId: getFreeUnitsPackages
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: masmovil
        - name: id
          in: path
          description: Subscription Id
          required: true
          schema:
            type: string
          example: 3821002
      responses:
        '200':
          description: OK. Empty list if the correspondent subscription does not have free units packages
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GetFreeUnitsPackage'
        '404':
          description: A subscription with the specified criteria was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/fraud_requests':
    get:
      tags:
        - Fraud Requests
      summary: Get filtered fraud requests details
      description: Get filtered fraud requests details by query params. Possible options are
        <ul>
        <li> sale_id </li>
        <li> account_id and optional risk_decision </li>
        <li> subscription_id and optional risk_decision </li>
        <li> customer_id and optional risk_decision </li>
        <li> date_range and mandatory risk_decision X or R. date_range must not be greater than 31 days </li>
        </ul>
      operationId: getSaasFraudRequests
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: yoigo
        - name: sale_id
          in: query
          description: SaleId filter
          required: false
          schema:
            type: string
            example: -345652
        - name: subscription_id
          in: query
          description: SubscriptionId filter
          required: false
          schema:
            type: string
            example: 12345
        - name: customer_id
          in: query
          description: CustomerId filter
          required: false
          schema:
            type: string
            example: 12345
        - name: account_id
          in: query
          description: AccountId filter
          required: false
          schema:
            type: string
            example: 12345
        - name: risk_decision
          in: query
          description: RiskDecision status filter
          required: false
          schema:
            type: string
            description: fraud request risk decision
              <ul>
              <li> X -> Doc required </li>
              <li> A -> OK  </li>
              <li> D -> Cancelled </li>
              <li> R -> KO </li>
              </ul>
            example: A
            enum:
              - A
              - X
              - D
              - R
        - name: date_range
          in: query
          description: Date range filter. Must match pattern dd/MM/yyyy,dd/MM/yyyy
          required: false
          schema:
            type: string
            example: 24/06/2019,25/07/2019
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GetFraudRequest'
        '404':
          description: A fraud request with the specified criteria was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/fraud_requests/{id}':
    patch:
      tags:
        - Fraud Requests
      summary: Patch fraud request by fraud_request_id
      description: Patch fraud request by fraud_request_id
      operationId: patchSaasFraudRequestsById
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: yoigo
        - name: id
          in: path
          description: fraud request unique identifier
          required: true
          schema:
            type: string
          example: 5652763
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchFraudRequest'
      responses:
        '202':
          description: fraud request modification successfully received
          content: { }
        '400':
          description: Invalid body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '404':
          description: A fraud request with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '409':
          description: The request could not be completed due to a conflict with the current state of the resource
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/subscriptions/{id}/devices':
    get:
      tags:
        - Devices
      summary: Get subscription devices details by subscription_id
      description: Get subscription devices details by subscription_id. For now, it only returns sims details no matter if category filter is used or not. It will evolve for returning all types of devices
      operationId: getSaasSubscriptionsDevices
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: yoigo
        - name: id
          in: path
          description: subscription unique identifier
          required: true
          schema:
            type: string
          example: 5652763
        - name: category
          in: query
          description: device category filter
          required: false
          schema:
            type: string
            enum: [ SIM, OTHER ]
            default: SIM
        - name: only_active
          in: query
          description: boolean to indicate if just active device details are required. For retrieving pending and already processed device change requests, use false value
          schema:
            type: boolean
            default: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GetSubscriptionDevice'
        '404':
          description: A subscription with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/subscriptions/{id}/devices/{device_id}':
    get:
      tags:
        - Devices
      summary: Get subscription device by subscription device id
      description: Get subscription device by subscription device id
      operationId: getSaasSubscriptionDevicesById
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: yoigo
        - name: id
          in: path
          description: subscription unique identifier
          required: true
          schema:
            type: string
          example: 5652763
        - name: device_id
          in: path
          description: subscription device unique identifier
          required: true
          schema:
            type: string
          example: 5652763
        - name: only_active
          in: query
          description: boolean to indicate if just active device details are required. For retrieving pending and already processed device change requests, use false value
          schema:
            type: boolean
            default: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetSubscriptionDevice'
        '404':
          description: A subscription or device with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/subscriptions/{id}/devices/{device_id}/replacement':
    post:
      tags:
        - Devices
      summary: Post subscription device replacement operation
      description: Post subscription device replacement operation (i.e. sim replacement request)
      operationId: replaceSimDevice
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: yoigo
        - name: id
          in: path
          description: subscription unique identifier
          required: true
          schema:
            type: string
          example: 5652763
        - name: device_id
          in: path
          description: subscription device unique identifier
          required: true
          schema:
            type: string
          example: 5652763
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchSubscriptionDevice'
      responses:
        '202':
          description: subscription device change request successfully received
          content: { }
        '400':
          description: Invalid body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '404':
          description: A subscription or a subscription device with the specified ids were not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '409':
          description: The request could not be completed due to a conflict with the current state of the resource
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/subscriptions/{id}/segments':
    get:
      tags:
        - Segments
      summary: Get subscription segments by subscription id
      description: Get subscription segments by subscription id
      operationId: getSubscriptionSegments
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: yoigo
        - name: id
          in: path
          description: subscription unique identifier
          required: true
          schema:
            type: string
          example: 5652763
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetSubscriptionSegments'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

    post:
      tags:
        - Segments
      summary: Create segments
      description: Create segments
      operationId: postSubscriptionSegments
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: masmovil
        - name: id
          in: path
          description: Subscription Id
          required: true
          schema:
            type: string
          example: 3821002
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostSegments'
      responses:
        '204':
          description: Segments creation successfully done
        '400':
          description: Invalid body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '404':
          description: A subscription with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/subscriptions/{id}/commercial_product_history':
    get:
      description: Get commercial product history by subscription id
      operationId: getCommercialProductHistory
      parameters:
        - description: Organization name
          example: yoigo
          explode: false
          in: path
          name: org_id
          required: true
          schema:
            type: string
          style: simple
        - description: subscription unique identifier
          example: 5652763
          explode: false
          in: path
          name: id
          required: true
          schema:
            type: string
          style: simple
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetCommercialProductsHistory'
          description: OK
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
          description: Unexpected error
      summary: Get subscription segments by subscription id
      tags:
        - Subscription Commercial Products

  '/orgs/{org_id}/subscriptions/{id}/shippings':
    get:
      tags:
        - Subscriptions
      summary: Consult all logistics shipments associated with a subscriptionId with the possibility of searching by time range
      description: Get subscription shipping by subscription id and requested date
      operationId: getSubscriptionShipping
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: "masmovil"
        - name: id
          in: path
          description: subscription unique identifier
          required: true
          schema:
            type: string
          example: 5652763
          explode: false
          style: simple
        - name: requested_date
          in: query
          schema:
            type: string
            format: date-time
          description: requested date
          example: "2017-09-15T22:00:00Z"
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetSubscriptionShippings'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/apple_watch/sell':
    post:
      tags:
        - Apple Watch
      summary: Starts the process of selling an Apple Watch
      description: Starts the process of selling an Apple Watch
      operationId: sellAppleWatch
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: "masmovil"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SellAppleWatchRequest'
            examples:
              sample1:
                value:
                  main_subscription_id: "7024858"
                  commercial_product_id: "1"
                  imsi: "214035453370793"
                  iccid: "8934011411551283000"
                  free_units_packages: [ { "id": "1"},{ "id": "2"} ]
                  promotions: [ { "id": "3" },{ "id": "4" } ]
      responses:
        '201':
          description: Sell process for AppleWatch subscription successfully accepted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SellAppleWatchResponse"
        '400':
          description: Invalid body
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '404':
          description: A subscription or an account bundle with the specified ids was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

  '/orgs/{org_id}/apple_watch/{id}/deactivate':
    post:
      tags:
        - Apple Watch
      summary: Deactivate Apple Watch subscription for a given subscriptionId
      description: Deactivate Apple Watch subscription for a given subscriptionId
      operationId: deactivateAppleWatchSubscriptionById
      parameters:
        - name: org_id
          in: path
          description: Organization name
          required: true
          schema:
            type: string
          example: masmovil
        - name: id
          in: path
          description: Subscription Id
          required: true
          schema:
            type: string
          example: 3821002
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AppleWatchDeactivateSubscriptionRequest'
      responses:
        '202':
          description: Apple Watch subscription successfully cancelled
        '404':
          description: A subscription with the specified id was not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorMessage"

components:
  schemas:
    ContractSet:
      type: object
      properties:
        contracts:
          type: array
          items:
            $ref: '#/components/schemas/Contract'

    Contract:
      type: object
      required:
        - url_expiration_date
        - public_url
        - media_type
        - type
        - status
        - created_date
        - contract_id
      properties:
        url_expiration_date:
          type: string
          description: Expiration date for the supplied link. Format according to ISO 8601
          readOnly: true
          format: date-time
          example: 2023-01-27T03:44:52.000Z
        public_url:
          type: string
          readOnly: true
          description: Link to download the contract
          example: https://storage.googleapis.com/mas-documents-prod/cbd2e693-d71a-4cee-8313-1972acc0394d
        media_type:
          type: string
          readOnly: true
          description: Type of the provided file
          example: application/pdf
        name:
          type: string
          description: Name of the document
          readOnly: true
          example: my_doc_name
        type:
          type: string
          description: Type of contract
          readOnly: true
          x-extensible-enum:
            - CONVERGENT
            - ONLYMOBILE
            - TV
            - TERMINAL
            - "SIM REPLACEMENT"
            - "CHANGE ADDRESS"
            - "BUNDLE MIGRATION"
            - "CHANGE TECHNOLOGY"
            - "UNFINANCED TERMINAL"
            - "FINANCED TERMINAL"
            - "BUNDLE ADDLINE"
            - "CHANGE OWNER"
            - "REFINANCED TERMINAL"
            - "DEVICE RETURN"
          example: ONLYMOBILE
        status:
          type: string
          description: Status of the contract
          readOnly: true
          example: SIGNATURE EXPIRED
        created_date:
          type: string
          description: Creation date. Format according to ISO 8601
          readOnly: true
          format: date-time
          example: 2023-01-27T03:44:52.000Z
        contract_id:
          type: string
          description: Contract unique identifier
          readOnly: true
          example: ce2f20cb-35df-4ffe-bca6-c0ed0c28cb39

    GetSubscriptionShippings:
      type: array
      items:
        $ref: '#/components/schemas/GetSubscriptionShipping'

    GetSubscriptionShipping:
      type: object
      properties:
        account_id:
          type: integer
          format: int32
          description: internal unique identifier of the billable account the account bundle belongs to
          example: 1233094
        created_date:
          type: string
          description: created date
          format: date-time
          example: "2017-09-15T22:00:00Z"
        requested_date:
          type: string
          description: requested date
          format: date-time
          example: "2017-09-15T22:00:00Z"
        shipping_date:
          type: string
          description: shipping date
          format: date
          example: "2017-09-15T22:00:00Z"
        item_number:
          type: integer
          format: int32
          example: 9806253
        account_expedition_id:
          type: integer
          format: int32
          description: internal unique identifier of the account expedition
          example: 1233094
        logistics_id:
          type: string
          description: internal unique identifier of the logistic
          example: 1233094
        status:
          type: string
          description: subscription shipping status
          example: CONFIRMED
        address:
          type: string
          description: address > $address + $city + $state + $zipcode
          example: Carrer del Parc, 4-8, El Pont de Suert, Lleida, 25520
        applicable_cost:
          $ref: '#/components/schemas/ApplicableCost'
        product_type:
          type: string
          description: product type
          example: SIM
        msisdn:
          type: string
          description: Reserved sim through devices-api in previous call
          example: 612121212
        first_name:
          type: string
          description: user name performing the operation
          example: "test"
        last_name:
          type: string
          description: user last name performing the operation
          example: "test"
        document_number:
          type: string
          description: user document number performing the operation
          example: "Y4444444"
        email:
          type: string
          description: user email performing the operation
          example: "test@test"
        terminal_name:
          type: string
          description: name of the corresponding terminal
          example: "terminal name"
        terminal_model:
          type: string
          description: name of the terminal model
          example: "16 blue 256GB"

    ApplicableCost:
      type: object
      properties:
        amount:
          type: number
          description: amount
          format: double
          example: 1.00
        type:
          type: string
          description: Cost type
          example: PAY_ON_DELIVERY
          enum:
            - PAY_ON_DELIVERY
            - PAID_IN_ADVANCE

    GetAccountBundle:
      allOf:
        - $ref: '#/components/schemas/AccountBundle'
        - type: object
          required:
            - id
            - account_id
            - status
            - bundle_id

    AccountBundle:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          description: Internal CRM unique account bundle identifier
          example: 1233094
        account_id:
          type: string
          description: internal unique identifier of the billable account the account bundle belongs to
          example: 1233094
        status:
          $ref: "#/components/schemas/SubscriptionStatus"
        activation_date:
          type: string
          description: activation date (Mysim ActivateDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        deactivation_date:
          type: string
          description: deactivation date (Mysim EndDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        cancellation_date:
          type: string
          description: deactivation date (Mysim EndDate for deactivated subscriptions which have not been activated)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        bundle_id:
          type: string
          description: catalogue bundle id (Mysim accountBundleCfgId)
          example: 3072
        bundled_subscriptions:
          type: array
          items:
            $ref: '#/components/schemas/BundledSubscription'

    BundledSubscription:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          description: Internal CRM unique bundled subscription identifier
          example: 1233094
        subscription_id:
          type: string
          description: internal subscription id
          example: 3821002
        status:
          $ref: "#/components/schemas/SubscriptionStatus"
        subscription_type:
          $ref: '#/components/schemas/SubscriptionType'
        commercial_product_id:
          type: string
          description: commercial product id
          example: 3073
        creation_date:
          type: string
          description: activation date (Mysim CreatedDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        deactivation_date:
          type: string
          description: deactivation date (Mysim EndDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        is_main:
          type: boolean

    SellMultiSimRequest:
      type: object
      required:
        - customer_id
        - account_id
        - sale_details
        - commercial_product_id
        - main_subscription_id
        - numeration_type
        - imsi
        - iccid
      properties:
        customer_id:
          type: string
          description: Customer identifier
          example: 1234
        account_id:
          type: string
          description: account identifier
          example: 10096875
        sale_details:
          type: object
          required:
            - date
            - delivery_method
          properties:
            date:
              type: string
              description: sale date
              format: date-time
              example: "2017-09-15T22:00:00Z"
            user_name:
              type: string
              description: Optional user name
              example: "test@test"
            delivery_method:
              type: string
              description: Sale delivery method
              example: OFFLINE
              enum:
                - OFFLINE
                - ONLINE
            scoring:
              type: object
              properties:
                id:
                  type: string
                  description: Sale scoring identifier
                value:
                  type: string
                  description: Sale scoring value
            signature:
              type: object
              properties:
                id:
                  type: string
                  description: Sale signature identifier
                  minLength: 1
                type:
                  type: string
                  description: Sale signature type
                  example: BIOMETRIC
                  enum:
                    - PAPER
                    - BIOMETRIC
                    - OTP
        commercial_product_id:
          type: string
          example: 1
          description: Commercial product identifier
        main_subscription_id:
          type: string
          description: Subscription identifier from an existent mobile subscription
          example: 5331402
        numeration_type:
          $ref: "#/components/schemas/NumerationType"
        imsi:
          type: string
          description: International Mobile Subscriber Identity associated to the mobile subscription
          example: 214035453370793
        iccid:
          type: string
          description: Circuit Card Identification Number associated to the SIM card
          example: 8934011411551283144
        free_units_packages:
          type: array
          description: list of free units packages included in the sale
          items:
            $ref: '#/components/schemas/SellMultiSimRequestFreeUnitsPackage'
        promotions:
          type: array
          description: list of promotions included in the sale
          items:
            $ref: '#/components/schemas/SellMultiSimRequestPromotion'

    SellMultiSimResponse:
      type: object
      properties:
        subscription_id:
          type: string
          description: subscription id created in the sale
          example: 3819912

    DeactivateMultiSimRequest:
      type: object
      required:
        - deactivation_reason
      properties:
        deactivation_reason:
          type: string
          description: Deactivation reason text or id as a string
          example: "1234"
        deactivation_user:
          type: string
          description: User that requests the deactivation
          example: "test@test.com"
        requested_deactivation_date:
          type: string
          description: deactivation date
          format: date-time
          example: "2017-09-15T22:00:00Z"

    CancelActivationSubscriptionRequest:
      type: object
      required:
        - cancellation_reason
      properties:
        cancellation_reason:
          type: string
          description: Cancellation reason text or id as a string
          example: "BAJA VOLUNTARIA"
        cancellation_user:
          type: string
          description: User that requests the cancellation
          example: "test@test.com"
        requested_cancellation_date:
          type: string
          description: cancellation date
          format: date-time
          example: "2017-09-15T22:00:00Z"

    GetSubscription:
      allOf:
        - $ref: '#/components/schemas/Subscription'
        - type: object
          required:
            - id
            - account_id
            - sale_date
            - sale_type
            - commercial_product_id
            - billing_type
            - subscription_type
            - current_status

    Subscription:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          description: Internal CRM unique subscription identifier
          example: 1233094
        account_id:
          type: string
          description: internal unique identifier of the billable account the subscripton belongs to
          example: 1233094
        account_bundles:
          type: array
          description: array of account bundles the subscription has been associated to
          items:
            $ref: '#/components/schemas/SubsAccountBundle'
        sale_date:
          type: string
          description: sale date
          format: date-time
          example: "2017-09-15T22:00:00Z"
        sale_type:
          type: string
          description: subscription sale type
          example: SALE
          enum:
            - SALE
            - ADDSUBSCRIPTIONTOBUNDLE
            - MIGRATION
        user_name:
          type: string
          description: user name of the user performing the subscription operation
          example: test@test.com
        commercial_product_id:
          type: string
          description: unique identifier of the commercial product associated to the subscription
          example: 3072
        billing_type:
          type: string
          description: billing type name
          example: POSTPAID
          enum:
            - POSTPAID
            - PREPAID
        subscription_type:
          $ref: '#/components/schemas/SubscriptionType'
        subscription_additional_details:
          $ref: '#/components/schemas/DetailedSubscription'
          discriminator:
            propertyName: subscription_type
        addresses:
          type: array
          description: array of addresses associated to the subscription
          items:
            $ref: '#/components/schemas/Address'
        current_status:
          $ref: '#/components/schemas/SubscriptionStatus'
        current_status_date:
          type: string
          description: pre-activation date
          format: date-time
          example: "2017-09-15T22:00:00Z"
        cancellation_reason:
          type: object
          additionalProperties: false
          description: cancellation reason
          properties:
            deactive_motive:
              type: string
              description: deactive motive from apollo
              example: "CANCELACION VENTA"
            reason:
              type: string
              description: reason why subscription was cancelled or deactivated
              example: "SUBSCRIPTION_NOT_ACTIVATED_AFTER_WAITING_TIME"
        status_history:
          type: array
          description: array of status changes associated to the subscription
          items:
            $ref: '#/components/schemas/StatusChange'
        contract_documents:
          type: array
          description: array of contract document's ids related to the subscription
          items:
            type: string

    SubsAccountBundle:
      type: object
      additionalProperties: false
      properties:
        account_bundle_id:
          type: string
          description: Internal CRM unique account bundle identifier
          example: 1233094
        status:
          $ref: '#/components/schemas/SubscriptionStatus'
        creation_date:
          type: string
          description: activation date (Mysim CreatedDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        deactivation_date:
          type: string
          description: deactivation date (Mysim EndDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"

    StatusChange:
      type: object
      additionalProperties: false
      required:
        - status_date
        - status
      properties:
        status_date:
          type: string
          description: pre-activation date
          format: date-time
          example: "2017-09-15T22:00:00Z"
        status:
          $ref: '#/components/schemas/SubscriptionStatus'

    SecuritySubscription:
      type: object
      additionalProperties: false
      properties:
        external_id:
          type: string
          description: Security subscription id
          example: 11111111
        kit_type:
          type: string
          description: type of the installed kit
          example: A-MAGNETICO
        kit_type_description:
          type: string
          description: description of the installed kit
          example: CONTACTO MAGNETICO PARA PUERTAS
        third_party_address:
          $ref: '#/components/schemas/Address'
        third_party_work_order_status:
          type: string
          description: work order status on 3rd party side
          example: INSTALACION TERMINADA
        third_party_installation_status:
          type: string
          description: installation status on 3rd party side
          example: INSTALACION TERMINADA
        third_party_contract_status:
          type: string
          description: contract status on 3rd party side
          example: ACTIVO
        installation_date:
          type: string
          description: installation date
          format: date
          example: "2017-09-15"
        nxt_invoice_cfee_netamo:
          type: number
          format: double
          example: 8.264463
        nxt_invoice_ofee_netamo:
          type: number
          format: double
          example: 8.264463
        total_stay_time:
          type: number
          format: int32
          example: 24
        stay_period:
          type: number
          format: int32
          example: 24
        total_stay_cost:
          type: number
          format: double
          example: 400.000000
        stay_cost:
          type: number
          format: double
          example: 400.000000
        no_return_cost:
          type: number
          format: double
          example: 400.000000
        install_comp:
          type: array
          items:
            $ref: '#/components/schemas/InstallComp'

    TvSubscription:
      type: object
      additionalProperties: false
      properties:
        requires_install_tech_support:
          type: boolean
          description: Installation with technical support flag
          example: false
        is_tech_support_billable:
          type: boolean
          description: Technical support billable flag
          example: false
        registration_email:
          type: string
          description: Email associated to the Tv subscription
          example: test1@test.com
        payer_identity_document:
          type: string
          description: TV subscription payer identification number
          example: 11111111A

    DataSharingSubscription:
      type: object
      additionalProperties: false
      properties:
        data_sharing_free_units_packages:
          type: array
          items:
            $ref: '#/components/schemas/SharingFreeUnitsPackage'
        data_sharing_members:
          type: array
          items:
            $ref: '#/components/schemas/SubscriptionMember'
          description: Data sharing subscription id members
        mandatory_units:
          type: number
          format: double
          description: Shared units coming from mandatory free units packages (tariff units)
          example: 8.264463
        optional_one_time_units:
          type: number
          format: double
          description: Shared units coming from optional one time free units packages
          example: 8.264463
        optional_recurring_units:
          type: number
          format: double
          description: Shared units coming from optional recurring free units packages
          example: 8.264463
        network_group_id:
          type: string
          description: Network group id
          example: masmovil1233094

    MobileSubscription:
      type: object
      additionalProperties: false
      properties:
        msisdn:
          type: string
          description: Mobile number associated to subscription
          example: 666777999
        numeration_type:
          $ref: "#/components/schemas/NumerationType"
        imsi:
          type: string
          description: International Mobile Subscriber Identity associated to the mobile subscription
          example: 214035453370793
        iccid:
          type: string
          description: Circuit Card Identification Number associated to the SIM card
          example: 8934011411551283144
        associated_multi_sim_subscriptions:
          type: array
          items:
            $ref: "#/components/schemas/AssociatedMultiSimSubscription"
          description: MultiSim subscriptions associated to the Mobile subscription
        associated_apple_watch_subscriptions:
          type: array
          items:
            $ref: "#/components/schemas/AssociatedAppleWatchSubscription"
          description: Apple Watch subscriptions associated to the Mobile subscription

    LandlineSubscription:
      type: object
      additionalProperties: false
      properties:
        landline_number:
          type: string
          description: Landline number associated to subscription
          example: 666777999
        numeration_type:
          $ref: "#/components/schemas/NumerationType"
        technology:
          type: string
          description: technology associated to the landline subscription. Mapping with Mysim model
            <ul>
            <li> SubscriptionType = 3 -> ANALOG </li>
            <li> SubscriptionType = 4 -> DIGITAL </li>
            </ul>
          example: ANALOG
          enum:
            - ANALOG
            - DIGITAL

    BroadbandSubscription:
      type: object
      additionalProperties: false
      properties:
        requires_install_tech_support:
          type: boolean
          description: Installation with technical support flag
          example: false
        is_tech_support_billable:
          type: boolean
          description: Technical support billable flag
          example: false
        territory_owner:
          type: string
          description: territory owner associated to the broadband subscription. Obtained from the correspondent AccountBundle within Mysim
          example: FIBMM02
        broadband_technology:
          type: string
          description: technology associated to the broadband subscription. Mapping with Mysim model
            <ul>
            <li> SubscriptionType = 5 -> ADSL </li>
            <li> SubscriptionType = 6 -> FTTH </li>
            </ul>
          example: ADSL
          enum:
            - ADSL
            - FTTH
        access_reuse_in_activation:
          type: boolean
          description: notifies when a subscription is reusing a previous access from another client
          example: false
        access_reuse_in_deactivation:
          type: boolean
          description: notifies when an access is being reused by another next client after the deactivation of the subscription
          example: false

    MultiSimSubscription:
      type: object
      additionalProperties: false
      required:
        - mainSubscriptionId
      properties:
        msisdn:
          type: string
          description: Mobile number associated to subscription
          example: 666777999
        numeration_type:
          $ref: "#/components/schemas/NumerationType"
        imsi:
          type: string
          description: International Mobile Subscriber Identity associated to the mobile subscription
          example: 214035453370793
        iccid:
          type: string
          description: Circuit Card Identification Number associated to the SIM card
          example: 8934011411551283144
        mainSubscriptionId:
          type: string
          description: Internal CRM unique subscription identifier
          example: 1233094

    AppleWatchSubscription:
      type: object
      additionalProperties: false
      required:
        - mainSubscriptionId
      properties:
        msisdn:
          type: string
          description: Mobile number associated to subscription
          example: 666777999
        imsi:
          type: string
          description: International Mobile Subscriber Identity associated to the mobile subscription
          example: 214035453370793
        iccid:
          type: string
          description: |
            ICCID stands for Integrated Circuit Card Identifier. It is a serial number corresponding to the SIM card installed in a connected device
          example: 21403545337079321403545337079311
        mainSubscriptionId:
          type: string
          description: Internal CRM unique subscription identifier
          example: 1233094

    TerminateSubscriptionStatusRequest:
      type: object
      additionalProperties: false
      required:
        - status_change_user
        - status_change_reason
      properties:
        status_change_user:
          type: string
          description: user name of the user performing the subscription status change (Mysim user login)
          example: test@test.com
        status_change_reason:
          type: string
          description: subscription status change reason
          example: customer request
        requested_status_change_date:
          type: string
          description: date when the status change must be effective
          format: date-time
          example: "2017-09-15T22:00:00Z"

    AssociatedMultiSimSubscription:
      type: object
      additionalProperties: false
      properties:
        msisdn:
          type: string
          description: Mobile number associated to subscription
          example: 666777999
        numeration_type:
          $ref: "#/components/schemas/NumerationType"
        imsi:
          type: string
          description: International Mobile Subscriber Identity associated to the mobile subscription
          example: 214035453370793
        iccid:
          type: string
          description: Circuit Card Identification Number associated to the SIM card
          example: 8934011411551283144
        subscription_id:
          type: string
          description: Internal CRM unique subscription identifier
          example: 1233094
        status:
          $ref: '#/components/schemas/SubscriptionStatus'

    AssociatedAppleWatchSubscription:
      type: object
      additionalProperties: false
      properties:
        msisdn:
          type: string
          description: Mobile number associated to subscription
          example: 666777999
        imsi:
          type: string
          description: International Mobile Subscriber Identity associated to the mobile subscription
          example: 214035453370793
        iccid:
          type: string
          description: |
            ICCID stands for Integrated Circuit Card Identifier. It is a serial number corresponding to the SIM card installed in a connected device
          example: 21403545337079321403545337079311
        subscription_id:
          type: string
          description: Internal CRM unique subscription identifier
          example: 1233094
        status:
          $ref: "#/components/schemas/SubscriptionStatus"

    DeviceInsuranceSubscription:
      type: object
      additionalProperties: false
      required:
        - subscription_device_id
      properties:
        subscription_device_id:
          type: string
          description: Id of the subscription device associated to the insurance
          example: 7367286
        request_id:
          type: string
          description: Id of the device insurance policy request, assigned by BIBE
          example: 7367286
        insurance_policy_id:
          type: string
          description: Id of the device insurance policy, assigned by BIBE
          example: 7367286
        insurance_monthly_fee:
          type: number
          format: double
          description: Insurance monthly fee
          example: 8.264463
        insurance_annual_fee:
          type: number
          format: double
          description: Insurance annual fee
          example: 8.264463
        deductible_included:
          type: boolean
          description: Indicates if the insurance policy includes a deductible amount
          example: false
        deductible_fee:
          type: number
          format: double
          description: Insurance deductible fee
          example: 8.264463
        theft_included:
          type: boolean
          description: Indicates if the insurance policy includes theft coverage
          example: false
        serial_number:
          type: string
          description: serial number
          example: false
        brand:
          type: string
          description: brand of the insured device
          example: false
        model:
          type: string
          description: model of the insured device
          example: false

    NetflixSubscription:
      type: object
      additionalProperties: false
      properties:
        external_id:
          type: string
          description: PAI associated to the subscription
          example: 7367286
        email:
          type: string
          description: Email associated to the subsbcription (not known for now)
          example: test@gmail.com

    InstallComp:
      type: object
      additionalProperties: false
      properties:
        item_cd:
          type: string
          description: installed component
          example: A-MAGNETICO
        item_desc:
          type: string
          description: installed component description
          example: CONTACTO MAGNETICO PARA PUERTAS
        item_quantity:
          type: number
          format: int32
          description: number of units installed
          example: 1

    Address:
      type: object
      additionalProperties: false
      properties:
        address_type:
          type: string
          description: Address type
          example: INSTALLATION
          enum:
            - BILLING
            - INSTALLATION
            - CONTACT
            - SHIPMENT
        address_lines:
          type: array
          description: Address information detail
          items:
            $ref: '#/components/schemas/AddressLine'
        contact_details:
          $ref: '#/components/schemas/AddressContact'

    AddressContact:
      type: object
      additionalProperties: false
      properties:
        contact_name:
          type: string
          description: Address contact name
        contact_phone_1:
          type: string
          description: Address contact phone 1
        contact_phone_2:
          type: string
          description: Address contact phone 2
        contact_email_address:
          type: string
          description: Address contact email
        contact_identity_document:
          type: string
          description: Address contact identity document
        additional_details:
          type: string
          description: Address additional details

    AddressLine:
      type: object
      additionalProperties: false
      properties:
        address_line_name:
          type: string
          description: Address line name
          example: Street
          enum:
            - Street
            - StreetType
            - Number
            - Bis
            - City
            - Gescal
            - District
            - Block
            - Stair
            - Floor
            - Letter
            - ZipCode
            - Province
            - State
            - Country
            - AddressId
            - IsUnoccupiedPair
            - additionalDetails
        address_line_value:
          type: string
          description: Address line value (i.e.stree name, number value...)
          example: Street name

    PatchSubscription:
      type: object
      additionalProperties: false
      required:
        - subscription_type
      properties:
        subscription_type:
          $ref: '#/components/schemas/SubscriptionType'
        status_change:
          $ref: '#/components/schemas/PatchStatusChange'

    PatchStatusChange:
      type: object
      additionalProperties: false
      properties:
        status:
          $ref: '#/components/schemas/SubscriptionStatus'
        status_change_user:
          type: string
          description: user name of the user performing the subscription status change (Mysim user login)
          example: test@test.com
        status_change_reason:
          type: string
          description: subscription status change reason
          example: customer request
        requested_status_change_date:
          type: string
          description: date when the status change must be effective
          format: date-time
          example: "2017-09-15T22:00:00Z"

    Terms:
      type: object
      additionalProperties: false
      required:
        - terms_id
        - start_date
        - end_date
        - type
      properties:
        id:
          type: string
          description: Internal CRM unique subscription terms identifier (SubscriptionBindingPeriodId within Mysim)
          example: 1233094
        terms_id:
          type: string
          description: Catalogue unique terms identifier (BindingTypeId within Mysim)
          example: 76
        start_date:
          type: string
          description: terms start date (Mysim StartDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        end_date:
          type: string
          description: terms end date (Mysim EndDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        type:
          type: string
          description: PermanenceContract (contract used when a minimum permanency is set), ActivationCommitment (terms type used when service activation is committed. For instance, the installation cost is subsidized only in case the service is finally activated. If the order is cancelled before activating the service but after performing installation, the installation cost could be charged to the customer through an ActivationCommitment terms), ReturnCommitment (terms type used for enabling the commitment of returning a subsidized item after the service deactivation. For instance, when the service provider delivers a device to the customer that it is actually owned buy the service provider, the customer will be typically forced to return the transferred device after service deactivation. This term type is used for enabling this type of commitment)
          example: PermanenceContract
          enum:
            - PermanenceContract
            - ActivationCommitment
            - ReturnCommitment
        commitment_duration:
          type: number
          description: duration of a PermanenceContract in months
          format: int32
          example: 1

    Value:
      type: object
      required:
        - value
      properties:
        value:
          type: number
          format: double
          example: 8.264463
        currency:
          type: string
          description: null for values associated to promotion with discountTYpe=percentage. euro for rest
          example: euro

    BasicCreditLimit:
      type: object
      additionalProperties: false
      properties:
        subscription_id:
          type: string
          description: internal subscription id
          example: 3821002
        credit_limit_id:
          type: string
          description: credit limit id
          example: MOBILE_SUBSCRIPTION_TOTAL_CREDIT_LIMIT
          enum:
            - MOBILE_SUBSCRIPTION_TOTAL_CREDIT_LIMIT
            - MOBILE_SUBSCRIPTION_ROAMING_VOICE_CREDIT_LIMIT
            - MOBILE_SUBSCRIPTION_PREMIUM_CREDIT_LIMIT
            - MOBILE_SUBSCRIPTION_INTERNATIONAL_VOICE_CREDIT_LIMIT
            - LANDLINE_SUBSCRIPTION_TOTAL_CREDIT_LIMIT
            - LANDLINE_SUBSCRIPTION_PREMIUM_CREDIT_LIMIT
            - LANDLINE_SUBSCRIPTION_INTERNATIONAL_VOICE_CREDIT_LIMIT
        credit_limit_value:
          type: number
          description: credit limit value
          example: 87.264463
        user_name:
          type: string
          description: user name of the user setting the subscription credit limit (Mysim user login)
          example: test@test.com
        change_reason:
          type: string
          description: subscription credit limit change reason
          example: customer request
        effective_date:
          type: string
          description: date when the limit starts to be effective
          format: date-time
          example: "2017-09-15T22:00:00Z"
        update_date:
          type: string
          description: date when the limit value is set
          format: date-time
          example: "2017-09-15T22:00:00Z"

    CreditLimit:
      allOf:
        - $ref: '#/components/schemas/BasicCreditLimit'
        - type: object
          properties:
            historical_changes:
              type: array
              description: Subscription credit limit historical changes
              items:
                $ref: '#/components/schemas/BasicCreditLimit'

    GetCreditLimit:
      allOf:
        - $ref: '#/components/schemas/CreditLimit'
        - type: object
          required:
            - subscription_id
            - credit_limit_id
            - credit_limit_value
            - user_name
            - effective_date
            - update_date

    DefaultCreditLimit:
      type: object
      additionalProperties: false
      properties:
        mobile_total:
          type: number
          format: double
          description: xxx
          example: 3821002
        mobile_roaming_voice:
          type: number
          format: double
          description: xxx
          example: 3821002
        mobile_premium:
          type: number
          format: double
          description: xxx
          example: 3821002
        mobile_international_voice:
          type: number
          format: double
          description: xxx
          example: 3821002
        landline_total:
          type: number
          format: double
          description: xxx
          example: 3821002
        landline_premium:
          type: number
          format: double
          description: xxx
          example: 3821002
        landline_international_voice:
          type: number
          format: double
          description: xxx
          example: 3821002

    PostCreditLimits:
      type: object
      additionalProperties: false
      required:
        - credit_limits
      properties:
        credit_limits:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/PostCreditLimit'

    PostCreditLimit:
      type: object
      additionalProperties: false
      required:
        - credit_limit_id
        - user_name
      properties:
        credit_limit_id:
          type: string
          description: credit limit id
          example: MOBILE_SUBSCRIPTION_TOTAL_CREDIT_LIMIT
          enum:
            - MOBILE_SUBSCRIPTION_TOTAL_CREDIT_LIMIT
            - MOBILE_SUBSCRIPTION_ROAMING_VOICE_CREDIT_LIMIT
            - MOBILE_SUBSCRIPTION_PREMIUM_CREDIT_LIMIT
            - MOBILE_SUBSCRIPTION_INTERNATIONAL_VOICE_CREDIT_LIMIT
            - LANDLINE_SUBSCRIPTION_TOTAL_CREDIT_LIMIT
            - LANDLINE_SUBSCRIPTION_PREMIUM_CREDIT_LIMIT
            - LANDLINE_SUBSCRIPTION_INTERNATIONAL_VOICE_CREDIT_LIMIT
        credit_limit_value:
          type: number
          description: credit limit value. If not received, default value configured for tenant will be provisioned
          example: 87.264463
        user_name:
          type: string
          description: user name of the user setting the subscription credit limit (Mysim user login)
          example: test@test.com

    PostCreditLimitsResponse:
      type: object
      properties:
        credit_limit_id:
          type: string
          description: credit limit id
          example: MOBILE_SUBSCRIPTION_TOTAL_CREDIT_LIMIT
          enum:
            - MOBILE_SUBSCRIPTION_TOTAL_CREDIT_LIMIT
            - MOBILE_SUBSCRIPTION_ROAMING_VOICE_CREDIT_LIMIT
            - MOBILE_SUBSCRIPTION_PREMIUM_CREDIT_LIMIT
            - MOBILE_SUBSCRIPTION_INTERNATIONAL_VOICE_CREDIT_LIMIT
            - LANDLINE_SUBSCRIPTION_TOTAL_CREDIT_LIMIT
            - LANDLINE_SUBSCRIPTION_PREMIUM_CREDIT_LIMIT
            - LANDLINE_SUBSCRIPTION_INTERNATIONAL_VOICE_CREDIT_LIMIT
        credit_limit_value:
          type: number
          description: credit limit value. If not received, default value configured for tenant will be provisioned
          example: 87.264463
        effective_date:
          type: string
          description: date when the limit starts to be effective
          format: date-time
          example: "2017-09-15T22:00:00Z"

    PatchCreditLimit:
      type: object
      additionalProperties: false
      required:
        - credit_limit_id
        - credit_limit_value
        - change_user
      properties:
        credit_limit_id:
          type: string
          description: credit limit id
          example: MOBILE_SUBSCRIPTION_ROAMING_VOICE_CREDIT_LIMIT
          enum:
            - MOBILE_SUBSCRIPTION_TOTAL_CREDIT_LIMIT
            - MOBILE_SUBSCRIPTION_ROAMING_VOICE_CREDIT_LIMIT
            - MOBILE_SUBSCRIPTION_PREMIUM_CREDIT_LIMIT
            - MOBILE_SUBSCRIPTION_INTERNATIONAL_VOICE_CREDIT_LIMIT
            - LANDLINE_SUBSCRIPTION_TOTAL_CREDIT_LIMIT
            - LANDLINE_SUBSCRIPTION_PREMIUM_CREDIT_LIMIT
            - LANDLINE_SUBSCRIPTION_INTERNATIONAL_VOICE_CREDIT_LIMIT
        credit_limit_value:
          type: number
          description: credit limit value
          example: 87.264463
        change_user:
          type: string
          description: user name of the user changing the subscription credit limit (Mysim user login)
          example: test@test.com
        change_reason:
          type: string
          description: subscription credit limit change reason
          example: customer request

    PatchCreditLimits:
      type: object
      additionalProperties: false
      required:
        - subscription_type
        - credit_limits
      properties:
        subscription_type:
          $ref: '#/components/schemas/SubscriptionType'
        credit_limits:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/PatchCreditLimit'

    ErrorMessage:
      type: object
      additionalProperties: false
      required:
        - errors
      properties:
        errors:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/ErrorMessageItem'

    ErrorMessageItem:
      type: object
      additionalProperties: false
      required:
        - code
        - title
        - ref
        - details
      properties:
        code:
          type: string
          description: Error code having an entry in a domain dictionary
          example: XXX_21201
        title:
          type: string
          description: Title of the error, having an entry in a domain dictionary
          example: "TITLE_OF_THE_DOMAIN_ERROR"
        ref:
          type: string
          description: Location in the developer portal
          example: https://developers.masstack.com/en/docs/apis_domain_doc_swagger/2/apioverview/#erro
        details:
          type: string
          description: Message and details of the error

    DetailedSubscription:
      type: object
      oneOf:
        - $ref: '#/components/schemas/SecuritySubscription'
        - $ref: '#/components/schemas/TvSubscription'
        - $ref: '#/components/schemas/DataSharingSubscription'
        - $ref: '#/components/schemas/MobileSubscription'
        - $ref: '#/components/schemas/BroadbandSubscription'
        - $ref: '#/components/schemas/LandlineSubscription'
        - $ref: '#/components/schemas/MultiSimSubscription'
        - $ref: '#/components/schemas/AppleWatchSubscription'
        - $ref: '#/components/schemas/DeviceInsuranceSubscription'
        - $ref: '#/components/schemas/NetflixSubscription'

    FreeUnitsPackage:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          description: Internal CRM unique subscription free units package identifier
          example: 1233094
        free_units_package_id:
          type: string
          description: Catalogue unique free units package identifier
          example: 76
        activation_date:
          type: string
          description: free units package subsciption activation date (Mysim AssociationDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        deactivation_date:
          type: string
          description: promotion deactivation date (Mysim EndDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        user_name:
          type: string
          description: user name of the user who adds the promotion
          example: test@test.com

    GetFreeUnitsPackage:
      allOf:
        - $ref: '#/components/schemas/FreeUnitsPackage'
        - type: object
          required:
            - id
            - free_units_package_id
            - user_name

    SellMultiSimRequestFreeUnitsPackage:
      type: object
      additionalProperties: false
      required:
        - id
      properties:
        id:
          type: string
          description: Internal CRM unique subscription free units package identifier
          example: 1233094

    SubscriptionId:
      type: object
      additionalProperties: false
      properties:
        subscription_id:
          type: string
          description: internal subscription id
          example: 3821002

    SharingFreeUnitsPackage:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          description: sharing free units package id
          example: 1234
        subscription_id:
          type: string
          description: sharing free units package subscription id
          example: 1234
        start_date:
          type: string
          description: start date
          format: date-time
          example: "2017-09-15T22:00:00Z"
        end_date:
          type: string
          description: end date
          format: date-time
          example: "2017-09-15T22:00:00Z"

    SubscriptionMember:
      type: object
      additionalProperties: false
      properties:
        subscription_id:
          type: string
          description: internal subscription id
          example: 3821002
        start_date:
          type: string
          description: start of the membership
          format: date-time
          example: "2017-09-15T22:00:00Z"
        end_date:
          type: string
          description: end of the membership
          format: date-time
          example: "2017-09-15T22:00:00Z"

    GetFraudRequest:
      allOf:
        - $ref: '#/components/schemas/FraudRequest'
        - type: object
          required:
            - id
            - risk_decision

    FraudRequest:
      type: object
      additionalProperties: false
      required:
        - risk_decision
      properties:
        id:
          type: string
          description: Internal unique fraud request id
          example: 1233094
        sell_id:
          type: string
          description: Internal unique sell id
          example: 76
        risk_decision:
          type: string
          description: fraud request risk decision
            <ul>
            <li> X -> Doc required </li>
            <li> A -> OK  </li>
            <li> D -> Cancelled </li>
            <li> R -> KO </li>
            </ul>
          example: A
          enum:
            - A
            - X
            - D
            - R
        subscriptions:
          type: array
          items:
            $ref: '#/components/schemas/FraudRequestSubscription'

    FraudRequestSubscription:
      type: object
      additionalProperties: false
      properties:
        subscription_id:
          type: string
          description: internal subscription id
          example: 3821002
        subscription_type:
          $ref: '#/components/schemas/SubscriptionType'

    PatchFraudRequest:
      type: object
      additionalProperties: false
      required:
        - risk_decision
        - risk_level
      properties:
        risk_decision:
          type: string
          description: fraud request risk decision
            <ul>
            <li> X -> Doc required </li>
            <li> A -> OK  </li>
            <li> D -> Cancelled </li>
            </ul>
          example: A
          enum:
            - A
            - X
            - D
        risk_level:
          type: integer
          format: int32
          description: Value from 0 to 10
          example: 3
        risk_codes:
          type: string
          description: risk codes
          example: IH:c(4)s(0)r()v(779)
        fraud_request_value:
          type: integer
          format: int64
          description: unique response id
          example: 165089515739815
        status_change_user:
          type: string
          description: user name of the user performing the subscription status change (Mysim user login)
          example: test@test.com
        status_change_reason:
          type: string
          description: subscription status change reason
          example: customer request
        requested_status_change_date:
          type: string
          description: date when the status change must be effective
          format: date-time
          example: "2017-09-15T22:00:00Z"

    GetSubscriptionSegments:
      type: object
      additionalProperties: false
      required:
        - segments
      properties:
        segments:
          type: array
          description: subscription segments
          items:
            $ref: '#/components/schemas/GetSubscriptionSegment'

    GetSubscriptionSegment:
      type: object
      additionalProperties: false
      properties:
        segment_id:
          type: string
          description: Segment identifier
          example: SEGMENT_ID
        segment_value:
          type: string
          description: Segment value
          example: SEGMENT_VALUE
        user_name:
          type: string
          description: User name of the user changing the subscription segment (Mysim user login)
          example: test@test.com
        change_reason:
          type: string
          description: Segment change reason
          example: customer request
        effective_date:
          type: string
          description: date when the segment starts to be effective
          format: date-time
          example: "2017-09-15T22:00:00Z"

    PostSegments:
      type: object
      additionalProperties: false
      required:
        - segments
      properties:
        segments:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/PostSegment'

    PostSegment:
      type: object
      additionalProperties: false
      required:
        - segment_id
        - segment_value
        - change_user
      properties:
        segment_id:
          type: string
          description: Segment identifier
          example: SEGMENT_ID
        segment_value:
          type: string
          description: Segment value
          example: SEGMENT_VALUE
        change_user:
          type: string
          description: User name of the user changing the subscription segment (Mysim user login)
          example: test@test.com
        change_reason:
          type: string
          description: Segment change reason
          example: customer request

    GetSubscriptionDevice:
      allOf:
        - $ref: '#/components/schemas/SubscriptionDevice'
        - type: object
          required:
            - id
            - device_id
            - category
            - status

    SubscriptionDevice:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          description: Internal CRM unique subscription device identifier
          example: 1233094
        device_id:
          type: string
          description: Catalogue unique device identifier
          example: P045A1SNC
        category:
          type: string
          description: device category
          example: SIM
        status:
          type: string
          description: device status
          example: ACTIVO
        contract_document_id:
          type: string
          description: Contract Document unique identifier. It can be an id with uuid format that is associated to a document stored within MasDocuments or a legacy pdf file name
        device_additional_details:
          $ref: '#/components/schemas/DetailedDevice'
          discriminator:
            propertyName: category
        subscription_device_change_requests:
          type: array
          description: array of requests associated to the subscription device
          items:
            $ref: '#/components/schemas/SubscriptionDeviceChangeRequest'
            discriminator:
              propertyName: category

    DetailedDevice:
      type: object
      oneOf:
        - $ref: '#/components/schemas/SimDevice'
        - $ref: '#/components/schemas/Device'

    SimDevice:
      type: object
      additionalProperties: false
      properties:
        iccid:
          type: string
          description: Circuit Card Identification Number associated to the SIM card
          example: 8934011411551283144
        imsi:
          type: string
          description: International mobile subscriber identity
          example: 214035453370793
        pin:
          type: string
          description: Pin
          example: 1234
        puk:
          type: string
          description: puk
          example: 1234
        pin2:
          type: string
          description: Pin2
          example: 1234
        puk2:
          type: string
          description: puk2
          example: 1234
        fabrication_type:
          type: string
          description: fabrication type
          enum:
            - SIM
            - MICROSIM
            - NANOSIM
            - eSIM
          example: eSIM

    Device:
      type: object
      additionalProperties: false
      required:
        - sale_date
        - insured_amount
      properties:
        sale_date:
          type: string
          format: date-time
          example: "2017-09-15T22:00:00Z"
        delivery_date:
          type: string
          format: date-time
          example: "2017-09-15T22:00:00Z"
        serial_number:
          type: string
        insured_amount:
          type: number
          description: field with the amount that can be insured in a particular device, if there is no insurance option a -1.00 value is returned
          format: double
          example: -1.00

    SimDeviceChangeRequest:
      type: object
      additionalProperties: false
      properties:
        status:
          type: string
          description: change request status
          example: PROCESSED
        request_date:
          type: string
          description: request date
          format: date-time
          example: "2017-09-15T22:00:00Z"
        user_name:
          type: string
          description: user name of the user performing the subscription device request
          example: test@test.com
        change_reason:
          type: string
          description: device change reason
          example: sim lost
        contract_document_id:
          type: string
          example: d290f1ee-6c54-4b01-90e6-d701748f0851
          description: Contract Document unique identifier. It can be an id with uuid format that is associated to a document stored within MasDocuments or a legacy pdf file name
        fabrication_type:
          type: string
          description: fabrication type
          enum:
            - SIM
            - MICROSIM
            - NANOSIM
            - eSIM
          example: eSIM
        iccid:
          type: string
          description: Circuit Card Identification Number associated to the SIM card
          example: 8934011411551283144
        imsi:
          type: string
          description: International mobile subscriber identity
          example: 214035453370793

    SubscriptionDeviceChangeRequest:
      type: object
      allOf:
        - $ref: '#/components/schemas/SimDeviceChangeRequest'

    PatchSubscriptionDevice:
      type: object
      additionalProperties: false
      required:
        - category
        - subscription_device_change_request
      properties:
        category:
          type: string
          description: device category
          example: SIM
        user_name:
          type: string
          description: user name of the user performing the subscription device request. If there is a token in place generated with real user credentials, there is no need to send this value  since it will be obtained using the token claims
          example: test@test.com
        change_reason:
          type: string
          description: device change reason
          example: sim lost
        subscription_device_change_request:
          $ref: '#/components/schemas/PatchSubscriptionDeviceChangeRequest'
          discriminator:
            propertyName: category

    PatchSimDeviceChangeRequest:
      type: object
      additionalProperties: false
      required:
        - fabrication_type
      properties:
        fabrication_type:
          type: string
          description: fabrication type
          example: eSIM
        signature_process_id:
          type: string
          description: id of the signature process triggered by sales channel
        signature_type:
          type: string
          description: signature type
          enum:
            - PAPER
            - BIOMETRIC
            - OTP
        iccid:
          type: string
          description: Circuit Card Identification Number associated to the SIM card
          example: 8934011411551283144
        imsi:
          type: string
          description: International mobile subscriber identity
          example: 214035453370793
        new_iccid:
          description: Circuit Card Identification Number associated to the SIM card to change by actual
          example: "8934011411551283145"
          type: string
        new_imsi:
          description: International mobile subscriber identity to change by actual
          example: "214035453370793"
          type: string

    PatchSubscriptionDeviceChangeRequest:
      type: object
      allOf:
        - $ref: '#/components/schemas/PatchSimDeviceChangeRequest'

    PostPromotion:
      allOf:
        - $ref: '#/components/schemas/Promotion'
        - type: object
          required:
            - promotion_id
            - activation_date

    SellMultiSimRequestPromotion:
      type: object
      properties:
        id:
          type: string
          description: Internal CRM unique subscription promotion identifier
          example: 1233094

    PostPromotionResponse:
      type: object
      properties:
        id:
          type: string
          description: Internal CRM unique subscription promotion identifier
          example: 1233094

    Promotion:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          description: Internal CRM unique subscription promotion identifier
          example: 1233094
        promotion_id:
          type: string
          description: Catalogue unique promotion identifier
          example: 76
        activation_date:
          type: string
          description: promotion activation date (Mysim AssociationDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        deactivation_date:
          type: string
          description: promotion deactivation date (Mysim EndDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        user_name:
          type: string
          description: user name of the user who adds the promotion
          example: test@test.com
        value:
          $ref: '#/components/schemas/PromotionValue'
        terms:
          $ref: '#/components/schemas/PromotionTerms'

    PromotionTerms:
      type: object
      additionalProperties: false
      required:
        - terms_id
        - start_date
        - end_date
        - type
      properties:
        id:
          type: string
          description: Internal CRM unique subscription terms identifier (SubscriptionBindingPeriodId within Mysim)
          example: 1233094
        terms_id:
          type: string
          description: Catalogue unique terms identifier (BindingTypeId within Mysim)
          example: 76
        start_date:
          type: string
          description: terms start date (Mysim StartDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        end_date:
          type: string
          description: terms end date (Mysim EndDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        type:
          type: string
          description: PermanenceContract (contract used when a minimum permanency is set), ActivationCommitment (terms type used when service activation is committed. For instance, the installation cost is subsidized only in case the service is finally activated. If the order is cancelled before activating the service but after performing installation, the installation cost could be charged to the customer through an ActivationCommitment terms), ReturnCommitment (terms type used for enabling the commitment of returning a subsidized item after the service deactivation. For instance, when the service provider delivers a device to the customer that it is actually owned buy the service provider, the customer will be typically forced to return the transferred device after service deactivation. This term type is used for enabling this type of commitment)
          example: PermanenceContract
          enum:
            - PermanenceContract
            - ActivationCommitment
            - ReturnCommitment
        commitment_duration:
          type: number
          description: duration of a PermanenceContract in months
          format: int32
          example: 1

    PromotionValue:
      type: object
      required:
        - value
      properties:
        value:
          type: number
          format: double
          example: 8.264463
        currency:
          type: string
          description: null for values associated to promotion with discountTYpe=percentage. euro for rest
          example: euro


    PostPromotionDeactivate:
      type: object
      additionalProperties: false
      required:
        - deactivation_date
      properties:
        deactivation_date:
          type: string
          description: promotion deactivation date (Mysim EndDate)
          format: date-time
          example: "2017-09-15T22:00:00Z"
        user_name:
          type: string
          description: user name of the user who deactivates the promotion
          example: test@test.com
        status_change_reason:
          type: string
          description: promotion status change reason
          example: customer request

    NumerationType:
      type: string
      description: numeration type name. Mapping between Mysim origin and MasSubscriptions numeration_type
        <ul>
        <li> OriginId=1 -> Nuevo numero -> NEW </li>
        <li> Origin=2 -> Numero portado -> OUTER_PORTABILITY </li>
        <li> OriginId=10 -> Numero entre marcas -> INNER_PORTABILITY </li>
        <li> Others -> UNKNOWN -> UNKNOWN </li>
        </ul>
      example: NEW
      enum:
        - NEW
        - OUTER_PORTABILITY
        - INNER_PORTABILITY
        - UNKNOWN

    SubscriptionStatus:
      type: string
      description: subscription status.Mapping between Mysim and MasSubscriptions status
        <ul>
        <li> INSTALADO (1) -> SALEINCOMPLETE, SALECOMPLETE, SALECREATED </li>
        <li> PRE-ACTIVADO (2) -> PRE-ACTIVE </li>
        <li> ACTIVO (3) -> ACTIVE </li>
        <li> BLOQUEO POR SALDO (4) -> ACTIVE (with services barred) </li>
        <li> TERMINADO (6) > DEACTIVATED, CANCELLED, SALEREJECTED </li>
        <li> BLOQUEO TEMPORAL (7) -> ACTIVE (with services barred) </li>
        <li> PENDIENTE TERMINACION (9) -> PENDINGDEACTIVATION </li>
        <li> BLOQUEO LIMITE CONSUMO (10) -> ACTIVE (with services barred) </li>
        <li> BLOQUEO POR IMPAGO (12) -> ACTIVE (with services barred) </li>
        <li> SUSPENSION PENDIENTE (39) -> ACTIVE </li>
        <li> RECONEXION PENDIENTE (40) -> ACTIVE (with services barred) </li>
        <li> PENDIENTE BLOQUEO TEMPORAL (50) -> ACTIVE </li>
        </ul>
      example: ACTIVE
      enum:
        - SALEINCOMPLETE
        - SALECOMPLETE
        - PRE-ACTIVE
        - ACTIVE
        - PENDINGDEACTIVATION
        - PENDINGCANCELLATION
        - DEACTIVATED
        - CANCELLED
        - SALEREJECTED
        - SALECREATED

    SubscriptionType:
      type: string
      description: subscription type name. Mapping between Mysim and MasSubscriptions subscription_type
        <ul>
        <li> PRE-PAGO -> MOBILE </li>
        <li> POST-PAGO -> MOBILE </li>
        <li> INTERNET FTTH-> BROADBAND </li>
        <li> INTERNET ADSL -> BROADBAND </li>
        <li> FIJO ANALOGICO-> LANDLINE </li>
        <li> FIJO DIGITAL -> LANDLINE </li>
        <li> AGILE TV -> TV </li>
        <li> SECURITY -> SECURITY </li>
        <li> DATASHARING -> DATASHARING </li>
        <li> MULTISIM -> MULTISIM </li>
        <li> DEVICEINSURANCE -> DEVICEINSURANCE </li>
        <li> NETFLIX -> NETFLIX </li>
        <li> APPLEWATCH -> APPLEWATCH </li>
        <li> AMAZONPRIME -> AMAZONPRIME </li>
        <li> MAX -> MAX </li>
        <li> ORANGE TV -> ORANGETV </li>
        <li> ORANGE TV LIBRE -> ORANGETVLIBRE </li>
        <li> DISNEY -> DISNEY </li>
        <li> AGILE_TV -> AGILE_TV </li>
        </ul>
      example: MOBILE
      enum:
        - MOBILE
        - BROADBAND
        - LANDLINE
        - TV
        - SECURITY
        - DATASHARING
        - MULTISIM
        - DEVICEINSURANCE
        - NETFLIX
        - APPLEWATCH
        - AMAZONPRIME
        - AGILE_TV
        - MAX
        - ORANGETV
        - ORANGETVLIBRE
        - DISNEY

    GetCommercialProductsHistory:
      type: object
      additionalProperties: false
      properties:
        commercial_product_history:
          description: Commercial Products historical changes
          items:
            $ref: '#/components/schemas/CommercialProduct'
          type: array
    CommercialProduct:
      type: object
      additionalProperties: false
      properties:
        history_id:
          type: string
          description: unique identifier of the commercial product history record
          example: 637746
        commercial_product_id:
          type: string
          description: unique identifier of the commercial product associated to the subscription
          example: 3072
        start_date:
          type: string
          description: start date
          format: date-time
          example: "2017-09-15T22:00:00Z"
        end_date:
          type: string
          description: end date
          format: date-time
          example: "2017-09-15T22:00:00Z"

    SellAppleWatchRequest:
      type: object
      required:
        - main_subscription_id
        - commercial_product_id
        - imsi
        - iccid
      properties:
        main_subscription_id:
          type: string
          description: Subscription identifier from an existent mobile subscription
          example: "5331402"
        commercial_product_id:
          type: string
          example: "1"
          description: Commercial product identifier
        imsi:
          type: string
          description: International Mobile Subscriber Identity associated to the AppleWatch subscription
          example: "214035453370793"
        iccid:
          type: string
          description: Circuit Card Identification Number associated to the SIM card
          example: "8934011411551283144"
        sale_details:
          type: object
          properties:
            user_name:
              type: string
              description: Optional user name
              example: "test@test"
        free_units_packages:
          type: array
          description: list of free units packages included in the sale
          items:
            $ref: '#/components/schemas/SellAppleWatchRequestFreeUnitsPackage'
        promotions:
          type: array
          description: list of promotions included in the sale
          items:
            $ref: '#/components/schemas/SellAppleWatchRequestPromotion'

    SellAppleWatchResponse:
      type: object
      properties:
        subscription_id:
          type: string
          description: subscription id created in the sale
          example: 3819912

    SellAppleWatchRequestFreeUnitsPackage:
      type: object
      additionalProperties: false
      required:
        - id
      properties:
        id:
          type: string
          description: Internal CRM unique subscription free units package identifier
          example: "1233094"

    SellAppleWatchRequestPromotion:
      type: object
      properties:
        id:
          type: string
          description: Internal CRM unique subscription promotion identifier
          example: "1233094"

    AppleWatchDeactivateSubscriptionRequest:
      type: object
      required:
        - deactivation_reason
      properties:
        deactivation_reason:
          type: string
          description: Deactivation reason text or id as a string
          example: "1234"
        deactivation_user:
          type: string
          description: User that requests the deactivation
          example: "test@test.com"
        requested_deactivation_date:
          type: string
          description: deactivation date
          format: date-time
          example: "2017-09-15T22:00:00Z"

  x-othersOverviewInfo:
    description: >

      ## Response code library
      <details><summary>INVALID_LIMIT_VALUE_CONFIGURATION</summary>
      ```
      {
        "errors": [
          {
            "code": "0036",
            "title": "INVALID_LIMIT_VALUE_CONFIGURATION",
            "ref": "https://developers.masstack.com/en/",
            "details": "Invalid limit value configuration for subscription 534297"
          }
        ]
      }
      ```
      </details>
      <details><summary>SIM_CARD_NOT_FREE</summary>
      ```
      {
        "errors": [
          {
            "code": "0035",
            "title": "SIM_CARD_NOT_FREE",
            "ref": "https://developers.masstack.com/en/",
            "details": "Sim card with imsi 1234 is not free"
          }
        ]
      }
      ```
      </details>
      <details><summary>INCOMPATIBLE_PROMOTION_WITH_COMMERCIAL_PRODUCT</summary>
      ```
      {
        "errors": [
          {
            "code": "0034",
            "title": "INCOMPATIBLE_PROMOTION_WITH_COMMERCIAL_PRODUCT",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>INCOMPATIBLE_FREE_UNITS_PACKAGE_WITH_COMMERCIAL_PRODUCT</summary>
      ```
      {
        "errors": [
          {
            "code": "0033",
            "title": "INCOMPATIBLE_FREE_UNITS_PACKAGE_WITH_COMMERCIAL_PRODUCT",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>UNEXPECTED_SUBSCRIPTION_TYPE</summary>
      ```
      {
        "errors": [
          {
            "code": "0032",
            "title": "UNEXPECTED_SUBSCRIPTION_TYPE",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>BUNDLED_COMMERCIAL_PRODUCT_MULTIPLE_SERVICE_FEES</summary>
      ```
      {
        "errors": [
          {
            "code": "0031",
            "title": "BUNDLED_COMMERCIAL_PRODUCT_MULTIPLE_SERVICE_FEES",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>BUNDLED_COMMERCIAL_PRODUCT_NO_SERVICE_FEE</summary>
      ```
      {
        "errors": [
          {
            "code": "0030",
            "title": "BUNDLED_COMMERCIAL_PRODUCT_NO_SERVICE_FEE",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>INCOMPATIBLE_BUNDLED_PRODUCT_WITH_COMMERCIAL_PRODUCT</summary>
      ```
      {
        "errors": [
          {
            "code": "0029",
            "title": "INCOMPATIBLE_BUNDLED_PRODUCT_WITH_COMMERCIAL_PRODUCT",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>ACCOUNT_BUNDLE_INACTIVE_SUBSCRIPTION</summary>
      ```
      {
        "errors": [
          {
            "code": "0028",
            "title": "ACCOUNT_BUNDLE_INACTIVE_SUBSCRIPTION",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>INACTIVE_ACCOUNT_BUNDLE</summary>
      ```
      {
        "errors": [
          {
            "code": "0027",
            "title": "INACTIVE_ACCOUNT_BUNDLE",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>ASSOCIATED_ACTIVE_APPLEWATCH</summary>
      ```
      {
        "errors": [
          {
            "code": "0026",
            "title": "ASSOCIATED_ACTIVE_APPLEWATCH",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>ASSOCIATED_ACTIVE_MULTISIM</summary>
      ```
      {
        "errors": [
          {
            "code": "0025",
            "title": "ASSOCIATED_ACTIVE_MULTISIM",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>INACTIVE_SUBSCRIPTION</summary>
      ```
      {
        "errors": [
          {
            "code": "0024",
            "title": "INACTIVE_SUBSCRIPTION",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>PENDING_OPERATIONS</summary>
      ```
      {
        "errors": [
          {
            "code": "0023",
            "title": "PENDING_OPERATIONS",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>PENDING_WORK_ORDERS</summary>
      ```
      {
        "errors": [
          {
            "code": "0022",
            "title": "PENDING_WORK_ORDERS",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>INCOMPATIBLE_ACCOUNT_WITH_COMMERCIAL_PRODUCT</summary>
      ```
      {
        "errors": [
          {
            "code": "0021",
            "title": "INCOMPATIBLE_ACCOUNT_WITH_COMMERCIAL_PRODUCT",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>INACTIVE_ACCOUNT_ID</summary>
      ```
      {
        "errors": [
          {
            "code": "0020",
            "title": "INACTIVE_ACCOUNT_ID",
            "ref": "https://developers.masstack.com/en/",
            "details": "Account with id: 1234 is not active"
          }
        ]
      }
      ```
      </details>
      <details><summary>DEFAULT_ERROR</summary>
      ```
      {
        "errors": [
          {
            "code": "0019",
            "title": "DEFAULT_ERROR",
            "ref": "https://developers.masstack.com/en/",
            "details": "XXX"
          }
        ]
      }
      ```
      </details>

