swagger: '2.0'
info:
  version: 1.1.0
  title: IO Function Backoffice
  contact:
    name: IO team
    url: https://forum.italia.it/c/progetto-io
  x-logo:
    url: https://io.italia.it/assets/img/io-logo-blue.svg
  description: |
    Documentation of the io-function-backoffice
host: backoffice-api.io.italia.it
basePath: /api/v1
schemes:
  - https
security:
  - Bearer: []
paths:
  /bpd/citizen:
    get:
      operationId: GetBPDCitizen
      summary: Get BPD Citizen info
      description: Get the Citizen BPD info
      parameters:
        - $ref: '#/parameters/CitizenID'
      responses:
        '200':
          description: Found.
          schema:
            $ref: '#/definitions/BPDCitizen'
          examples:
            application/json:
              fiscal_code: AAABBB01C02D345A
              timestamp_tc: '2011-10-05T14:48:00.000Z'
              payoff_instr: IT90M0300203280482653729744
              payoff_instr_type: IBAN
              enabled: 'true'
              insert_date: '2011-10-05T14:48:00.000Z'
              insert_user: Bank
              update_date: '2011-10-05T14:48:00.000Z'
              update_user: Bank
              payment_methods:
                - payment_instrument_hpan: >-
                    9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
                  payment_instrument_status: ACTIVE
                  payment_instrument_insert_date: '2011-10-05T14:48:00.000Z'
                  payment_instrument_insert_user: Bank
                  payment_instrument_update_date: '2011-10-05T14:48:00.000Z'
                  payment_instrument_update_user: Bank
        '400':
          description: Invalid request.
          schema:
            $ref: '#/definitions/ProblemJson'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
          schema:
            $ref: '#/definitions/ProblemJson'
        '404':
          description: Not found.
          schema:
            $ref: '#/definitions/ProblemJson'
        '429':
          description: Rate Limit exceeded
        '500':
          description: Internal server Error
          schema:
            $ref: '#/definitions/ProblemJson'
  /bpd/transactions:
    get:
      operationId: GetBPDTransactions
      summary: Get BPD transactions info list
      description: Get the BPD transactions info list
      parameters:
        - $ref: '#/parameters/CitizenID'
      responses:
        '200':
          description: Found.
          schema:
            $ref: '#/definitions/BPDTransactionList'
        '400':
          description: Invalid request.
          schema:
            $ref: '#/definitions/ProblemJson'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
          schema:
            $ref: '#/definitions/ProblemJson'
        '429':
          description: Rate Limit exceeded
        '500':
          description: Internal server Error
          schema:
            $ref: '#/definitions/ProblemJson'
  /bpd/payment-instruments/{hpan}:
    get:
      operationId: GetBPDPaymentInstrument
      summary: Get BPD hpan detail
      description: Get BPD hpan detail related to a fiscal code
      parameters:
        - $ref: '#/parameters/CitizenID'
        - name: hpan
          in: path
          type: string
          required: true
          description: The hpan of a payment instrument
      responses:
        '200':
          description: Found.
          schema:
            $ref: '#/definitions/PaymentMethodDetails'
        '400':
          description: Invalid request.
          schema:
            $ref: '#/definitions/ProblemJson'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
          schema:
            $ref: '#/definitions/ProblemJson'
        '404':
          description: Not found.
          schema:
            $ref: '#/definitions/ProblemJson'
        '500':
          description: Internal server Error
          schema:
            $ref: '#/definitions/ProblemJson'
  /bpd/awards:
    get:
      operationId: GetBPDAwards
      summary: Get BPD awards list
      description: Get BPD awards list related to a fiscal code
      parameters:
        - $ref: '#/parameters/CitizenID'
      responses:
        '200':
          description: Found.
          schema:
            $ref: '#/definitions/AwardsList'
        '400':
          description: Invalid request.
          schema:
            $ref: '#/definitions/ProblemJson'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
          schema:
            $ref: '#/definitions/ProblemJson'
        '404':
          description: Not found.
          schema:
            $ref: '#/definitions/ProblemJson'
        '429':
          description: Rate Limit exceeded
        '500':
          description: Internal server Error
          schema:
            $ref: '#/definitions/ProblemJson'
consumes:
  - application/json
produces:
  - application/json
