Skip to content

Commit

Permalink
Merge pull request #15 from Print-one/main
Browse files Browse the repository at this point in the history
Main -> Next
  • Loading branch information
SophiaH67 committed Apr 15, 2024
2 parents 6d74ef9 + 0a12e9b commit b018956
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 22 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [1.2.1](https://github.com/Print-one/print-one-js/compare/v1.2.0...v1.2.1) (2024-04-15)


### Bug Fixes

* :bug: incorrect check in csv order test ([59a73ea](https://github.com/Print-one/print-one-js/commit/59a73ea4d118c20f3627e464dd90a395e30eaaef))
* :bug: incorrect ts marking for undefined properties ([c09dd93](https://github.com/Print-one/print-one-js/commit/c09dd937e239d6efa9127def0852cdd7ab8d6e0c))
* :bug: order creation not working with templateId ([8784076](https://github.com/Print-one/print-one-js/commit/878407679d44d4d21e57ac31087f4f00aa1772ad))

# [1.2.0](https://github.com/Print-one/print-one-js/compare/v1.1.0...v1.2.0) (2024-04-04)


Expand Down
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",
"version": "1.2.1",
"description": "The official javascript client for Print.one",
"license": "MIT",
"author": "Print.one",
Expand Down
18 changes: 4 additions & 14 deletions src/PrintOne.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,8 @@ export class PrintOne {
* @param data The order data
*/
public async createOrder(data: CreateOrder): Promise<Order> {
let templateId: undefined | string;

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

const sendDateStr =
data.sendDate instanceof Date
Expand All @@ -279,13 +274,8 @@ export class PrintOne {
}

public async createCsvOrder(data: CreateCsvOrder): Promise<CsvOrder> {
let templateId: undefined | string;

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

const formData = new FormData();
formData.append(
Expand Down
12 changes: 10 additions & 2 deletions src/models/CsvOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ export type CreateCsvOrder = {
recipient: Address;
mergeVariables?: Record<string, string>;
};
template: Template | string;
finish?: Finish;
billingId?: string;
sender?: Address;
};
} & (
| {
template: Template | string;
templateId?: undefined;
}
| {
template?: undefined;
templateId: string;
}
);

export type CreateBatchCsvOrder = Pick<CreateCsvOrder, "file" | "mapping">;

Expand Down
12 changes: 10 additions & 2 deletions src/models/Order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@ import { sleep } from "../utils";
export type CreateOrder = {
recipient: Address;
sender?: Address;
template: Template | string;
/**
* @default GLOSSY
*/
finish?: Finish;
mergeVariables?: Record<string, unknown>;
billingId?: string;
sendDate?: Date | string;
};
} & (
| {
template: Template | string;
templateId?: undefined;
}
| {
template?: undefined;
templateId: string;
}
);

export class Order {
private _data: IOrder;
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 < 1)) {
await order.refresh();
await sleep(1000);
}
Expand Down

0 comments on commit b018956

Please sign in to comment.