From 009921704b0c7b75206341ef20b1f540c31e366c Mon Sep 17 00:00:00 2001 From: Koen van Staveren Date: Mon, 19 Feb 2024 10:19:37 +0100 Subject: [PATCH] feat: batch endpoints added (#8) * feat: batch endpoints * chore: implement pr feedback * test: run batch tests last --- docs/Batch.md | 164 +++++++++ docs/CsvOrder.md | 42 +-- docs/PrintOne.md | 133 +++++++- jest.config.js | 1 + package-lock.json | 103 +----- package.json | 1 + src/AxiosHttpHandler.ts | 26 ++ src/HttpHandler.ts | 13 + src/PrintOne.ts | 126 ++++++- src/enums/BatchStatus.ts | 19 ++ src/index.ts | 1 + src/models/Batch.ts | 160 +++++++++ src/models/CsvOrder.ts | 2 +- src/models/_interfaces/IBatch.ts | 20 ++ src/utils.ts | 15 + test/Batch.spec.ts | 296 ++++++++++++++++ test/CsvOrder.spec.ts | 4 +- test/CustomHttpHandler.spec.ts | 15 +- test/Order.spec.ts | 3 - test/PrintOne.spec.ts | 570 +++++++++++++++++++++++++++++-- testSequencer.js | 18 + 21 files changed, 1573 insertions(+), 159 deletions(-) create mode 100644 docs/Batch.md create mode 100644 src/enums/BatchStatus.ts create mode 100644 src/models/Batch.ts create mode 100644 src/models/_interfaces/IBatch.ts create mode 100644 test/Batch.spec.ts create mode 100644 testSequencer.js diff --git a/docs/Batch.md b/docs/Batch.md new file mode 100644 index 0000000..d5a8c06 --- /dev/null +++ b/docs/Batch.md @@ -0,0 +1,164 @@ +Contains all information about a given Batch + +# Fields + +| Name | Type | Description | +| ---------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id` | `string` | The ID of the batch. | +| `companyId` | `string` | The ID of the company the batch belongs to. | +| `Name` | `string` | The name of the batch. | +| `billingId` | `string` \| `undefined` | The ID assigned to the batch by the customer. | +| `finish` | `string` | The finish of the batch. Can be `GLOSSY` or `MATT`. | +| `isBillable` | `boolean` | Whether the batch is billable. True when an live API key is used, false when a test API key is used. | +| `templateId` | `string` | The ID of the template the batch is based on. | +| `estimatedPrice` | `number` | The estimated price of the batch. | +| `status` | `string` | The status of the batch. Can be `batch_created`, `batch_needs_approval`, `batch_user_ready`, `batch_ready_to_schedule`, `batch_scheduling`, `batch_scheduled` or `batch_sent` | +| `orders` | `object` | An object containing the orders of the batch. With keys 'processing', 'success', 'failed' and 'cancelled' | +| `createdAt` | `string` | The date the batch was created. | +| `updatedAt` | `string` | The date the batch was last updated. | + +# Methods + +## `.getTemplate()` + +Get the template the batch is based on. Uses [`PrintOne.getTemplate()`](./PrintOne#gettemplateid). + +**Returns: [`Promise