openapi: 3.0.1
info:
  title: MasFeasibility API
  description: I am <b><i>MasFeasibility API</i></b>. My intention is to provide a set of REST services to check sales viability.
  version: 2.0.0
servers:
  - url: https://feasibility.sta.masstack.com/v2
    description: STA
  - url: https://feasibility.masstack.com/v2
    description: PROD
tags:
  - name: Portability
    description: These services checks if a landline portability or an access transfer is allowed.
  - name: Subscription Limit
    description: This service provides subscriptions info of telco services
paths:
  /orgs/{orgId}/portability/portabilityCheck:
    post:
      tags:
        - Portability
      description: Returns whether the portability process can be carried out and whether it requires a new installation. Altas con portabilidad.
      operationId: getPortability
      parameters:
        - name: orgId
          in: path
          required: true
          style: simple
          explode: false
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/portabilityCheck'
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/_getPortabilityConditions'
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/bad_request_response'
              examples:
                example1:
                  value:
                    code: "0015"
                    status: BAD_REQUEST
                    message: Bad Request
                    detailMsg: "The field '{fieldName}' is required"
                example2:
                  value:
                    code: "0018"
                    status: BAD_REQUEST
                    message: Bad Request
                    detailMsg: the origin brand and the destination brand are the same
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/not_found_response'
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error_response'
  /orgs/{orgId}/portability/accessCheck:
    post:
      tags:
        - Portability
      description: Returns if a new installation is required. Altas naked o nueva numeracion.
      operationId: getAccess
      parameters:
        - name: orgId
          in: path
          required: true
          style: simple
          explode: false
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/accessCheck'
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/_getAccessCheck'
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/bad_request_response'
              examples:
                example1:
                  value:
                    code: "0015"
                    status: BAD_REQUEST
                    message: Bad Request
                    detailMsg: "The field '{fieldName}' is required"
                example2:
                  value:
                    code: "0018"
                    status: BAD_REQUEST
                    message: Bad Request
                    detailMsg: the origin brand and the destination brand are the same
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/not_found_response'
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error_response'
  /orgs/{orgId}/subscriptions/limit/active:
    post:
      tags:
        - Subscription Limit
      description: Gives active subscriptions info and fraud limits of telco services for a client
      operationId: POST -orgs/_orgId/subscriptions/limit/active
      parameters:
        - name: orgId
          in: path
          description: Organization name as it is registered in mas-stack
          required: true
          schema:
            type: string
          example: masmovil
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/subscription_limit_active_request'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/subscription_limit_active_response'
components:
  schemas:
    portabilityCheck:
      required:
        - number
        - technicalId
        - technology
        - territoryOwner
      type: object
      properties:
        number:
          type: string
          description: Fixed number to be ported
          example: "911234567"
        territoryOwner:
          type: string
          description: Territory owner. Not mandatory if technology is MIFIJO
          example: FIBNEB01
        technicalId:
          type: string
          description: TechnicalId (corresponding with "GESCAL" ). Not mandatory if technology is MIFIJO. g17 or g37
          example: "12345678901234567"
        addressId:
          type: string
          description: Unique address ID
          example: "M0000000000000000000000000000007042185"
        technology:
          type: string
          description: Technology to be provided
          example: FTTH
          enum:
            - FTTH
            - ADSL
            - MIFIJO
    accessCheck:
      required:
        - documentId
        - technicalId
        - technology
        - territoryOwner
      type: object
      properties:
        originNumber:
          type: string
          description: Fixed number to be ported
          example: "911234567"
        territoryOwner:
          type: string
          description: Territory owner.
          example: FIBNEB01
        technicalId:
          type: string
          description: TechnicalId (corresponding with "GESCAL" ). g17 or g37
          example: "12345678901234567"
        addressId:
          type: string
          description: Unique address ID
          example: "M0000000000000000000000000000007042185"
        documentId:
          $ref: '#/components/schemas/documentId'
    documentId:
      required:
        - type
        - value
      type: object
      properties:
        type:
          type: string
          example: NIF
          enum:
            - CIF
            - NIE
            - NIF
            - Passport
        value:
          type: string
          example: 11111111A
    _getPortabilityConditions:
      required:
        - installationRequired
        - internalPortability
        - isPortable
        - operator
      type: object
      properties:
        internalPortability:
          type: boolean
          description: Determines whether the process is an internal portability or not
          example: true
        isPortable:
          type: boolean
          description: Determines whether the number is portable
          example: true
        installationRequired:
          type: boolean
          description: Determines whether a new installation is required
          example: false
        operator:
          $ref: '#/components/schemas/operator'
        installationInformation:
          $ref: '#/components/schemas/installationInformation'
    _getAccessCheck:
      required:
        - installationRequired
      type: object
      properties:
        installationRequired:
          type: boolean
          description: Determines whether a new installation is required
          example: false
        installationInformation:
          $ref: '#/components/schemas/installationInformation'
    installationInformation:
      required:
        - iua
        - internalAccess
      type: object
      properties:
        internalAccess:
          type: boolean
          description: internal or external access
          example: true
        iua:
          type: string
          description: origin IUA
          example: V33904AHB202
        brand:
          type: string
          example: 'ORANGE'
          description: Brand name
        number:
          type: string
          example: '654321987'
          description: Client's phone number
        documentNumber:
          type: string
          example: '12345678Z'
          description: Client's document number
        gescal:
          type: string
          example: '28000010276800007         006DCHA    '
          description: Gescal address
      description: Available when FTTH access transfer
    operator:
      type: object
      required:
        - code
        - name
      properties:
        code:
          type: string
          description: Operator code
          example: "00031"
        name:
          type: string
          description: Operator name
          example: XTRA
    subscription_limit_active_request:
      type: object
      properties:
        document_type:
          type: string
          example: NIF
          enum:
            - NIF
            - CIF
            - NIE
            - PASSPORT
            - TR
          description: client document type.
        document_id:
          example: 88662844Y
          type: string
          description: client document number.
        segment:
          type: string
          example: Consumer
          enum:
            - Consumer
            - SelfEmployee
            - SME
            - B2B
    subscription_limit_active_response:
      type: object
      required: [ "total_limit", "total_active_subscriptions",  "total_subscriptions_allowed"]
      properties:
        total_limit:
          type: integer
          description: total limit from fraud
          example: 4
        total_active_subscriptions:
          type: integer
          description: active subscription for request type and client
          example: 2
        total_subscriptions_allowed:
          type: integer
          description: subscriptions allowed for a client
          example: 2
        specific_limits:
          type: array
          description: subscriptions of each type allowed for a client
          items:
            type: object
            properties:
              type:
                description: Subscription Type
                type: string
                enum:
                  - BROADBAND
                  - FIXED
                  - MOBILE
                x-enum-varnames:
                  - BROADBAND
                  - FIXED
                  - MOBILE
              limit:
                description: Limit of subscriptions allowed
                type: integer
              active_subscriptions:
                description: Active subscriptions for a client
                type: integer
              subscriptions_allowed:
                description: Allowed subscriptions that return fraud
                type: integer
            example:
              - type: mobile
                limit: 3
                active_subscriptions: 2
                subscriptions_allowed: 1
              - type: fixed
                limit: 1
                active_subscriptions: 0
                subscriptions_allowed: 1
              - type: fixed
                limit: 1
                active_subscriptions: 0
                subscriptions_allowed: 1

    not_found_response:
      properties:
        code:
          type: string
          example: "0001"
        status:
          type: string
          example: NOT_FOUND
        message:
          type: string
          example: Resource Not Found
        detailMsg:
          type: string
          example: "{Entity} not found for id: {id}"
    bad_request_response:
      properties:
        code:
          type: string
          example: "0015"
        status:
          type: string
          example: BAD_REQUEST
        message:
          type: string
          example: Bad Request
        detailMsg:
          type: string
          example: "The field '{fieldName}' is required"
    error_response:
      properties:
        code:
          type: string
          example: "0002"
        status:
          type: string
          example: UNEXPECTED
        message:
          type: string
          example: Unexpected error
        detailMsg:
          type: string
          example: Unhandled exception
  securitySchemes:
    AuthnToken:
      type: http
      scheme: bearer
      bearerFormat: JWT