Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

API.Routes.DatStore

Mestre-Tramador edited this page Aug 29, 2022 · 1 revision

Store Dat(s) POST

/dat

Multiple .dat files can be stored at once.

Headers

Name Value Description
Content-Type multipart/form-data As the files are required, a FormData shall be sent.

Request Body

The only mandatory specification is that at least one of the sent files shall be a Dat file.

Response

201

[
  {
    "file": "ok.dat",
    "name": "200.dat",
    "data": {
      "sellers": [
        {
          "cpf": "143.434.670-66",
          "name": "João Silva",
          "wage": 1250.64
        }
      ],
      "customers": [
        {
          "cnpj": "02.820.494/0001-86",
          "name": "Eduardo Fraga",
          "branch": "Pesca"
        }
      ],
      "sales": [
        {
          "id": 475,
          "items": [
            {
              "id": 2201,
              "quantity": 5,
              "price": 60.99
            }
          ],
          "seller": "João Silva"
        },
        {
          "id": 492,
          "items": [
            {
              "id": 1335,
              "quantity": 4,
              "price": 21.50
            },
            {
              "id": 1337,
              "quantity": 1,
              "price": 16.50
            }
          ],
          "seller": "João Silva"
        },
      ]
    }
  }
]

Each item represents an uploaded file, having its success. Note that the quantity of items returned is equal of the uploaded files, and alongside the successes errors can be returned. The 201 code is not altered if at least one success occurred.

The data is the same of the Read route, which requires the ID (number) on the name returned.

422

[
  {
    "file": "invalid.dat",
    "error": "Incorrect formatted data"
  },
  {
    "file": "unsaved.dat",
    "error": "Could not save file"
  },
  {
    "file": "no-stored.dat",
    "error": "File was not stored"
  }
]

Each item represents an uploaded file, having different errors. Note that the quantity of items returned is equal of the uploaded files, and the errors can be the same of differ alongside the files.

Clone this wiki locally