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

paths:
  # Chemin facultatif
  /840:
    post:
      summary: Définition d'un message 840
      operationId: message840
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BodyType840'
      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:
    BodyType840:
      type: object
      properties:
        EventReportEnvelope:
          $ref: '#/components/schemas/EventReportEnvelopeType'
      required:
        - EventReportEnvelope

    EventReportEnvelopeType:
      type: object
      properties:
        Attributes:
          $ref: '#/components/schemas/AttributesType840'
        HeaderEventReport:
          $ref: '#/components/schemas/HeaderEventReportType'
        EventReport:
          $ref: '#/components/schemas/EventReportType'
        EvidenceOfEvent:
          type: array
          maxItems: 9
          items:
            $ref: '#/components/schemas/EvidenceOfEventType'
        NewTransportArrangerTrader:
          $ref: '#/components/schemas/NewTransportArrangerTraderType840'
        NewTransporterTrader:
          $ref: '#/components/schemas/NewTransporterTraderType840'
        TransportDetails:
          type: array
          maxItems: 99
          items:
            $ref: '#/components/schemas/TransportDetailsType840'
        BodyEventReport:
          type: array
          maxItems: 99
          items:
            $ref: '#/components/schemas/BodyEventReportType'
      required:
        - Attributes
        - HeaderEventReport

    AttributesType840:
      type: object
      description: |
        | Nom de l'élément                     | Référentiels | Règles | Conditions |
        |--------------------------------------|--------------|--------|------------|
        | DateAndTimeOfValidationOfEventReport |              |        |            |
      properties:
        DateAndTimeOfValidationOfEventReport:
          $ref: '../ie/types.yaml#/components/schemas/DateTimeType'

    HeaderEventReportType:
      type: object
      description: |
        | Nom de l'élément                   | Référentiels | Règles                                 | Conditions |
        |------------------------------------|--------------|----------------------------------------|------------|
        | EventReportNumber                  |              | IC_RG_R071<br>IC_RG_R235<br>IC_RG_R274 | IC_RG_C080 |
        | MsOfSubmissionEventReportReference |              | IC_RG_R093                             | IC_RG_C080 |
        | AdministrativeReferenceCode        |              | IC_RG_R030<br>IC_RG_R273               |            |
        | SequenceNumber                     |              | IC_RG_R232                             |            |
        | ReferenceNumberOfExciseOffice      |              | IC_RG_R032<br>IC_RG_R036               |            |
        | MemberStateOfEvent                 |              |                                        |            |
      properties:
        EventReportNumber:
          $ref: '../ie/types.yaml#/components/schemas/EventReportNumberType'
        MsOfSubmissionEventReportReference:
          $ref: '../ie/types.yaml#/components/schemas/MsOfSubmissionEventReportReferenceType'
        ReferenceNumberOfExciseOffice:
          $ref: '../ie/types.yaml#/components/schemas/ExciseOfficeCodeType'
        MemberStateOfEvent:
          $ref: '../ie/types.yaml#/components/schemas/MemberStateCodeType'
        SequenceNumber:
          $ref: '../ie/types.yaml#/components/schemas/SequenceNumberType'
        AdministrativeReferenceCode:
          $ref: '../ie/types.yaml#/components/schemas/AdministrativeReferenceCodeType'

    EventReportType:
      type: object
      description: |
        | Nom de l'élément            | Référentiels  | Règles     | Conditions |
        |-----------------------------|---------------|------------|------------|
        | DateOfEvent                 |               |            |            |
        | PlaceOfEvent                |               |            |            |
        | PlaceOfEventLG              | Ref_28 (BC12) |            | IC_RG_C002 |
        | ExciseOfficerIdentification |               |            |            |
        | SubmittingPerson            |               | FR_RG_R052 |            |
        | SubmittingPersonCode        | Ref_16 (BC34) |            |            |
        | SubmittingPersonComplement  |               |            | IC_RG_C129 |
        | ChangedTransportArrangement | Ref_51 (TC70) |            |            |
        | Comments                    |               |            |            |
      properties:
        DateOfEvent:
          $ref: '../ie/types.yaml#/components/schemas/DateType'
        PlaceOfEvent:
          $ref: '#/components/schemas/LSDPlaceOfEventType'
        ExciseOfficerIdentification:
          $ref: '../ie/types.yaml#/components/schemas/ExciseOfficerIdentificationType'
        SubmittingPerson:
          $ref: '../ie/types.yaml#/components/schemas/SubmittingPersonType'
        SubmittingPersonCode:
          $ref: '../ie/types.yaml#/components/schemas/SubmittingPersonCodeType'
        SubmittingPersonComplement:
          $ref: '#/components/schemas/LSDSubmittingPersonComplementType'
        ChangedTransportArrangement:
          $ref: '../ie/tcl.yaml#/components/schemas/TransportArrangement'
        Comments:
          $ref: '#/components/schemas/LSDCommentsType'
      required:
        - DateOfEvent
        - SubmittingPerson
        - SubmittingPersonCode

    EvidenceOfEventType:
      type: object
      description: |
        | Nom de l'élément       | Référentiels  | Règles | Conditions |
        |------------------------|---------------|--------|------------|
        | IssuingAuthority       |               |        |            |
        | EvidenceTypeCode       | Ref_18 (BC01) |        |            |
        | ReferenceOfEvidence    | Ref_28 (BC12) |        |            |
        | ImageOfEvidence        |               |        |            |
        | EvidenceTypeComplement |               |        | IC_RG_C132 |
      properties:
        IssuingAuthority:
          $ref: '#/components/schemas/LSDIssuingAuthorityType'
        EvidenceTypeCode:
          $ref: '../ie/types.yaml#/components/schemas/EvidenceTypeCodeType'
        ReferenceOfEvidence:
          $ref: '#/components/schemas/LSDReferenceOfEvidenceType'
        ImageOfEvidence:
          type: string
          format: byte
        EvidenceTypeComplement:
          $ref: '#/components/schemas/LSDEvidenceTypeComplementType'
      required:
        - EvidenceTypeCode
        - ReferenceOfEvidence

    NewTransportArrangerTraderType840:
      type: object
      description: |
        | Nom de l'élément | Référentiels  | Règles | Conditions |
        |------------------|---------------|--------|------------|
        | VatNumber        |               |        |            |
        | TraderName       |               |        |            |
        | StreetName       |               |        |            |
        | StreetNumber     |               |        |            |
        | PostCode         |               |        |            |
        | City             |               |        |            |
        | language         | Ref_28 (BC12) |        |            |
      properties:
        VatNumber:
          $ref: '../ie/types.yaml#/components/schemas/VatNumberType'
        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
        - __language

    NewTransporterTraderType840:
      type: object
      description: |
        | Nom de l'élément             | Référentiels  | Règles | Conditions |
        |------------------------------|---------------|--------|------------|
        | TransportUnitCode            | Ref_53 (BC35) |        |            |
        | IdentityOfTransportUnits     |               |        | IC_RG_C156 |
        | CommercialSealIdentification |               |        |            |
        | ComplementaryInformation     |               |        |            |
        | SealInformation              |               |        |            |
        | language                     | Ref_28 (BC12) |        | IC_RG_C002 |
      properties:
        VatNumber:
          $ref: '../ie/types.yaml#/components/schemas/VatNumberType'
        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
        - __language

    TransportDetailsType840:
      type: object
      properties:
        TransportUnitCode:
          $ref: '../ie/types.yaml#/components/schemas/TransportUnitCodeType'
        IdentityOfTransportUnits:
          $ref: '../ie/types.yaml#/components/schemas/IdentityOfTransportUnitsType'
        CommercialSealIdentification:
          $ref: '../ie/types.yaml#/components/schemas/CommercialSealIdentificationType'
        ComplementaryInformation:
          $ref: '#/components/schemas/LSDComplementaryInformationType840'
        SealInformation:
          $ref: '#/components/schemas/LSDSealInformationType840'
      required:
        - TransportUnitCode

    BodyEventReportType:
      type: object
      description: |
        | Nom de l'élément            | Référentiels  | Règles                   | Conditions |
        |-----------------------------|---------------|--------------------------|------------|
        | EventTypeCode               | Ref_17 (BC15) |                          |            |
        | AssociatedInformation       |               |                          | IC_RG_C130 |
        | BodyRecordUniqueReference   |               | IC_RG_R058<br>IC_RG_R232 | IC_RG_C194 |
        | IndicatorOfShortageOrExcess | Ref_62 (TC47) |                          | IC_RG_C065 |
        | ObservedShortageOrExcess    |               | IC_RG_R232               | IC_RG_C065 |
      properties:
        EventTypeCode:
          $ref: '../ie/types.yaml#/components/schemas/EventTypeCodeType'
        AssociatedInformation:
          $ref: '#/components/schemas/LSDAssociatedInformationType'
        BodyRecordUniqueReference:
          $ref: '../ie/types.yaml#/components/schemas/BodyRecordUniqueReferenceType'
        IndicatorOfShortageOrExcess:
          $ref: '../ie/tcl.yaml#/components/schemas/IndicatorOfShortageOrExcess'
        ObservedShortageOrExcess:
          $ref: '../ie/types.yaml#/components/schemas/ObservedShortageOrExcessType'
      required:
        - EventTypeCode


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


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


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


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


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


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


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


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

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


