swagger: '2.0'
info:
  version: '1.0'
  title: Spécification des API PSA
  description: Spécification des API PSA
  contact: {}
host: psa-rct.d.opencell.work
basePath: /opencell/inbound/flexi
schemes:
  - http
consumes:
  - application/json
produces:
  - application/json
paths:
  /pull:
    post:
      description: 'API permettant la consommation du compte Flexi-mobilité'
      summary: F4 - Tirage des points Flexi-mobilité
      tags:
        - Tirage
      operationId: PullPost
      produces:
        - application/json
      parameters:
        - name: Content-Type
          in: header
          required: true
          type: string
          description: 'application/json'
        - name: Body
          in: body
          required: true
          description: ''
          schema:
            $ref: '#/definitions/TirageRequest'
      responses:
        '200':
          description: 'OK Result'
          schema:
            $ref: '#/definitions/TirageResponse'
          headers: {}
        '500':
          description: 'Internal error'
          schema:
            $ref: '#/definitions/InternalErrorResponse'
          headers: {}
      security: []
  /balance:
    post:
      summary: F5 - Consultation balance
      consumes:
        - application/json
      description: F5 - API de consultation du solde du compte Flexi-mobilité
      tags:
        - Consultation balance
      operationId: BalancePost
      produces:
        - application/json
      parameters:
        - name: Content-Type
          in: header
          required: true
          type: string
          description: 'application/json'
        - name: Body
          in: body
          required: true
          description: ''
          schema:
            $ref: '#/definitions/ConsultationRequest'
      responses:
        '200':
          description: 'OK Result'
          schema :
            $ref: '#/definitions/ConsultationResponse'
          headers: {}
        '500':
          description: 'Internal error'
          schema:
            $ref: '#/definitions/InternalErrorResponse'

  /simulate:
    post:
      description: 'F4" - API pour la simulation d''une opération de tirage'
      summary: 'F4" - Simulation de tirage'
      tags:
        - Simulation tirage
      operationId: SimulatePost
      produces:
        - application/json
      parameters:
        - name: Content-Type
          in: header
          required: true
          type: string
          description: 'application/json'
        - name: Body
          in: body
          required: true
          description: ''
          schema:
            $ref: "#/definitions/SimulationRequest"
      responses:
        '200':
          description: 'OK Result'
          schema :
            $ref: '#/definitions/SimulationResponse'
          headers: {}
        '500':
          description: 'Internal error'
          schema:
            $ref: '#/definitions/InternalErrorResponse'
          headers: {}
      security: []
  /cancel:
    post:
      description: F4' - API permettant l'annulation d'un tirage sur le compte Flexi-mobilité
      summary: F4' - Annulation de tirage
      tags:
        - Annulation tirage
      operationId: CancelPost
      produces:
        - application/json
      parameters:
        - name: Content-Type
          in: header
          required: true
          type: string
          description: 'application/json'
        - name: Body
          in: body
          required: true
          description: ''
          schema:
            $ref: "#/definitions/AnnulationRequest"
      responses:
        '200':
          description: ''
          headers: {}
          schema:
            $ref: "#/definitions/AnnulationResponse"
        '500':
          description: 'Internal error'
          schema:
            $ref: '#/definitions/InternalErrorResponse'
          headers: {}
      security: []
