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
  /839:
    post:
      summary: Définition d'un message 839
      operationId: message839
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BodyType839'
      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:
    BodyType839:
      type: object
      properties:
        RefusalByCustoms:
          $ref: '#/components/schemas/RefusalByCustomsType839'
      required:
        - RefusalByCustoms

    RefusalByCustomsType839:
      type: object
      properties:
        Attributes:
          $ref: '#/components/schemas/AttributesType839'
        ConsigneeTrader:
          $ref: '#/components/schemas/ConsigneeTraderType839'
        ExportPlaceCustomsOffice:
          $ref: '#/components/schemas/ExportPlaceCustomsOfficeType839'
        Rejection:
          $ref: '#/components/schemas/RejectionType839'
        ExportDeclarationInformation:
          $ref: '#/components/schemas/ExportDeclarationInformationType839'
        CEadVal:
          type: array
          minItems: 0
          maxItems: 999
          items:
            $ref: '#/components/schemas/CEadValType839'
      required:
        - Attributes
        - ConsigneeTrader
        - Rejection

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

    ConsigneeTraderType839:
      type: object
      description: |
        | Nom de l'élément | Référentiels  | Règles                                 | Conditions |
        |------------------|---------------|----------------------------------------|------------|
        | TraderName       |               | IC_RG_R045<br>IC_RG_R271<br>IC_RG_R272 | IC_RG_C010 |
        | StreetName       |               |                                        |            |
        | Postcode         |               |                                        |            |
        | City             |               |                                        |            |
        | EoriNumber       |               |                                        | IC_RG_C180 |
        | language         | BC12 (Ref_28) |                                        |            |
      properties:
        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'
        EoriNumber:
          $ref: '../ie/types.yaml#/components/schemas/EoriNumberType'
        __language:
          $ref: '../ie/types.yaml#/components/schemas/LanguageCodeType'
      required:
        - TraderName
        - StreetName
        - Postcode
        - City
        - __language

    ExportPlaceCustomsOfficeType839:
      type: object
      description: |
        | Nom de l'élément | Référentiels | Règles                   | Conditions |
        |------------------|--------------|--------------------------|------------|
        | ReferenceNumber  |              | IC_RG_R032<br>IC_RG_R236 |            |
      properties:
        ReferenceNumber:
          $ref: '../ie/types.yaml#/components/schemas/ExciseOfficeCodeType'
      required:
        - ReferenceNumber

    RejectionType839:
      type: object
      description: |
        | Nom de l'élément     | Référentiels  | Règles | Conditions |
        |----------------------|---------------|--------|------------|
        | RejectionDateAndTime |               |        |            |
        | RejectionReasonCode  | TC18 (Ref_11) |        |            |
      properties:
        RejectionDateAndTime:
          $ref: '../ie/types.yaml#/components/schemas/DateTimeType'
        RejectionReasonCode:
          $ref: '../ie/tcl.yaml#/components/schemas/CustomsRejectionReasonCode'
      required:
        - RejectionDateAndTime
        - RejectionReasonCode

    ExportDeclarationInformationType839:
      type: object
      description: |
        | Nom de l'élément                    | Référentiels | Règles     | Conditions |
        |-------------------------------------|--------------|------------|------------|
        | LocalReferenceNumber                |              |            | IC_RG_C147 |
        | DocumentReferenceNumber             |              | IC_RG_R100 | IC_RG_C147 |
        | NegativeCrosscheckValidationResults |              |            | IC_RG_C212 |
        | NNonDes                             |              |            |            |
      properties:
        LocalReferenceNumber:
          $ref: '../ie/types.yaml#/components/schemas/LocalReferenceNumberType'
        DocumentReferenceNumber:
          $ref: '../ie/types.yaml#/components/schemas/DocumentReferenceNumberType'
        NegativeCrosscheckValidationResults:
          type: array
          minItems: 0
          maxItems: 99
          items:
            $ref: '#/components/schemas/NegativeCrosscheckValidationResultsTypeType839'
        NNonDes:
          $ref: '#/components/schemas/NNonDesTypeType839'

    NegativeCrosscheckValidationResultsTypeType839:
      description: |
        | Nom de l'élément    | Référentiels | Règles | Conditions |
        |---------------------|--------------|--------|------------|
        | UbrCrosscheckResult |              |        |            |
      properties:
        UbrCrosscheckResult:
          type: array
          maxItems: 999
          items:
            $ref: '#/components/schemas/UbrCrosscheckResultTypeType839'
      required:
        - UbrCrosscheckResult

    UbrCrosscheckResultTypeType839:
      type: object
      description: |
        | Nom de l'élément                         | Référentiels  | Règles     | Conditions |
        |------------------------------------------|---------------|------------|------------|
        | AdministrativeReferenceCode              |               | IC_RG_R030 |            |
        | BodyRecordUniqueReference                |               |            |            |
        | DiagnosisCode                            | TC72 (Ref_14) |            |            |
        | ValidationResult                         | TC27 (Ref_99) |            |            |
        | RejectionReason                          |               |            |            |
        | CombinedNomenclatureCodeCrosscheckResult |               |            | IC_RG_C213 |
        | NetMassCrosscheckResult                  |               |            | IC_RG_C213 |
      properties:
        AdministrativeReferenceCode:
          $ref: '../ie/types.yaml#/components/schemas/AdministrativeReferenceCodeType'
        BodyRecordUniqueReference:
          $ref: '../ie/types.yaml#/components/schemas/BodyRecordUniqueReferenceType'
        DiagnosisCode:
          $ref: '../ie/tcl.yaml#/components/schemas/DiagnosisCode'
        ValidationResult:
          $ref: '../ie/tcl.yaml#/components/schemas/Flag'
        RejectionReason:
          $ref: '../ie/types.yaml#/components/schemas/RejectionReasonType'
        CombinedNomenclatureCodeCrosscheckResult:
          $ref: '#/components/schemas/CombinedNomenclatureCodeCrosscheckResultType839'
        NetMassCrosscheckResult:
          $ref: '#/components/schemas/NetMassCrosscheckResultType839'
      required:
        - AdministrativeReferenceCode
        - BodyRecordUniqueReference
        - DiagnosisCode
        - ValidationResult

    CombinedNomenclatureCodeCrosscheckResultType839:
      type: object
      description: |
        | Nom de l'élément | Référentiels  | Règles | Conditions |
        |------------------|---------------|--------|------------|
        | ValidationResult | TC27 (Ref_99) |        |            |
        | RejectionReason  |               |        |            |
      properties:
        ValidationResult:
          $ref: '../ie/tcl.yaml#/components/schemas/Flag'
        RejectionReason:
          $ref: '../ie/types.yaml#/components/schemas/RejectionReasonType'
      required:
        - ValidationResult

    NetMassCrosscheckResultType839:
      type: object
      description: |
        | Nom de l'élément | Référentiels  | Règles | Conditions |
        |------------------|---------------|--------|------------|
        | ValidationResult | TC27 (Ref_99) |        |            |
        | RejectionReason  |               |        |            |
      properties:
        ValidationResult:
          $ref: '../ie/tcl.yaml#/components/schemas/Flag'
        RejectionReason:
          $ref: '../ie/types.yaml#/components/schemas/RejectionReasonType'
      required:
        - ValidationResult

    NNonDesTypeType839:
      type: object
      description: |
        | Nom de l'élément | Référentiels | Règles | Conditions |
        |------------------|--------------|--------|------------|
        | NnonDesType      |              |        |            |
      properties:
        DocumentReferenceNumber:
          $ref: '../ie/types.yaml#/components/schemas/DocumentReferenceNumberType'
      required:
        - DocumentReferenceNumber

    CEadValType839:
      type: object
      description: |
        | Nom de l'élément            | Référentiels | Règles                   | Conditions |
        |-----------------------------|--------------|--------------------------|------------|
        | AdministrativeReferenceCode |              | IC_RG_R030<br>IC_RG_R232 |            |
        | SequenceNumber              |              |                          |            |
      properties:
        AdministrativeReferenceCode:
          $ref: '../ie/types.yaml#/components/schemas/AdministrativeReferenceCodeType'
        SequenceNumber:
          $ref: '../ie/types.yaml#/components/schemas/SequenceNumberType'
      required:
        - AdministrativeReferenceCode
        - SequenceNumber
