Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next -> Main #17

Merged
merged 35 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b822eaf
ci: reduce amount of workers for tests
UnderKoen Feb 13, 2024
9e04141
feat: ✨ added CsvOrder model + endpoints (#7)
PaulRill00 Feb 13, 2024
66d0dcf
chore(release): 1.2.0-next.1 [skip ci]
semantic-release-bot Feb 13, 2024
0099217
feat: batch endpoints added (#8)
UnderKoen Feb 19, 2024
4c2996b
feat: :sparkles: added remaining getBatches filters
PaulRill00 Feb 28, 2024
64ec3ad
feat: added format to DTO
PaulRill00 Feb 28, 2024
2d2ea37
test: :white_check_mark: test isBillable getBatches filter
PaulRill00 Feb 28, 2024
a4bd3a6
feat: :sparkles: allow for uploading CSVs to a Batch
PaulRill00 Mar 4, 2024
74b0313
feat: :sparkles: added endpoint to get a CsvOrder by it's ID
PaulRill00 Mar 7, 2024
cf7f7be
docs: :memo: added docs about PrintOne.getCsvOrder
PaulRill00 Mar 7, 2024
e85e14c
Merge pull request #12 from Print-one/feat/add-get-csv-order-endpoint
PaulRill00 Mar 7, 2024
a506f3f
Merge branches 'feat/PO-1477-batch-csv' and 'next' of github.com:Prin…
PaulRill00 Mar 7, 2024
0560944
feat: :sparkles: allow for getting CSV order by id
PaulRill00 Mar 7, 2024
8420046
feat: implement PR feedback
PaulRill00 Mar 11, 2024
0c76223
test: fixed a broken test
PaulRill00 Mar 11, 2024
745014e
Merge pull request #11 from Print-one/feat/PO-1477-batch-csv
PaulRill00 Mar 11, 2024
98a0a1c
chore: setup script
UnderKoen Mar 13, 2024
c526300
chore: pr feedback
UnderKoen Mar 14, 2024
c2ca919
feat: :sparkles: support batch order's API urls
PaulRill00 Mar 18, 2024
aaeeaee
Merge branch 'next' of github.com:Print-one/print-one-js into feat/PO…
PaulRill00 Mar 25, 2024
868b287
chore: :pushpin: updated package-lock.json
PaulRill00 Mar 25, 2024
87a250e
chore: :recycle: make urlPrefix protected getter
PaulRill00 Mar 25, 2024
9795b9d
test: :white_check_mark: fixed empty CSV mapping expected
PaulRill00 Mar 25, 2024
45629a9
Merge pull request #10 from Print-one/feat/PO-1446-get-batches-more-f…
PaulRill00 Mar 25, 2024
bf3f282
Merge branch 'next' of github.com:Print-one/print-one-js into feat/PO…
PaulRill00 Mar 25, 2024
7a44f79
test: :white_check_mark: added more regression tests
PaulRill00 Mar 25, 2024
4bfa078
Merge pull request #13 from Print-one/feat/PO-1525-batch-order-endpoints
PaulRill00 Mar 25, 2024
648cab7
Merge remote-tracking branch 'origin/main' into next
SophiaH67 Apr 8, 2024
f220080
docs: :memo: added example .env file [ci skip]
PaulRill00 Apr 8, 2024
6d74ef9
chore: fix ci running for 2 hours
UnderKoen Apr 9, 2024
b018956
Merge pull request #15 from Print-one/main
SophiaH67 Apr 15, 2024
2db77de
fix: batch status filter
UnderKoen May 9, 2024
2b0e209
fix: batch status filter
UnderKoen May 9, 2024
57d72ef
chore: autoGenNextBatch
UnderKoen May 9, 2024
6d0dade
Merge branch 'main' into next
SophiaH67 May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
release:
name: Update documentation
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: spenserblack/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
name: Test
on:
push:
branches:
- main
- next
paths-ignore:
- "docs/**"
- "**/*.md"
pull_request:
paths-ignore:
- "docs/**"
Expand All @@ -16,6 +9,7 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
223 changes: 223 additions & 0 deletions docs/Batch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
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<Template>`](./Template)**

**Example**

```js
const batch = await client.getbatch("example-batch-id");
const template = await batch.getTemplate();
```

---

## `.refresh()`

Refresh the batch data to get the latest information

**Returns: `Promise<void>`**

**Example**

```js
const batch: Batch;
await batch.refresh();
```

---

## [`.getOrders([options])`](./PrintOne#getordersoptions)

Get all orders in the batch.

**Parameters**

| Name | Type | Default | Description |
| ------------------------------- | ----------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `options.limit` | `number` | `10` | The maximum number of batchs to return. |
| `options.page` | `number` | `1` | The page of batchs to return. |
| `options.sortBy` | [`sort`](./Filtering#Sorting) | `createdAt:DESC` | The field(s) to sort the batchs by. Can be `createdAt`, `anonymizedAt`, `updatedAt`, `friendlyStatus` or `sendDate` |
| `options.filter.friendlyStatus` | `string` \| `string[]` | `undefined` | The friendly status(es) of the batch(s) to filter by. Can be `Processing`, `Success`, `Sent`, `Scheduled`, `Cancelled` or `Failed` |
| `options.filter.billingId` | `string` \| `string[]` | `undefined` | The billing ID(s) of the batch(s) to filter by. |
| `options.filter.format` | `string` \| `string[]` | `undefined` | The format(s) of the batch(s) to filter by. Can be `POSTCARD_A5`, `POSTCARD_A6`, `POSTCARD_SQ14` or `GREETINGCARD_SQ15` |
| `options.filter.finish` | `string` \| `string[]` | `undefined` | The finish(es) of the batch(s) to filter by. Can be `GLOSSY` or `MATTE` |
| `options.filter.isBillable` | `boolean` | `undefined` | Whether the batch(s) are live batch or test batchs. |
| `options.filter.createdAt` | [`date`](./Filtering#Date) | `undefined` | The date(s) the batch(s) were created on. |

**Returns: [`Promise<PaginatedResponse<Order>>`](./Order)**

**Example**

```js
const orders = await batch.getOrders({
limit: 20,
page: 1,
sortBy: "createdAt:ASC",
filter: {
friendlyStatus: "Success",
format: Format.POSTCARD_A5,
finish: Finish.GLOSSY,
isBillable: true,
createdAt: {
from: "2020-01-01",
to: "2020-01-31",
},
},
});
```

---

## [`.getOrder(orderId)`](./PrintOne#getorderorderid)

Get a specific order in the batch.

**Parameters**

| Name | Type | Description |
| --------- | -------- | -------------------- |
| `orderId` | `string` | The ID of the order. |

**Returns: [`Promise<Order>`](./Order)**

**Example**

```js
const order = await batch.getOrder("example-order-id");
```

---

## `.createOrder(data)`

Create a new order in the batch.

**Parameters**

| Name | Type | Description |
| ---------------- | ---------------------------- | --------------------------------- |
| `data.recipient` | [`Address`](./Order#Address) | The recipient of the order. |
| `mergeVariables` | `object` | The merge variables of the order. |

**Returns: [`Promise<Order>`](./Order)**

**Example**

```js
const order = await batch.createOrder({
recipient: {
name: "John Doe",
address: "123 Main St",
city: "Anytown",
postalCode: "1221AH",
country: "Nederland",
},
mergeVariables: {
name: "John Doe",
},
});
```

---

## `.update(data)`

Update the batch.

**Parameters**

| Name | Type | Description |
| ------------ | ------------------- | ------------------------------------------- |
| `data.ready` | `Date` \| `boolean` | Whether the batch is ready to be scheduled. |

**Returns: `Promise<void>`**

**Example**

```js
await batch.update({
ready: true,
});
```

---

## `.createCsvOrder(data)`

Create a new csv order.

**Parameters**

| Name | Type | Description |
| ------ | -------- | ------------------------------------------------------------------------------------------------- |
| `data` | `object` | The data to create the order with. See [`CsvOrder`](./CsvOrder#createcsvorderdata) for more info. |

**Returns: [`Promise<CsvOrder>`](./CsvOrder)**

**Example**

```js
const batch: Batch;

const order = await batch.createCsvOrder({
mapping: {
recipient: {
city: "{{City}}",
name: "{{FirstName}} {{LastName}}",
address: "{{Street}} {{HouseNr}}",
country: "{{Country}}",
postalCode: "{{ZIP}}",
},
mergeVariables: {
name: "{{FirstName}}",
coupon: "{{Coupon}}",
},
},
file: file,
});
```

---

## `.getCsvOrder(id)`

Get a csv order by its ID.

**Parameters**

| Name | Type | Description |
| ---- | -------- | ------------------------------- |
| `id` | `string` | The ID of the csv order to get. |

**Returns: [`Promise<CsvOrder>`](./CsvOrder)**

**Example**

```js
const batch: Batch;

const csvOrder = await batch.getCsvOrder("example-order-id");
```
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ module.exports = {
statements: 100,
},
},
testSequencer: "./testSequencer.js",
};
Loading
Loading