Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
SophiaH67 committed Apr 8, 2024
2 parents 4bfa078 + 5284c84 commit 648cab7
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 158 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# [1.2.0-next.1](https://github.com/Print-one/print-one-js/compare/v1.1.0...v1.2.0-next.1) (2024-02-13)
# [1.2.0](https://github.com/Print-one/print-one-js/compare/v1.1.0...v1.2.0) (2024-04-04)


### Bug Fixes

* :bug: accessing property that might not exist ([aed3508](https://github.com/Print-one/print-one-js/commit/aed350824713a8552ebdc2cfed013763109da0bf))


### Features

* ✨ added CsvOrder model + endpoints ([#7](https://github.com/Print-one/print-one-js/issues/7)) ([9e04141](https://github.com/Print-one/print-one-js/commit/9e041416bdc09a3f34d6f2da72bde6788770e39b))
* :sparkles: added endpoint to get a CsvOrder by it's ID ([0be83a9](https://github.com/Print-one/print-one-js/commit/0be83a9060c35f1e4bac3620dab9f72659063e1a))
* ✨ added CsvOrder model + endpoints ([#7](https://github.com/Print-one/print-one-js/issues/7)) ([9deda48](https://github.com/Print-one/print-one-js/commit/9deda48271f56b830158d03a3b2a535d76797c70))
* CSV upload ([7debb24](https://github.com/Print-one/print-one-js/commit/7debb24f913f113510b7b1e03088f30fa6a66d3c))

# [1.1.0](https://github.com/Print-one/print-one-js/compare/v1.0.0...v1.1.0) (2024-01-23)

Expand Down
42 changes: 21 additions & 21 deletions docs/CsvOrder.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ Contains all information about a given CsvOrder

# Fields

| Name | Type | Description |
| ---------------------- | ------------------------------------ | -------------------------------------------------------------------------------------------------------- |
| `id` | `string` | The ID of the order. |
| `templateId` | `string` | The ID of the template the order is based on. |
| `finish` | `string` | The finish of the order. Can be `GLOSSY` or `MATT`. |
| `format` | `string` | The format of the order. Can be `POSTCARD_A5`, `POSTCARD_A6`, `POSTCARD_SQ14` or `GREETINGCARD_SQ15`. |
| `mergeVariableMapping` | `object` | The merge variables of the order. Keys are the merge variable names. |
| `sender` | [`Address`](#Address) \| `undefined` | The sender of the order. |
| `recipientMapping` | [`Address`](#Address) | The mapping of the recipient. |
| `definitiveCountryId` | `string` | The ID of the definitive country of the order. |
| `billingId` | `string` \| `undefined` | The ID assigned to the csv order by the customer. |
| `isBillable` | `boolean` | Whether the csv order is billable. True when an live API key is used, false when a test API key is used. |
| `status` | `string` | The status of the csv order. Can be `order_created` or `order_processed` |
| `friendlyStatus` | `string` | The friendly status of the csv order. Can be `Processing` or `Success` |
| `estimatedOrderCount` | `number` | The amount of initial orders in the CSV |
| `failedOrderCount` | `number` | The amount of orders which have failed to be processed |
| `processedOrderCount` | `number` | The amount of orders which have successfully been processed |
| `totalOrderCount` | `number` | The total amount of orders failed or processed |
| `sendDate` | `Date` | The date the order will be sent on. |
| `createdAt` | `Date` | The date and time the order was created. |
| `updatedAt` | `Date` | The date and time the order was last updated. |
| Name | Type | Description |
| --------------------- | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | `string` | The ID of the order. |
| `templateId` | `string` | The ID of the template the order is based on. |
| `finish` | `string` | The finish of the order. Can be `GLOSSY` or `MATT`. |
| `format` | `string` | The format of the order. Can be `POSTCARD_A5`, `POSTCARD_A6`, `POSTCARD_SQ14` or `GREETINGCARD_SQ15`. |
| `mergeVariableMapping` | `object` | The merge variables of the order. Keys are the merge variable names. |
| `sender` | [`Address`](#Address) \| `undefined` | The sender of the order. |
| `recipientMapping` | [`Address`](#Address) | The mapping of the recipient. |
| `definitiveCountryId` | `string` | The ID of the definitive country of the order. |
| `billingId` | `string` \| `undefined` | The ID assigned to the csv order by the customer. |
| `isBillable` | `boolean` | Whether the csv order is billable. True when an live API key is used, false when a test API key is used. |
| `status` | `string` | The status of the csv order. Can be `order_created` or `order_processed` |
| `friendlyStatus` | `string` | The friendly status of the csv order. Can be `Processing` or `Success` |
| `estimatedOrderCount` | `number` | The amount of initial orders in the CSV
| `failedOrderCount` | `number` | The amount of orders which have failed to be processed
| `processedOrderCount` | `number` | The amount of orders which have successfully been processed
| `totalOrderCount` | `number` | The total amount of orders failed or processed
| `sendDate` | `Date` | The date the order will be sent on. |
| `createdAt` | `Date` | The date and time the order was created. |
| `updatedAt` | `Date` | The date and time the order was last updated. |

# Methods

Expand Down
132 changes: 16 additions & 116 deletions docs/PrintOne.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ Create a new csv order.

**Parameters**

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

**Returns: [`Promise<CsvOrder>`](./CsvOrder)**
Expand All @@ -262,21 +262,21 @@ Create a new csv order.

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

Expand All @@ -299,104 +299,4 @@ Get a csv order by its ID.
```js
const csvOrder = await client.getCsvOrder("example-order-id");
```

---

## `.createBatch(data)`

Create a new batch.

**Parameters**

| Name | Type | Description |
| ---------------- | ------------------------------------ | ---------------------------------------------------- |
| `data.name` | `string` | The name of the batch. |
| `data.billingId` | `string` \| `undefined` | The billing ID of the batch. |
| `data.template` | `string` \| [`Template`](./Template) | The template of the batch. |
| `data.finish` | `string` | The finish of the batch. Can be `GLOSSY` or `MATTE`. |
| `data.ready' | `boolean` \| `Date` | The date the batch is ready. |

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

**Example**

```js
const batch = await client.createBatch({
name: "Example Batch",
billingId: "example-billing-id",
template: "example-template-id",
finish: Finish.GLOSSY,
ready: true,
});
```

---

## `.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) | `undefined` | The date(s) the batch(es) were 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` | The template(s) of the batch(es) to filter by. |

**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 Batch",
createdAt: {
from: "2020-01-01",
to: "2020-01-31",
},
updatedAt: {
from: "2020-01-01",
to: "2020-01-31",
},
sendDate: {
from: "2020-01-01",
to: "2020-01-31",
},
finish: Finish.GLOSSY,
templates: "example-template-id",
},
});
```
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@print-one/print-one-js",
"version": "1.2.0-next.1",
"version": "1.2.0",
"description": "The official javascript client for Print.one",
"license": "MIT",
"author": "Print.one",
Expand Down
19 changes: 15 additions & 4 deletions src/PrintOne.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,14 @@ export class PrintOne {
* @param data The order data
*/
public async createOrder(data: CreateOrder): Promise<Order> {
const templateId =
typeof data.template === "string" ? data.template : data.template.id;
let templateId: undefined | string;

if (data.template instanceof Template) {
templateId = data.template.id;
} else {
templateId = data.template;
}

const sendDateStr =
data.sendDate instanceof Date
? data.sendDate.toISOString()
Expand All @@ -273,8 +279,13 @@ export class PrintOne {
}

public async createCsvOrder(data: CreateCsvOrder): Promise<CsvOrder> {
const templateId =
typeof data.template === "string" ? data.template : data.template.id;
let templateId: undefined | string;

if (data.template instanceof Template) {
templateId = data.template.id;
} else {
templateId = data.template;
}

const formData = new FormData();
formData.append(
Expand Down
2 changes: 1 addition & 1 deletion test/CsvOrder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe("getOrders", function () {
// arrange

// act
while (await order.getOrders().then((x) => x.data.length === 0)) {
while (await order.getOrders({}).then((x) => x.data.length > 0)) {
await order.refresh();
await sleep(1000);
}
Expand Down
Loading

0 comments on commit 648cab7

Please sign in to comment.