From 4c2996b4ad3cf29bab6daf32830ae419c9641e81 Mon Sep 17 00:00:00 2001 From: Paul Rill Date: Wed, 28 Feb 2024 15:52:18 +0100 Subject: [PATCH 1/5] feat: :sparkles: added remaining getBatches filters --- src/PrintOne.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/PrintOne.ts b/src/PrintOne.ts index 90ab7cf..f928c54 100644 --- a/src/PrintOne.ts +++ b/src/PrintOne.ts @@ -30,6 +30,7 @@ import { CreateCsvOrder, CsvOrder } from "./models/CsvOrder"; import { ICsvOrder } from "./models/_interfaces/ICsvOrder"; import { Batch, CreateBatch } from "./models/Batch"; import { IBatch } from "./models/_interfaces/IBatch"; +import { BatchStatus } from "./enums/BatchStatus"; export type RequestHandler = new ( token: string, @@ -433,7 +434,9 @@ export class PrintOne { sendDate?: DateFilter | boolean; finish?: InFilter; templates?: InFilter; - //TODO format, status, isBillable + format?: InFilter; + status?: InFilter; + isBillable?: InFilter; }; } = {}, ): Promise> { @@ -444,8 +447,17 @@ export class PrintOne { ...dateFilterToQuery("createdAt", options.filter?.createdAt), ...dateFilterToQuery("updatedAt", options.filter?.updatedAt), ...inFilterToQuery("finish", options.filter?.finish), + ...inFilterToQuery("format", options.filter?.format), + ...inFilterToQuery("status", options.filter?.status), }; + if (typeof options.filter?.isBillable === "boolean") { + params = { + ...params, + "filter.isBillable": `$eq:${options.filter.isBillable}`, + }; + } + if (options.filter?.templates) { if (!Array.isArray(options.filter.templates)) { options.filter.templates = [options.filter.templates]; From 64ec3adc8b51dd697d0c1244e663353b087a17c1 Mon Sep 17 00:00:00 2001 From: Paul Rill Date: Wed, 28 Feb 2024 16:02:07 +0100 Subject: [PATCH 2/5] feat: added format to DTO --- src/models/Batch.ts | 5 +++++ src/models/_interfaces/IBatch.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/src/models/Batch.ts b/src/models/Batch.ts index 1687a2b..b81ddd4 100644 --- a/src/models/Batch.ts +++ b/src/models/Batch.ts @@ -7,6 +7,7 @@ import { PaginatedResponse } from "./PaginatedResponse"; import { Order } from "./Order"; import { Address } from "./Address"; import { IOrder } from "./_interfaces/IOrder"; +import { Format } from "src/enums/Format"; export type CreateBatch = { name: string; @@ -51,6 +52,10 @@ export class Batch { return this._data.finish as Finish; } + public get format(): Format { + return this._data.format as Format; + } + public get isBillable(): boolean { return this._data.isBillable; } diff --git a/src/models/_interfaces/IBatch.ts b/src/models/_interfaces/IBatch.ts index 7cae7bc..8c11411 100644 --- a/src/models/_interfaces/IBatch.ts +++ b/src/models/_interfaces/IBatch.ts @@ -4,6 +4,7 @@ export type IBatch = { name: string; billingId: string; finish: string; + format: string; isBillable: boolean; templateId: string; estimatedPrice: number; From 2d2ea37716d8db3c77b7ed24ff445bc31b9df2c9 Mon Sep 17 00:00:00 2001 From: Paul Rill Date: Wed, 28 Feb 2024 16:25:56 +0100 Subject: [PATCH 3/5] test: :white_check_mark: test isBillable getBatches filter --- src/PrintOne.ts | 2 +- test/PrintOne.spec.ts | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/PrintOne.ts b/src/PrintOne.ts index f928c54..ea78677 100644 --- a/src/PrintOne.ts +++ b/src/PrintOne.ts @@ -436,7 +436,7 @@ export class PrintOne { templates?: InFilter; format?: InFilter; status?: InFilter; - isBillable?: InFilter; + isBillable?: boolean; }; } = {}, ): Promise> { diff --git a/test/PrintOne.spec.ts b/test/PrintOne.spec.ts index a631fd1..385d370 100644 --- a/test/PrintOne.spec.ts +++ b/test/PrintOne.spec.ts @@ -1562,6 +1562,28 @@ describe("getBatches", function () { expect(batch.billingId).toEqual("test"); }); + it("should apply the isBillable filter", async function () { + // arrange + + // act + const batches = await client.getBatches({ + limit: 1, + filter: { + isBillable: true, + }, + }); + const batch = batches.data[0]; + + if (batch === undefined) { + console.warn("No orders found, skipping test"); + return; + } + + // assert + expect(batch).toBeDefined(); + expect(batch.isBillable).toEqual(true); + }); + it("should apply the name filter", async function () { // arrange const batchName = (await client.getBatches()).data[1]?.name ?? "test"; From 868b287f315070eb5eda83f8fec1c5e30dcc1724 Mon Sep 17 00:00:00 2001 From: Paul Rill Date: Mon, 25 Mar 2024 09:02:03 +0100 Subject: [PATCH 4/5] chore: :pushpin: updated package-lock.json --- package-lock.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 30b3ffc..1bc145a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@jest/test-sequencer": "^29.7.0", - "axios": "^1.6.6", + "axios": "^1.6.7", "debug": "^4.3.4" }, "devDependencies": { @@ -27,14 +27,14 @@ "@typescript-eslint/parser": "^6.18.1", "@under_koen/bsm": "^1.3.3", "eslint": "^8.52.0", - "eslint-config-prettier": "^9.0.0", + "eslint-config-prettier": "^9.1.0", "eslint-plugin-no-relative-import-paths": "^1.5.3", "eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-sort-keys-fix": "^1.1.2", "eslint-plugin-unused-imports": "^3.0.0", "jest": "^29.7.0", "jest-extended": "^4.0.2", - "prettier": "^3.0.3", + "prettier": "^3.2.4", "prettier-package-json": "^2.8.0", "rimraf": "^5.0.5", "semantic-release": "^22.0.6", @@ -3661,9 +3661,9 @@ } }, "node_modules/eslint-config-prettier": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.0.0.tgz", - "integrity": "sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", "dev": true, "bin": { "eslint-config-prettier": "bin/cli.js" @@ -9947,9 +9947,9 @@ } }, "node_modules/prettier": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", - "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" From 9795b9d881d85e0741710b67b63a4ab98ab4161d Mon Sep 17 00:00:00 2001 From: Paul Rill Date: Mon, 25 Mar 2024 09:46:01 +0100 Subject: [PATCH 5/5] test: :white_check_mark: fixed empty CSV mapping expected --- test/Batch.spec.ts | 4 ++-- test/PrintOne.spec.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Batch.spec.ts b/test/Batch.spec.ts index 2fe3087..c271fdb 100644 --- a/test/Batch.spec.ts +++ b/test/Batch.spec.ts @@ -126,7 +126,7 @@ describe("createCsvOrder", function () { expect(csvOrder.sender).toEqual(undefined); expect(csvOrder.recipientMapping).toEqual(mapping.recipient); expect(csvOrder.templateId).toEqual(template.id); - expect(csvOrder.mergeVariableMapping).toEqual(mapping.mergeVariables); + expect(csvOrder.mergeVariableMapping).toStrictEqual({}); expect(csvOrder.billingId).toEqual( expect.toBeOneOf([undefined, expect.any(String)]), ); @@ -181,7 +181,7 @@ describe("getCsvOrder", function () { expect(csvOrder.sender).toEqual(undefined); expect(csvOrder.recipientMapping).toEqual(mapping.recipient); expect(csvOrder.templateId).toEqual(template.id); - expect(csvOrder.mergeVariableMapping).toEqual(mapping.mergeVariables); + expect(csvOrder.mergeVariableMapping).toStrictEqual({}); expect(csvOrder.billingId).toBeOneOf([undefined, expect.any(String)]); expect(csvOrder.finish).toEqual(expect.any(String)); expect(csvOrder.format).toEqual(expect.any(String)); diff --git a/test/PrintOne.spec.ts b/test/PrintOne.spec.ts index bcb0df0..5dde41d 100644 --- a/test/PrintOne.spec.ts +++ b/test/PrintOne.spec.ts @@ -720,7 +720,7 @@ describe("createCsvOrder", function () { expect(csvOrder.sender).toEqual(undefined); expect(csvOrder.recipientMapping).toEqual(mapping.recipient); expect(csvOrder.templateId).toEqual(template.id); - expect(csvOrder.mergeVariableMapping).toEqual(mapping.mergeVariables); + expect(csvOrder.mergeVariableMapping).toStrictEqual({}); expect(csvOrder.billingId).toBeOneOf([undefined, expect.any(String)]); expect(csvOrder.finish).toEqual(expect.any(String)); expect(csvOrder.format).toEqual(expect.any(String)); @@ -844,7 +844,7 @@ describe("getCsvOrder", function () { expect(csvOrder.sender).toEqual(undefined); expect(csvOrder.recipientMapping).toEqual(mapping.recipient); expect(csvOrder.templateId).toEqual(template.id); - expect(csvOrder.mergeVariableMapping).toEqual(mapping.mergeVariables); + expect(csvOrder.mergeVariableMapping).toStrictEqual({}); expect(csvOrder.billingId).toBeOneOf([undefined, expect.any(String)]); expect(csvOrder.finish).toEqual(expect.any(String)); expect(csvOrder.format).toEqual(expect.any(String));