definitions:
  FiscalCode:
    type: string
    description: User's fiscal code.
    format: FiscalCode
    x-import: italia-ts-commons/lib/strings
    example: SPNDNL80R13C555X
  ProblemJson:
    type: object
    properties:
      type:
        type: string
        format: uri
        description: |-
          An absolute URI that identifies the problem type. When dereferenced,
          it SHOULD provide human-readable documentation for the problem type
          (e.g., using HTML).
        default: about:blank
        example: https://example.com/problem/constraint-violation
      title:
        type: string
        description: |-
          A short, summary of the problem type. Written in english and readable
          for engineers (usually not suited for non technical stakeholders and
          not localized); example: Service Unavailable
      status:
        type: integer
        format: int32
        description: >-
          The HTTP status code generated by the origin server for this
          occurrence

          of the problem.
        minimum: 100
        maximum: 600
        exclusiveMaximum: true
        example: 200
      detail:
        type: string
        description: |-
          A human readable explanation specific to this occurrence of the
          problem.
        example: There was an error processing the request
      instance:
        type: string
        format: uri
        description: >-
          An absolute URI that identifies the specific occurrence of the
          problem.

          It may or may not yield further information if dereferenced.
  PaymentMethodStatus:
    type: string
    enum:
      - ACTIVE
      - INACTIVE
  PaymentMethodDetails:
    type: object
    properties:
      fiscal_code:
        $ref: '#/definitions/FiscalCode'
      hpan:
        type: string
      channel:
        type: string
      channel_descr:
        type: string
        enum:
          - BancaSella
          - BancaSella_Other
          - Poste
          - SatisPay
          - EnelX
          - BancomatPay
          - Flowe
          - Nexi_YAP
          - Nexi_Issuing_diretto
          - Nexi_Other
          - Hype
          - AppIO
          - Other
      enabled:
        type: boolean
      update_date:
        type: string
        format: dateTime
      insert_date:
        type: string
        format: dateTime
      update_user:
        type: string
      insert_user:
        type: string
      activation_periods:
        type: array
        items:
          $ref: '#/definitions/ActivationPeriods'
    required:
      - fiscal_code
      - hpan
      - activation_periods
      - enabled
  ActivationPeriods:
    type: object
    properties:
      enrollment:
        type: string
        format: dateTime
      cancellation:
        type: string
        format: dateTime
      hist_insert_date:
        type: string
        format: dateTime
      hist_insert_user:
        type: string
      hist_update_date:
        type: string
        format: dateTime
      hist_update_user:
        type: string
      status:
        $ref: '#/definitions/PaymentMethodStatus'
    required:
      - enrollment
      - status
  BPDCitizen:
    type: object
    properties:
      fiscal_code:
        $ref: '#/definitions/FiscalCode'
      timestamp_tc:
        type: string
        format: dateTime
      payoff_instr:
        type: string
      payoff_instr_type:
        type: string
      insert_date:
        type: string
        format: dateTime
      insert_user:
        type: string
      update_date:
        type: string
        format: dateTime
      update_user:
        type: string
      enabled:
        type: boolean
      checkiban_fiscal_code:
        type: string
      checkiban_name:
        type: string
      checkiban_surname:
        type: string
      checkiban_status:
        type: string
      cancellation:
        type: string
        format: dateTime
      payment_methods:
        type: array
        items:
          $ref: '#/definitions/PaymentMethod'
    required:
      - fiscal_code
      - timestamp_tc
      - payment_methods
  PaymentMethod:
    type: object
    properties:
      payment_instrument_hpan:
        type: string
      payment_instrument_status:
        $ref: '#/definitions/PaymentMethodStatus'
      payment_instrument_insert_date:
        type: string
        format: dateTime
      payment_instrument_insert_user:
        type: string
      payment_instrument_update_date:
        type: string
        format: dateTime
      payment_instrument_update_user:
        type: string
      payment_instrument_enabled:
        type: boolean
    required:
      - payment_instrument_hpan
      - payment_instrument_status
  SupportToken:
    type: string
    pattern: ^[A-Za-z0-9-_=]+[.][A-Za-z0-9-_=]+[.][A-Za-z0-9-_.+/=]*$
    description: A JWT token used by Support Team
  CitizenID:
    description: Fiscal Code or Support Token for Citizen Identification
    x-one-of: true
    allOf:
      - $ref: '#/definitions/FiscalCode'
      - $ref: '#/definitions/SupportToken'
  BPDTransactionList:
    type: object
    properties:
      transactions:
        type: array
        items:
          $ref: '#/definitions/BPDTransaction'
    required:
      - transactions
  BPDTransaction:
    type: object
    properties:
      hpan:
        type: string
      trx_timestamp:
        type: string
        format: dateTime
      acquirer_id:
        type: string
      acquirer:
        type: string
      acquirer_descr:
        type: string
        enum:
          - Nexi
          - IntesaSanPaolo
          - Poste
          - Unicredit
          - BancaSella
          - Nexi_UBI
          - Nexi_ICCREA
          - AmericanExpress
          - SatisPay
          - ICCREA
          - Diners
          - Axepta_BNP
          - SumUP
          - Bancomat
          - BancomatPay
          - SiaPay
          - Paytipper
          - Reiffeisen
          - Cedacri
          - Deutsche
          - MPS
          - EquensWorldline
          - Other
      id_trx_acquirer:
        type: string
      id_trx_issuer:
        type: string
      operation_type:
        type: string
      operation_type_descr:
        type: string
        enum:
          - Payment
          - Transfer
          - ApplePay
          - GooglePay
          - Other
      circuit_type:
        type: string
      circuit_type_descr:
        type: string
        enum:
          - Pagobancomat
          - Visa
          - Mastercard
          - Amex
          - JCB
          - UnionPay
          - Diners
          - Codice_PostePay
          - BancomatPay
          - SatisPay
          - Circuito_Privativo
          - Other
      amount:
        type: number
      amount_currency:
        type: string
      amount_currency_descr:
        type: string
      score:
        type: number
      award_period_id:
        type: number
      merchant_id:
        type: string
      correlation_id:
        type: string
      bin:
        type: string
      terminal_id:
        type: string
      enabled:
        type: boolean
      elab_ranking:
        type: boolean
      insert_date:
        type: string
        format: dateTime
      insert_user:
        type: string
      update_date:
        type: string
        format: dateTime
      update_user:
        type: string
    required:
      - acquirer
      - id_trx_acquirer
      - trx_timestamp
      - hpan
  AwardPeriod:
    type: object
    properties:
      award_winner_id:
        type: number
      award_winner_period_id:
        type: number
      award_winner_payoff_instr:
        type: string
      award_winner_amount:
        type: number
      award_winner_period_start:
        type: string
        format: dateTime
      award_winner_period_end:
        type: string
        format: dateTime
      award_winner_jackpot:
        type: number
      award_winner_cashback:
        type: number
      award_winner_typology:
        type: string
      award_winner_account_holder_cf:
        type: string
      award_winner_account_holder_name:
        type: string
      award_winner_account_holder_surname:
        type: string
      award_winner_check_instr_status:
        type: string
      award_winner_insert_date:
        type: string
        format: dateTime
      award_winner_insert_user:
        type: string
      award_winner_update_date:
        type: string
        format: dateTime
      award_winner_update_user:
        type: string
      award_winner_enabled:
        type: boolean
      citizen_ranking_period_id:
        type: number
      citizen_ranking_cashback:
        type: number
      citizen_ranking_transaction:
        type: number
      citizen_ranking_ranking:
        type: number
      citizen_ranking_ranking_date:
        type: string
        format: dateTime
      citizen_ranking_insert_date:
        type: string
        format: dateTime
      citizen_ranking_insert_user:
        type: string
      citizen_ranking_update_date:
        type: string
        format: dateTime
      citizen_ranking_update_user:
        type: string
      citizen_ranking_enabled:
        type: boolean
      award_period_id:
        type: number
      award_period_start:
        type: string
        format: dateTime
      award_period_end:
        type: string
        format: dateTime
      award_period_grace_period:
        type: number
      award_period_amount_max:
        type: number
      award_period_trx_volume_min:
        type: number
      award_period_trx_eval_max:
        type: number
      award_period_ranking_min:
        type: number
      award_period_trx_cashback_max:
        type: number
      award_period_cashback_max:
        type: number
      award_period_cashback_perc:
        type: number
      award_period_insert_date:
        type: string
        format: dateTime
      award_period_insert_user:
        type: string
      award_period_update_date:
        type: string
        format: dateTime
      award_period_update_user:
        type: string
      award_period_enabled:
        type: boolean
    required:
      - award_period_id
      - award_period_start
      - award_period_end
      - award_period_grace_period
      - award_period_amount_max
      - award_period_trx_volume_min
      - award_period_trx_eval_max
      - award_period_ranking_min
      - award_period_trx_cashback_max
      - award_period_cashback_max
      - award_period_cashback_perc
  AwardsList:
    type: object
    properties:
      fiscal_code:
        $ref: '#/definitions/FiscalCode'
      awards:
        type: array
        items:
          $ref: '#/definitions/AwardPeriod'
    required:
      - fiscal_code
      - awards
parameters:
  CitizenID:
    name: x-citizen-id
    in: header
    description: The fiscal code of the user or the JWT' s support token
    type: string
    required: true
securityDefinitions:
  Bearer:
    type: apiKey
    name: Authorization
    in: header
