Skip to content

Commit

Permalink
Merge pull request #29 from Print-one/next
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulRill00 authored Aug 27, 2024
2 parents 52ef1bd + faeaafe commit 219b53f
Show file tree
Hide file tree
Showing 24 changed files with 1,039 additions and 72 deletions.
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# [1.4.0-next.2](https://github.com/Print-one/print-one-js/compare/v1.4.0-next.1...v1.4.0-next.2) (2024-08-27)


### Features

* :sparkles: added coupon-code-used webhook event handler ([ba28867](https://github.com/Print-one/print-one-js/commit/ba2886762e6368a5254a8b1081f0965e5f426d50))
* :sparkles: rename x-printone webhook headers to x-webhook ([4b3b818](https://github.com/Print-one/print-one-js/commit/4b3b8189f1e023279e878d53e6467166edbb80f7))

# [1.4.0-next.1](https://github.com/Print-one/print-one-js/compare/v1.3.0...v1.4.0-next.1) (2024-08-07)


### Bug Fixes

* :rotating_light: fix linting issues ([7bf02e4](https://github.com/Print-one/print-one-js/commit/7bf02e458c833554fc3e661497a7233f7a9be0ea))
* :white_check_mark: skip coupon code usage test, if order is not billable ([4a9ff10](https://github.com/Print-one/print-one-js/commit/4a9ff103fd166af87c7010ab585f5c91af9b79cb))
* typescript error on install ([20d3f0f](https://github.com/Print-one/print-one-js/commit/20d3f0fc8abadde35381dda455f1ae1d8775bc94))


### Features

* :sparkles: Added coupons ([604c374](https://github.com/Print-one/print-one-js/commit/604c3747a6587349f0040fba1838ef4a7a77e19d))
* :sparkles: webhook request validation logic ([ae9bd7c](https://github.com/Print-one/print-one-js/commit/ae9bd7c9c67b6516bcd0d47616162bc93c01282b))
* add batch_status_update webhook support ([696a1dc](https://github.com/Print-one/print-one-js/commit/696a1dc2f0e4dc124ae43e0fcd654574c9c07509))
* webhooks ([73a1678](https://github.com/Print-one/print-one-js/commit/73a1678a490618251a0a9b80a77931ad8b31e0f0))

# [1.3.0](https://github.com/Print-one/print-one-js/compare/v1.2.1...v1.3.0) (2024-07-01)


Expand All @@ -22,6 +47,28 @@
* batch endpoints added ([#8](https://github.com/Print-one/print-one-js/issues/8)) ([0099217](https://github.com/Print-one/print-one-js/commit/009921704b0c7b75206341ef20b1f540c31e366c))
* implement PR feedback ([8420046](https://github.com/Print-one/print-one-js/commit/8420046c3655a0a9480f192f3879fcf9524c06f4))

# [1.3.0-next.3](https://github.com/Print-one/print-one-js/compare/v1.3.0-next.2...v1.3.0-next.3) (2024-07-02)


### Features

* add batch_status_update webhook support ([696a1dc](https://github.com/Print-one/print-one-js/commit/696a1dc2f0e4dc124ae43e0fcd654574c9c07509))

# [1.3.0-next.2](https://github.com/Print-one/print-one-js/compare/v1.3.0-next.1...v1.3.0-next.2) (2024-07-01)


### Bug Fixes

* typescript error on install ([8fb29c4](https://github.com/Print-one/print-one-js/commit/8fb29c4f83831d12510e31475fb3a6fdc4ed352f))
* typescript error on install ([20d3f0f](https://github.com/Print-one/print-one-js/commit/20d3f0fc8abadde35381dda455f1ae1d8775bc94))


### Features

* :sparkles: webhook request validation logic ([ae9bd7c](https://github.com/Print-one/print-one-js/commit/ae9bd7c9c67b6516bcd0d47616162bc93c01282b))
* :sparkles: webhook request validation logic ([ce81792](https://github.com/Print-one/print-one-js/commit/ce81792e9b554ceaf0694857a9402b003bb80392))
* webhooks ([73a1678](https://github.com/Print-one/print-one-js/commit/73a1678a490618251a0a9b80a77931ad8b31e0f0))

# [1.3.0-next.1](https://github.com/Print-one/print-one-js/compare/v1.2.1...v1.3.0-next.1) (2024-05-22)


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Print-one.js
# Print-one.js

[![npm package][npm-img]][npm-url]
[![Build Status][build-img]][build-url]
Expand Down
30 changes: 14 additions & 16 deletions docs/Coupon.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ Contains all information about a given CsvOrder

# Fields

| Name | Type | Description |
| ---------------------- | ------------------------------------ | -------------------------------------------------------------------------------------------------------- |
| `id` | `string` | The ID of the coupon. |
| `name` | `string` | The name of the coupon. |
| `companyId` | `string` | The ID of the company the coupon belongs to. |
| `stats` | `object` | An object containing the stats of the coupon. With keys 'total', 'used' and 'remaining' |
| Name | Type | Description |
| ----------- | -------- | --------------------------------------------------------------------------------------- |
| `id` | `string` | The ID of the coupon. |
| `name` | `string` | The name of the coupon. |
| `companyId` | `string` | The ID of the company the coupon belongs to. |
| `stats` | `object` | An object containing the stats of the coupon. With keys 'total', 'used' and 'remaining' |

# Methods

Expand All @@ -28,7 +28,7 @@ await coupon.refresh();

## `Coupon.getCodes()`

Get all coupon codes within the coupon. |
Get all coupon codes within the coupon. |

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

Expand All @@ -42,7 +42,7 @@ const couponCodes = await coupon.getCodes();

## `Coupon.getCode(id)`

Get all coupon codes by its ID.
Get all coupon codes by its ID.

**Parameters**

Expand All @@ -55,7 +55,7 @@ Get all coupon codes by its ID.
**Example**

```js
const couponCode = await coupon.getCode('example-coupon-code-id');
const couponCode = await coupon.getCode("example-coupon-code-id");
```

---
Expand All @@ -66,11 +66,11 @@ Add coupon codes to the coupon by uploading a CSV.

**Parameters**

| Name | Type | Description |
| ---------- | ------------- | --------------------------------- |
| `csv` | `ArrayBuffer` | The file to upload. Must be a CSV |
| Name | Type | Description |
| ----- | ------------- | --------------------------------- |
| `csv` | `ArrayBuffer` | The file to upload. Must be a CSV |

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

**Example**

Expand All @@ -79,18 +79,16 @@ const data = fs.readFileSync("example.csv").buffer;
const file = await coupon.addCodes(data);
```


---

## `Coupon.delete()`

Delete the coupon.

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

**Example**

```js
await coupon.delete();
```

17 changes: 9 additions & 8 deletions docs/CouponCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ Contains all information about a given CsvOrder

# Fields

| Name | Type | Description |
| ---------------------- | ------------------------------------ | --------------------------------------------------------------------------------- |
| `id` | `string` | The ID of the coupon code. |
| `couponId` | `string` | The ID of the parent coupon. |
| `code` | `string` | The actual code saved for the coupon code`. |
| `used` | `boolean` | Whether the coupon code has been used. |
| `usedAt` | `Date` or `null` | The date at which the coupon code was used or `null` if not used yet. |
| `orderId` | `string` or `null` | The order ID by which the coupon code was used or `null` if not used yet. |
| Name | Type | Description |
| ---------- | ------------------ | ------------------------------------------------------------------------- |
| `id` | `string` | The ID of the coupon code. |
| `couponId` | `string` | The ID of the parent coupon. |
| `code` | `string` | The actual code saved for the coupon code`. |
| `used` | `boolean` | Whether the coupon code has been used. |
| `usedAt` | `Date` or `null` | The date at which the coupon code was used or `null` if not used yet. |
| `orderId` | `string` or `null` | The order ID by which the coupon code was used or `null` if not used yet. |

# Methods

---

## `.refresh()`
Expand Down
111 changes: 103 additions & 8 deletions docs/PrintOne.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,106 @@ Get a csv order by its ID.
const csvOrder = await client.getCsvOrder("example-order-id");
```

## `.createBatch(data)`

Create a new batch.

**Parameters**

| Name | Type | Description |
| ------ | -------- | ---------------------------------- |
| `data` | `object` | The data to create the batch with. |

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

**Example**

```js
const batch = await client.createBatch({
name: "example",
template: "example-template-id",
finish: "GLOSSY",
ready: true,
sender: {
name: "John Doe",
address: "Example Street 2",
city: "Anytown",
postalCode: "1234AB",
country: "NL",
},
});
```

---

## `.getBatch(id)`

Get a batch by its ID.

**Parameters**

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

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

**Example**

```js
const batch = await client.getBatch("example-batch-id");
```

--
---

## `.getBatches([options])`

Get all batches.

**Parameters**

| Name | Type | Default | Description |
| --------------------------- | -------------------------------------------------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `options.limit` | `number` | `10` | The maximum number of batches to return. |
| `options.page` | `number` | `1` | The page of batches to return. |
| `options.sortBy` | [`sort`](./Filtering#Sorting) | `createdAt:DESC` | The field(s) to sort the batches by. Can be `createdAt`, `updatedAt`, `billingId`, `sendDate` or `name` |
| `options.filter.billingId` | `string` \| `string[]` | `undefined` | The billing ID(s) of the batch(es) to filter by. |
| `options.filter.name` | `string` \| `string[]` | `undefined` | The name(s) of the batch(es) to filter by. |
| `options.filter.createdAt` | [`date`](./Filtering#Date) | `undefined` | The date(s) the batch(es) were created on. |
| `options.filter.updatedAT` | [`date`](./Filtering#Date) | `undefined` | The date(s) the batch(es) were updated on. |
| `options.filter.sendDate` | [`date`](./Filtering#Date) \| `boolean` | `undefined` | The date(s) the batch(es) are sent on. |
| `options.filter.finish` | `string` \| `string[]` | `undefined` | The finish(es) of the batch(es) to filter by. Can be `GLOSSY` or `MATTE` |
| `options.filter.templates` | `string` \| `string[]` \| [`Template`](./Template) \| [`Template[]`](./Template) | `undefined` | Whether the batch(es) are live order or test batches. |
| `options.filter.format` | `string` \| `string[]` | `undefined` | The format(s) of the batch(es) to filter by. Can be `POSTCARD_A5`, `POSTCARD_A6`, `POSTCARD_SQ14` |
| `options.filter.status` | `string` \| `string[]` | `undefined` | The status(es) of the batch(s) to filter by. Can be `batch_created`, `batch_needs_approval`, `batch_user_ready`, `batch_ready_to_schedule`, `batch_scheduling`, `batch_scheduled` or `batch_sent` |
| `options.filter.isBillable` | `boolean` | `undefined` | Whether the batch(es) are live order or test batches. |

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

**Example**

```js
const batches = await client.getBatches({
limit: 20,
page: 1,
sortBy: "createdAt:ASC",
filter: {
billingId: "example-billing-id",
name: "example-name",
sendDate: {
from: "2020-01-01",
to: "2020-01-31",
},
finish: Finish.GLOSSY,
templates: "example-template-id",
format: Format.POSTCARD_A5,
status: "batch_sent",
isBillable: true,
},
});
```

---

## `.createCoupon(data)`

Expand Down Expand Up @@ -334,12 +429,12 @@ Get all coupons.

**Parameters**

| Name | Type | Default | Description |
| ------------------------------- | ----------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `options.limit` | `number` | `10` | The maximum number of coupons to return. |
| `options.page` | `number` | `1` | The page of coupons to return. |
| `options.sortBy` | [`sort`](./Filtering#Sorting) | `createdAt:DESC` | The field(s) to sort the coupons by. Can be `createdAt` or `name` |
| `options.filter.name` | `string` \| `string[]` | `undefined` | The name(s) of the coupon(s) to filter |
| Name | Type | Default | Description |
| --------------------- | ----------------------------- | ---------------- | ----------------------------------------------------------------- |
| `options.limit` | `number` | `10` | The maximum number of coupons to return. |
| `options.page` | `number` | `1` | The page of coupons to return. |
| `options.sortBy` | [`sort`](./Filtering#Sorting) | `createdAt:DESC` | The field(s) to sort the coupons by. Can be `createdAt` or `name` |
| `options.filter.name` | `string` \| `string[]` | `undefined` | The name(s) of the coupon(s) to filter |

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

Expand Down Expand Up @@ -376,4 +471,4 @@ Get a coupon by its ID.
const coupon = await client.getCoupon("example-coupon-id");
```

---
---
Loading

0 comments on commit 219b53f

Please sign in to comment.