definitions:
  TirageRequest:
    title: F4 - TirageRequest
    example:
      subscriptionId: 101G4953427
      countryCode: FR
      seesionId: b3BlbjEwMUc2NTk5OTc3Y2VsbA==
      lang: FRA
      vin: QEJDBMMWX000FR000
      email: client.test@mpsa.fr
      eventId: '987654321'
      eventDate: '2018-05-21T18:01:57'
      eventOrigin: RENT_FR
      retailerId: 'FVSPFR'
      amountPoints: 362.41
      parameters:
        - code: duration
          value: '3'
        - code: brand
          value: Peugeot
        - code: model
          value: '3008'
        - code: note
          value: 'Bleu métalisé, boite auto'
    type: object
    properties:
      subscriptionId:
        type: string
      countryCode:
        type: string
      sessionId:
        type: string
      lang:
        type: string
      vin:
        type: string
      email:
        type: string
      eventId:
        type: string
      eventDate:
        type: string
      eventOrigin:
        type: string
      retailerId:
        type: string
      amountPoints:
        type: number
        format: double
      parameters:
        type: array
        items:
          title: Parameter
          type: object
          properties:
            code:
              example: duration
              type: string
            value:
              example: 3
              type: string
          required:
            - code
            - value
    required:
      - subscriptionId or vin
      - countryCode
      - sessionId
      - email
      - eventId
      - eventDate
      - eventOrigin
      - retailerId
      - amountPoints
      - parameters
  TirageResponse:
    title: 'F4 - TirageResponse'
    example:
      result:
        code: OK
        lang: FRA
        message: OK
      data:
        eventId: '987654321'
        balance: 272.85
        countryCode: FR
        amountPoints: 10.75
        requestDate: '2019-11-12'
        sessionId: b3BlblFXRk5BT0VLTTAwY2VsbA==
        subscriptionId: QWFNAOEKM00
        status: ACTIVE
        expiringBalance: 0
        expirationDate: '2023-06-24'
    type: object
  ConsultationRequest:
    title: F5 - ConsultationRequest
    example:
      souscriptionId: QWFNAOEKM00
      countryCode: FR
      sessionId: "b3BlbjEwMUc2NTk5OTc3Y2VsbA"
      email: client.test@mpsa.fr
      vin: QWFNAOEKM000FR000
      lang: FRA
      brandId: AP
      retailerId: QWFN0FR
      includeHistory: true
      historyLength: 0
    type: object
    properties:
      subscriptionId:
        type: string
      countryCode:
        type: string
      sessionId:
        type: string
      lang:
        type: string
      vin:
        type: string
      brandId:
        type: string
      email:
        type: string
      includeHistory:
        type: boolean
      historyLength:
        type: integer
        format: int32
    required:
      - subscriptionId
      - countryCode
      - sessionId
      - lang
      - vin
      - brandId
      - email
  ConsultationResponse :
    title : 'F5 - ConsultationResponse'
    example :
      result:
        code: Ok
        lang: FRA
        message: OK
      data:
        subscriptionId: 123456789
        countryCode: FR
        sessionId: 055d2c3bb2b5539585a12d57afe5391c
        brandId: 987654321
        status: ACTIVE
        balance:  100.0
        expirationDate: 2019-03-12
        discountCode: REM10
        details:
          eventCode: USAGE
          eventId: 987654321
          eventDate: 2018-06-15
          eventOrigin: RENT_FR
          retailerId: PEUGEOT_GENNEVILLIERS_001
          retailerDesc: Concession Peugeot Gennevilliers
          amountPoints:  250.0
          status: RESERVED
          description: Tirage
          parameters: [
          { code: duration,
            value: 3
          },
          { code: brand,
            value: Peugeot
          },
          { code: model,
            value: 3008
          },
          { code: note,
            value: Bleu métallisé boite auto
          }
          ]
  SimulationRequest:
    title: F4" - SimulationRequest
    example:
      subscriptionId: 'TNRM008953'
      countryCode: "FR"
      sessionId: ''
      vin: ''
      email: 'client.france@gmail.fr'
      lang: FRA
      amountCurrency: 362.41
      retailerId: "FVSPFR"
      eventDate: "2019-11-29T11:01:57"
    type: object
    properties:
      subscriptionId:
        type: string
      countryCode:
        type: string
      sessionId:
        type: string
      lang:
        type: string
      vin:
        type: string
      email:
        type: string
      retailerId:
        type: string
      amountCurrency:
        type: number
        format: double
      eventDate:
        type: string
        format: "yyyy-MM-ddThh:mm:ss"
    required:
      - subscriptionId or vin
      - countryCode
      - sessionId
      - email
      - lang
      - retailerId
      - amountCurrency
      - eventDate
  SimulationResponse :
    title : 'F4" - SimulationResponse'
    example :
      result:
        code: SUCCESS
        lang: FRA
        message: OK
      countryCode: 'FR'
      data:
        subscriptionId: 'QEJDBMMWX00'
        sessionId: "QVpFUlRZVUlPUFFTREZHSEpLTE1XWENWQk4="
        status: ACTIVE
        amountWithTax: 130
        balance: 100
      type: object
  AnnulationRequest:
    title: F4' - AnnulationRequest
    example: {
      "countryCode": "FR",
      "eventId": "987654321"
    }
    type: object
    properties:
      countryCode:
        type: string
      eventId:
        type: string
    required:
      - countryCode
      - eventId
  AnnulationResponse :
    title: F4' - AnnulationResponse
    example:
      result:
        code: SUCCESS
        message: ''
      data:
        subscriptionId: '123456789'
        countryCode: FR
        status: ACTIVE
        amountPoints: 130
        balance: 100
        expirationDate: '2019-03-12'
  InternalErrorResponse :
    title: 'Internal Error response'
    example:
      code: 'INTERNAL_ERROR'
      lang: 'FRA'
      message: 'Internal error description'
    type: object
    properties:
      code:
        type: string
      lang:
        type: string
      message:
        type: string
      countryCode:
        type: string
tags:
  - name: Tirage
    description: API permettant le tirage des points du compte Flexi-mobilité
  - name: Consultation balance
    description: API de consultation du solde du compte Flexi-mobilité
  - name: Simulation tirage
    description: API pour la simulation d'une opération de tirage
  - name: Annulation tirage
    description: API permettant l'annulation d'un tirage sur le compte Flexi-mobilité