openapi: 3.0.3
info:
  title: Interface API Gamma Refonte
  description: Interface API Gamma Refonte
  version: 1.0.0
  contact:
    name: DGDDI - Douane Française
    url: https://www.douane.gouv.fr/

paths:
  # Chemin facultatif
  /871:
    post:
      summary: Définition d'un message 871
      operationId: message871
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BodyType871'
      parameters:
        - $ref: '../api/headerHttp.yaml#/components/parameters/messageId'
      responses:
        '200':
          description: OK
          content:
            text/plain:
              schema:
                $ref: '../api/retourHttp.yaml#/components/schemas/retour200'

components:
  schemas:
    BodyType871:
      type: object
      properties:
        ExplanationOnReasonForShortage:
          $ref: '#/components/schemas/ExplanationOnReasonForShortageType'
      required:
        - ExplanationOnReasonForShortage

    ExplanationOnReasonForShortageType:
      type: object
      properties:
        Attributes:
          $ref: '#/components/schemas/AttributesType871'
        ConsigneeTrader:
          $ref: '#/components/schemas/ConsigneeTraderType871'
        ExciseMovement:
          $ref: '#/components/schemas/ExciseMovementType871'
        ConsignorTrader:
          $ref: '#/components/schemas/ConsignorTraderType871'
        Analysis:
          $ref: '#/components/schemas/AnalysisType'
        BodyAnalysis:
          type: array
          maxItems: 999
          items:
            $ref: '#/components/schemas/BodyAnalysisType'
      required:
        - Attributes
        - ExciseMovement

    AttributesType871:
      type: object
      description: |
        | Nom de l'élément                               | Référentiels | Règles     | Conditions |
        |------------------------------------------------|--------------|------------|------------|
        | DateAndTimeOfValidationOfExplanationOnShortage |              | IC_RG_C149 | IC_RG_C149 |
        | TypeDeclarant                                  |              | FR_RG_R028 |            |
      properties:
        DateAndTimeOfValidationOfExplanationOnShortage:
          $ref: '../ie/types.yaml#/components/schemas/DateTimeType'
        TypeDeclarant:
          $ref: '../ie/tcl.yaml#/components/schemas/SubmitterType'
      required:
        - TypeDeclarant

    ConsigneeTraderType871:
      type: object
      description: |
        | Nom de l'élément | Référentiels  | Règles     | Conditions |
        |------------------|---------------|------------|------------|
        | Traderid         | IC_RG_R045    | IC_RG_C010 |            |
        | TraderName       |               |            |            |
        | StreetName       |               |            |            |
        | StreetNumber     |               |            |            |
        | PostCode         |               |            |            |
        | City             |               |            |            |
        | language         | Ref_28 (BC12) | IC_RG_C002 |            |
      properties:
        Traderid:
          $ref: '../ie/types.yaml#/components/schemas/TraderidType'
        TraderName:
          $ref: '../ie/types.yaml#/components/schemas/TraderNameType'
        StreetName:
          $ref: '../ie/types.yaml#/components/schemas/StreetNameType'
        StreetNumber:
          $ref: '../ie/types.yaml#/components/schemas/StreetNumberType'
        Postcode:
          $ref: '../ie/types.yaml#/components/schemas/PostcodeType'
        City:
          $ref: '../ie/types.yaml#/components/schemas/CityType'
        __language:
          $ref: '../ie/types.yaml#/components/schemas/LanguageCodeType'
      required:
        - TraderName
        - StreetName
        - Postcode
        - City

    ExciseMovementType871:
      type: object
      properties:
        AdministrativeReferenceCode:
          $ref: '../ie/types.yaml#/components/schemas/AdministrativeReferenceCodeType'
        SequenceNumber:
          $ref: '../ie/types.yaml#/components/schemas/SequenceNumberType'
      required:
        - AdministrativeReferenceCode
        - SequenceNumber

    ConsignorTraderType871:
      type: object
      description: |
        | Nom de l'élément   | Référentiels  | Règles     | Conditions |
        |--------------------|---------------|------------|------------|
        | TraderExciseNumber | IC_RG_R044    |            |            |
        | TraderName         |               |            |            |
        | StreetName         |               |            |            |
        | StreetNumber       |               |            |            |
        | PostCode           |               |            |            |
        | City               |               |            |            |
        | language           | Ref_28 (BC12) | IC_RG_C002 |            |
      properties:
        TraderExciseNumber:
          $ref: '../ie/types.yaml#/components/schemas/ExciseNumberType'
        TraderName:
          $ref: '../ie/types.yaml#/components/schemas/TraderNameType'
        StreetName:
          $ref: '../ie/types.yaml#/components/schemas/StreetNameType'
        StreetNumber:
          $ref: '../ie/types.yaml#/components/schemas/StreetNumberType'
        Postcode:
          $ref: '../ie/types.yaml#/components/schemas/PostcodeType'
        City:
          $ref: '../ie/types.yaml#/components/schemas/CityType'
        __language:
          $ref: '../ie/types.yaml#/components/schemas/LanguageCodeType'
      required:
        - TraderExciseNumber

    AnalysisType:
      type: object
      description: |
        | Nom de l'élément  | Référentiels | Règles | Conditions |
        |-------------------|--------------|--------|------------|
        | DateOfAnalysis    |              |        |            |
        | GlobalExplanation |              |        |            |
      properties:
        DateOfAnalysis:
          $ref: '../ie/types.yaml#/components/schemas/DateType'
        GlobalExplanation:
          $ref: '#/components/schemas/LSDGlobalExplanationType'
      required:
        - DateOfAnalysis
        - GlobalExplanation

    BodyAnalysisType:
      type: object
      description: |
        | Nom de l'élément          | Référentiels  | Règles                                  | Conditions |
        |---------------------------|---------------|-----------------------------------------|------------|
        | ExciseProductCode         |               | IC_RG_R049                              |            |
        | BodyRecordUniqueReference |               | IC_RG_R231<br>IC_RG_R232<br>IC_RG_BR041 |            |
        | Explanation               |               |                                         |            |
        | language                  | Ref_28 (BC12) | IC_RG_C002                              |            |
        | ActualQuantity            |               | IC_RG_R232                              |            |
      properties:
        ExciseProductCode:
          $ref: '../ie/types.yaml#/components/schemas/ExciseProductCodeType'
        BodyRecordUniqueReference:
          $ref: '../ie/types.yaml#/components/schemas/BodyRecordUniqueReferenceType'
        Explanation:
          $ref: '#/components/schemas/LSDExplanationType'
        ActualQuantity:
          $ref: '../ie/types.yaml#/components/schemas/ActualQuantityType'
      required:
        - ExciseProductCode
        - BodyRecordUniqueReference
        - Explanation

    LSDExplanationType:
      type: object
      properties:
        _content_:
          $ref: '../ie/types.yaml#/components/schemas/ExplanationType'
        __language:
          $ref: '../ie/types.yaml#/components/schemas/LanguageCodeType'
      required:
        - __language
        - _content_


    LSDGlobalExplanationType:
      type: object
      properties:
        _content_:
          $ref: '../ie/types.yaml#/components/schemas/GlobalExplanationType'
        __language:
          $ref: '../ie/types.yaml#/components/schemas/LanguageCodeType'
      required:
        - __language
        - _content_
