From f500c1547c32bfe7ce9f2149779223fbf6e4e018 Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Mon, 15 Aug 2022 19:51:01 -0300 Subject: [PATCH 01/17] Tookan Basic TS Config --- components/tookan/package.json | 6 ++++++ components/tookan/tsconfig.json | 22 ++++++++++++++++++++++ pnpm-lock.yaml | 20 +++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 components/tookan/tsconfig.json diff --git a/components/tookan/package.json b/components/tookan/package.json index 79ac2b4d90c95..fc12fb1b8526b 100644 --- a/components/tookan/package.json +++ b/components/tookan/package.json @@ -13,5 +13,11 @@ "license": "MIT", "publishConfig": { "access": "public" + }, + "devDependencies": { + "@pipedream/types": "^0.1.4" + }, + "dependencies": { + "@pipedream/platform": "^1.1.0" } } \ No newline at end of file diff --git a/components/tookan/tsconfig.json b/components/tookan/tsconfig.json new file mode 100644 index 0000000000000..873d4ff05af64 --- /dev/null +++ b/components/tookan/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "lib": ["es2020"], + "module": "ES2020", + "target": "ES2020", + "moduleResolution": "node", + "listEmittedFiles": true, // Used as a part of the build task, since we need to pass emitted files to our post-build script + "composite": true, + "outDir": "dist", + "allowSyntheticDefaultImports": true, + }, + "allowJs": true, + "include": [ + "app", + "actions", + "sources", + "types" + ], + "exclude": [ + "dist", + ] + } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4c72e84185c19..7ad9c6988e85e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -427,6 +427,9 @@ importers: '@pipedream/types': 0.1.3 '@types/node': 17.0.45 + components/dictionary_api: + specifiers: {} + components/digicert: specifiers: {} @@ -564,6 +567,9 @@ importers: dependencies: '@pipedream/platform': 0.10.0 + components/foxy: + specifiers: {} + components/fraudlabs_pro: specifiers: fraudlabspro-nodejs: ^2.1.0 @@ -908,6 +914,9 @@ importers: components/linqs_cc: specifiers: {} + components/lob: + specifiers: {} + components/looker: specifiers: {} @@ -1663,7 +1672,13 @@ importers: specifiers: {} components/tookan: - specifiers: {} + specifiers: + '@pipedream/platform': ^1.1.0 + '@pipedream/types': ^0.1.4 + dependencies: + '@pipedream/platform': 1.1.0 + devDependencies: + '@pipedream/types': 0.1.4 components/transistor_fm: specifiers: {} @@ -1769,6 +1784,9 @@ importers: components/virustotal: specifiers: {} + components/voice: + specifiers: {} + components/voice_monkey: specifiers: {} From 68ae62032f8ce2e555105213323c0f75b3964bcc Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Wed, 17 Aug 2022 13:37:26 -0300 Subject: [PATCH 02/17] temporary request testing --- components/tookan/app/tookan.app.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/components/tookan/app/tookan.app.ts b/components/tookan/app/tookan.app.ts index 9db4315131bfb..611ebbc0980ba 100644 --- a/components/tookan/app/tookan.app.ts +++ b/components/tookan/app/tookan.app.ts @@ -1,3 +1,17 @@ +/* +const data = { + "api_key": `${this.tookan.$auth.api_key}`, + } + return await axios($, { + method: "post", + url: `https://api.tookanapp.com/v2/get_user_details`, + headers: { + "Content-Type": `application/json`, + }, + data, + }) +*/ + import { defineApp } from "@pipedream/types"; export default defineApp({ @@ -10,4 +24,4 @@ export default defineApp({ console.log(Object.keys(this.$auth)); }, }, -}); \ No newline at end of file +}); From 6687cb0af19d47f084620ccf92bab5ebfc91df83 Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Sun, 21 Aug 2022 23:06:03 -0300 Subject: [PATCH 03/17] update pnpm-lock --- pnpm-lock.yaml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ea7a6f9b59cb0..c02860a3ea2f1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -245,6 +245,9 @@ importers: axios: 0.27.2 package-lock-only: 0.0.4 + components/bitrix24: + specifiers: {} + components/blogger: specifiers: '@pipedream/platform': ^0.10.0 @@ -460,9 +463,6 @@ importers: components/dictionary_api: specifiers: {} - components/dictionary_api: - specifiers: {} - components/digicert: specifiers: {} @@ -603,9 +603,6 @@ importers: components/foxy: specifiers: {} - components/foxy: - specifiers: {} - components/fraudlabs_pro: specifiers: fraudlabspro-nodejs: ^2.1.0 @@ -996,9 +993,6 @@ importers: components/lob: specifiers: {} - components/lob: - specifiers: {} - components/looker: specifiers: {} @@ -1839,7 +1833,7 @@ importers: '@pipedream/platform': ^1.1.0 '@pipedream/types': ^0.1.4 dependencies: - '@pipedream/platform': 1.1.0 + '@pipedream/platform': 1.1.1 devDependencies: '@pipedream/types': 0.1.4 @@ -1968,9 +1962,6 @@ importers: components/voice: specifiers: {} - components/voice: - specifiers: {} - components/voice_monkey: specifiers: {} From 64c6121c93389a7b58590e7efa07808463ef3868 Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Sun, 21 Aug 2022 23:23:33 -0300 Subject: [PATCH 04/17] Tookan basic request structure --- components/tookan/app/tookan.app.ts | 39 +++++++++++++---------- components/tookan/common/requestParams.ts | 15 +++++++++ components/tookan/tsconfig.json | 2 +- 3 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 components/tookan/common/requestParams.ts diff --git a/components/tookan/app/tookan.app.ts b/components/tookan/app/tookan.app.ts index 611ebbc0980ba..230aa995df03c 100644 --- a/components/tookan/app/tookan.app.ts +++ b/components/tookan/app/tookan.app.ts @@ -1,27 +1,32 @@ -/* -const data = { - "api_key": `${this.tookan.$auth.api_key}`, - } - return await axios($, { - method: "post", - url: `https://api.tookanapp.com/v2/get_user_details`, - headers: { - "Content-Type": `application/json`, - }, - data, - }) -*/ - import { defineApp } from "@pipedream/types"; +import { axios } from "@pipedream/platform"; +import { HttpRequestParams } from "../common/requestParams"; export default defineApp({ type: "app", app: "tookan", propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl(): string { + return "https://api.tookanapp.com/v2"; + }, + async _httpRequest({ + $ = this, + endpoint, + data, + method + }: HttpRequestParams): Promise { + return axios($, { + url: this._baseUrl() + endpoint, + headers: { + "Content-Type": "application/json", + }, + data: { + api_key: this.$auth.api_key, + ...data + }, + method + }); }, }, }); diff --git a/components/tookan/common/requestParams.ts b/components/tookan/common/requestParams.ts new file mode 100644 index 0000000000000..c1acec0e7c62d --- /dev/null +++ b/components/tookan/common/requestParams.ts @@ -0,0 +1,15 @@ +import { Pipedream } from "@pipedream/types"; + +interface ActionRequestParams { + $?: Pipedream; +} + +interface HttpRequestParams extends ActionRequestParams { + endpoint: string; + data?: object; + method?: string; +} + +export { + HttpRequestParams, +}; diff --git a/components/tookan/tsconfig.json b/components/tookan/tsconfig.json index 873d4ff05af64..ec9c833423b99 100644 --- a/components/tookan/tsconfig.json +++ b/components/tookan/tsconfig.json @@ -14,7 +14,7 @@ "app", "actions", "sources", - "types" + "common" ], "exclude": [ "dist", From 4d5031f8697bdb91d6cd2248a8316b26418ccac2 Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Mon, 22 Aug 2022 00:44:44 -0300 Subject: [PATCH 05/17] Tookan request params --- .../create-appointment-task.ts | 28 ++++++++ components/tookan/common/requestParams.ts | 69 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 components/tookan/actions/create-appointment-task/create-appointment-task.ts diff --git a/components/tookan/actions/create-appointment-task/create-appointment-task.ts b/components/tookan/actions/create-appointment-task/create-appointment-task.ts new file mode 100644 index 0000000000000..594d85981dd65 --- /dev/null +++ b/components/tookan/actions/create-appointment-task/create-appointment-task.ts @@ -0,0 +1,28 @@ +import tookan from "../../app/tookan.app"; +import { defineAction } from "@pipedream/types"; +import { CreateAppointmentTaskParams } from "../../common/requestParams"; + +export default defineAction({ + name: "Create Appointment Task", + description: + "Create an appointment task [See docs here](https://tookanapi.docs.apiary.io/#reference/task/create-task/create-an-appointment-task)", + key: "tookan-create-appointment-task", + version: "0.0.1", + type: "action", + props: { + tookan, + }, + async run({ $ }): Promise { + const params: CreateAppointmentTaskParams = { + $, + // data: { + + // }, + }; + const data = await this.tookan.createAppointmentTask(params); + + $.export("$summary", "Created appointment task successfully"); + + return data; + }, +}); diff --git a/components/tookan/common/requestParams.ts b/components/tookan/common/requestParams.ts index c1acec0e7c62d..a8cfa814ac0c5 100644 --- a/components/tookan/common/requestParams.ts +++ b/components/tookan/common/requestParams.ts @@ -10,6 +10,75 @@ interface HttpRequestParams extends ActionRequestParams { method?: string; } +interface CreateAppointmentTaskParams extends ActionRequestParams { + data?: { + additionalOptions: object; + customer_address: string; + job_delivery_datetime: string; + job_pickup_datetime: string; + timezone: string; + has_pickup: 0; + has_delivery: 0; + layout_type: 1; + }; +} + +interface CreateDeliveryTask extends ActionRequestParams { + data?: { + additionalOptions: object; + customer_address: string; + job_delivery_datetime: string; + timezone: string; + has_pickup: 0; + has_delivery: 1; + layout_type: 0; + }; +} + +interface CreateFieldWorkforceTask extends ActionRequestParams { + data?: { + additionalOptions: object; + customer_address: string; + job_delivery_datetime: string; + job_pickup_datetime: string; + timezone: string; + has_pickup: 0; + has_delivery: 0; + layout_type: 2; + }; +} + +interface CreatePickupTask extends ActionRequestParams { + data?: { + additionalOptions: object; + job_pickup_address: string; + job_pickup_datetime: string; + timezone: string; + has_pickup: 1; + has_delivery: 0; + layout_type: 0; + }; +} + +interface CreatePickupAndDeliveryTask extends ActionRequestParams { + data?: { + additionalOptions: object; + customer_address: string; + job_delivery_datetime: string; + job_pickup_address: string; + job_pickup_datetime: string; + timezone: string; + has_pickup: 1; + has_delivery: 1; + layout_type: 0; + }; +} + export { HttpRequestParams, + CreateAppointmentTaskParams, + CreateDeliveryTask, + CreateFieldWorkforceTask, + CreatePickupTask, + CreatePickupAndDeliveryTask, }; From 95fdd10ebadc4d60579844bf36b680d187f1bcf7 Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Thu, 25 Aug 2022 02:50:48 -0300 Subject: [PATCH 06/17] Action params further mapping --- .../create-appointment-task.ts | 20 +-- components/tookan/app/tookan.app.ts | 6 +- components/tookan/common/requestParams.ts | 116 ++++++++++-------- components/tookan/package.json | 2 +- 4 files changed, 79 insertions(+), 65 deletions(-) diff --git a/components/tookan/actions/create-appointment-task/create-appointment-task.ts b/components/tookan/actions/create-appointment-task/create-appointment-task.ts index 594d85981dd65..d4bcad4144bd7 100644 --- a/components/tookan/actions/create-appointment-task/create-appointment-task.ts +++ b/components/tookan/actions/create-appointment-task/create-appointment-task.ts @@ -12,17 +12,17 @@ export default defineAction({ props: { tookan, }, - async run({ $ }): Promise { - const params: CreateAppointmentTaskParams = { - $, - // data: { - - // }, - }; - const data = await this.tookan.createAppointmentTask(params); + async run({ $ }) { + // const params: CreateAppointmentTaskParams = { + // $, + // // data: { - $.export("$summary", "Created appointment task successfully"); + // // }, + // }; + // const data = await this.tookan.createAppointmentTask(params); - return data; + // $.export("$summary", "Created appointment task successfully"); + + // return data; }, }); diff --git a/components/tookan/app/tookan.app.ts b/components/tookan/app/tookan.app.ts index 230aa995df03c..f0f2deba64d3d 100644 --- a/components/tookan/app/tookan.app.ts +++ b/components/tookan/app/tookan.app.ts @@ -14,7 +14,7 @@ export default defineApp({ $ = this, endpoint, data, - method + method, }: HttpRequestParams): Promise { return axios($, { url: this._baseUrl() + endpoint, @@ -23,9 +23,9 @@ export default defineApp({ }, data: { api_key: this.$auth.api_key, - ...data + ...data, }, - method + method, }); }, }, diff --git a/components/tookan/common/requestParams.ts b/components/tookan/common/requestParams.ts index a8cfa814ac0c5..b14792f125d0b 100644 --- a/components/tookan/common/requestParams.ts +++ b/components/tookan/common/requestParams.ts @@ -1,7 +1,7 @@ import { Pipedream } from "@pipedream/types"; interface ActionRequestParams { - $?: Pipedream; + $: Pipedream; } interface HttpRequestParams extends ActionRequestParams { @@ -10,75 +10,89 @@ interface HttpRequestParams extends ActionRequestParams { method?: string; } -interface CreateAppointmentTaskParams extends ActionRequestParams { - data?: { +type CreateTaskParams = ActionRequestParams & { + data: { additionalOptions: object; - customer_address: string; - job_delivery_datetime: string; - job_pickup_datetime: string; timezone: string; - has_pickup: 0; - has_delivery: 0; - layout_type: 1; + has_pickup: 0 | 1; + has_delivery: 0 | 1; + layout_type: 0 | 1 | 2; }; -} +}; -interface CreateDeliveryTask extends ActionRequestParams { - data?: { - additionalOptions: object; +interface HasDeliveryParams { + data: { customer_address: string; job_delivery_datetime: string; - timezone: string; - has_pickup: 0; - has_delivery: 1; - layout_type: 0; }; } - -interface CreateFieldWorkforceTask extends ActionRequestParams { - data?: { - additionalOptions: object; - customer_address: string; - job_delivery_datetime: string; +interface HasPickupDate { + data: { job_pickup_datetime: string; - timezone: string; - has_pickup: 0; - has_delivery: 0; - layout_type: 2; }; } -interface CreatePickupTask extends ActionRequestParams { - data?: { - additionalOptions: object; +interface HasPickupAddress { + data: { job_pickup_address: string; - job_pickup_datetime: string; - timezone: string; - has_pickup: 1; - has_delivery: 0; - layout_type: 0; }; } -interface CreatePickupAndDeliveryTask extends ActionRequestParams { - data?: { - additionalOptions: object; - customer_address: string; - job_delivery_datetime: string; - job_pickup_address: string; - job_pickup_datetime: string; - timezone: string; - has_pickup: 1; - has_delivery: 1; - layout_type: 0; +type CreateAppointmentTaskParams = CreateTaskParams & + HasDeliveryParams & + HasPickupDate & { + data: { + has_pickup: 0; + has_delivery: 0; + layout_type: 1; + }; + }; + +type CreateDeliveryTaskParams = CreateTaskParams & + HasDeliveryParams & { + data: { + has_pickup: 0; + has_delivery: 1; + layout_type: 0; + }; + }; + +type CreateFieldWorkforceTaskParams = CreateTaskParams & + HasDeliveryParams & + HasPickupDate & { + data: { + has_pickup: 0; + has_delivery: 0; + layout_type: 2; + }; + }; + +type CreatePickupTaskParams = CreateTaskParams & + HasPickupDate & + HasPickupAddress & { + data: { + has_pickup: 1; + has_delivery: 0; + layout_type: 0; + }; + }; + +type CreatePickupAndDeliveryTaskParams = CreateTaskParams & + HasPickupDate & + HasDeliveryParams & + HasPickupAddress & { + data: { + has_pickup: 1; + has_delivery: 1; + layout_type: 0; + }; }; -} export { HttpRequestParams, CreateAppointmentTaskParams, - CreateDeliveryTask, - CreateFieldWorkforceTask, - CreatePickupTask, - CreatePickupAndDeliveryTask, + CreateDeliveryTaskParams, + CreateFieldWorkforceTaskParams, + CreatePickupTaskParams, + CreatePickupAndDeliveryTaskParams, }; diff --git a/components/tookan/package.json b/components/tookan/package.json index fc12fb1b8526b..c835939e0c4eb 100644 --- a/components/tookan/package.json +++ b/components/tookan/package.json @@ -20,4 +20,4 @@ "dependencies": { "@pipedream/platform": "^1.1.0" } -} \ No newline at end of file +} From 544ea2959e91e4d5dce16210e02d225534a75dc7 Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Thu, 25 Aug 2022 03:33:11 -0300 Subject: [PATCH 07/17] Prop mapping for all actions --- .../create-appointment-task.ts | 25 +++++++++----- components/tookan/app/tookan.app.ts | 34 ++++++++++++++++++- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/components/tookan/actions/create-appointment-task/create-appointment-task.ts b/components/tookan/actions/create-appointment-task/create-appointment-task.ts index d4bcad4144bd7..12d38ce9896af 100644 --- a/components/tookan/actions/create-appointment-task/create-appointment-task.ts +++ b/components/tookan/actions/create-appointment-task/create-appointment-task.ts @@ -13,16 +13,23 @@ export default defineAction({ tookan, }, async run({ $ }) { - // const params: CreateAppointmentTaskParams = { - // $, - // // data: { + const params: CreateAppointmentTaskParams = { + $, + data: { + additionalOptions: {}, + timezone: 'abc', + customer_address: 'test', + job_delivery_datetime: 'test', + job_pickup_datetime: 'test', + has_pickup: 0, + has_delivery: 0, + layout_type: 1 + }, + }; + const data = await this.tookan.createAppointmentTask(params); - // // }, - // }; - // const data = await this.tookan.createAppointmentTask(params); + $.export("$summary", "Created appointment task successfully"); - // $.export("$summary", "Created appointment task successfully"); - - // return data; + return data; }, }); diff --git a/components/tookan/app/tookan.app.ts b/components/tookan/app/tookan.app.ts index f0f2deba64d3d..0854a09366b74 100644 --- a/components/tookan/app/tookan.app.ts +++ b/components/tookan/app/tookan.app.ts @@ -5,7 +5,39 @@ import { HttpRequestParams } from "../common/requestParams"; export default defineApp({ type: "app", app: "tookan", - propDefinitions: {}, + propDefinitions: { + timezone: { + label: "Timezone", + description: "Timezone difference with UTC", + type: "string", + }, + customerAddress: { + label: "Customer Address", + description: "This is the address of the customer to whom the product should be delivered", + type: "string", + }, + jobDeliveryDatetime: { + label: "Job Delivery Date/Time", + description: "This is the time before which the product should be delivered. Use a date/time string in the format `2016-08-14 19:00:00`", + type: "string", + }, + jobPickupDatetime: { + label: "Job Pickup Date/Time", + description: "This is time before which the pickup should be collected. Use a date/time string in the format `2016-08-14 19:00:00`", + type: "string", + }, + jobPickupAddress: { + label: "Job Pickup Address", + description: "The address from which the pickup should be collected", + type: "string", + }, + additionalOptions: { + label: "Additional Options", + description: "Any optional parameters to pass to this request", + type: "object", + optional: true, + }, + }, methods: { _baseUrl(): string { return "https://api.tookanapp.com/v2"; From ddfd322bc8d65a003b782a0cc7f7cff5fce22591 Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Fri, 26 Aug 2022 18:22:02 -0300 Subject: [PATCH 08/17] Action params and request functions --- components/tookan/app/tookan.app.ts | 42 ++++++++++++++++++++--- components/tookan/common/requestParams.ts | 2 +- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/components/tookan/app/tookan.app.ts b/components/tookan/app/tookan.app.ts index 0854a09366b74..79ea2b624f0b5 100644 --- a/components/tookan/app/tookan.app.ts +++ b/components/tookan/app/tookan.app.ts @@ -1,6 +1,13 @@ import { defineApp } from "@pipedream/types"; import { axios } from "@pipedream/platform"; -import { HttpRequestParams } from "../common/requestParams"; +import { + HttpRequestParams, + CreateAppointmentTaskParams, + CreateDeliveryTaskParams, + CreateFieldWorkforceTaskParams, + CreatePickupAndDeliveryTaskParams, + CreatePickupTaskParams, +} from "../common/requestParams"; export default defineApp({ type: "app", @@ -13,17 +20,20 @@ export default defineApp({ }, customerAddress: { label: "Customer Address", - description: "This is the address of the customer to whom the product should be delivered", + description: + "This is the address of the customer to whom the product should be delivered", type: "string", }, jobDeliveryDatetime: { label: "Job Delivery Date/Time", - description: "This is the time before which the product should be delivered. Use a date/time string in the format `2016-08-14 19:00:00`", + description: + "This is the time before which the product should be delivered. Use a date/time string in the format `2016-08-14 19:00:00`", type: "string", }, jobPickupDatetime: { label: "Job Pickup Date/Time", - description: "This is time before which the pickup should be collected. Use a date/time string in the format `2016-08-14 19:00:00`", + description: + "This is time before which the pickup should be collected. Use a date/time string in the format `2016-08-14 19:00:00`", type: "string", }, jobPickupAddress: { @@ -60,5 +70,29 @@ export default defineApp({ method, }); }, + async createTask(params: { data: object }) { + return this._httpRequest({ + endpoint: "/create_task", + method: "POST", + ...params, + }); + }, + async createAppointmentTask(params: CreateAppointmentTaskParams) { + return this.createTask(params); + }, + async createDeliveryTask(params: CreateDeliveryTaskParams) { + return this.createTask(params); + }, + async createFieldWorkforceTask(params: CreateFieldWorkforceTaskParams) { + return this.createTask(params); + }, + async createPickupAndDeliveryTask( + params: CreatePickupAndDeliveryTaskParams + ) { + return this.createTask(params); + }, + async createPickupTask(params: CreatePickupTaskParams) { + return this.createTask(params); + }, }, }); diff --git a/components/tookan/common/requestParams.ts b/components/tookan/common/requestParams.ts index b14792f125d0b..deea1664e848e 100644 --- a/components/tookan/common/requestParams.ts +++ b/components/tookan/common/requestParams.ts @@ -93,6 +93,6 @@ export { CreateAppointmentTaskParams, CreateDeliveryTaskParams, CreateFieldWorkforceTaskParams, - CreatePickupTaskParams, CreatePickupAndDeliveryTaskParams, + CreatePickupTaskParams, }; From 0bfa0b31cb7315171ee8a4feb84ff72838335819 Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Mon, 29 Aug 2022 02:48:09 -0300 Subject: [PATCH 09/17] Create Appointment Task --- components/tookan/actions/common.ts | 28 +++++++++++++++++++ .../create-appointment-task.ts | 25 ++++++++++++----- components/tookan/app/tookan.app.ts | 2 +- 3 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 components/tookan/actions/common.ts diff --git a/components/tookan/actions/common.ts b/components/tookan/actions/common.ts new file mode 100644 index 0000000000000..8173ec074d144 --- /dev/null +++ b/components/tookan/actions/common.ts @@ -0,0 +1,28 @@ +import tookan from "../app/tookan.app"; + +export default { + props: { + tookan, + additionalOptions: { + propDefinition: [tookan, "additionalOptions"], + }, + timezone: { + propDefinition: [tookan, "timezone"], + }, + }, +}; + +/* + customerAddress: { + propDefinition: [tookan, "customerAddress"], + }, + jobDeliveryDatetime: { + propDefinition: [tookan, "jobDeliveryDatetime"], + }, + jobPickupDatetime: { + propDefinition: [tookan, "jobPickupDatetime"], + }, + jobPickupAddress: { + propDefinition: [tookan, "jobPickupAddress"], + }, + */ diff --git a/components/tookan/actions/create-appointment-task/create-appointment-task.ts b/components/tookan/actions/create-appointment-task/create-appointment-task.ts index 12d38ce9896af..ca448011c9c3c 100644 --- a/components/tookan/actions/create-appointment-task/create-appointment-task.ts +++ b/components/tookan/actions/create-appointment-task/create-appointment-task.ts @@ -1,8 +1,10 @@ -import tookan from "../../app/tookan.app"; import { defineAction } from "@pipedream/types"; import { CreateAppointmentTaskParams } from "../../common/requestParams"; +import tookan from "../../app/tookan.app"; +import common from "../common"; export default defineAction({ + ...common, name: "Create Appointment Task", description: "Create an appointment task [See docs here](https://tookanapi.docs.apiary.io/#reference/task/create-task/create-an-appointment-task)", @@ -10,17 +12,26 @@ export default defineAction({ version: "0.0.1", type: "action", props: { - tookan, + ...common.props, + customerAddress: { + propDefinition: [tookan, "customerAddress"], + }, + jobDeliveryDatetime: { + propDefinition: [tookan, "jobDeliveryDatetime"], + }, + jobPickupDatetime: { + propDefinition: [tookan, "jobPickupDatetime"], + }, }, async run({ $ }) { const params: CreateAppointmentTaskParams = { $, data: { - additionalOptions: {}, - timezone: 'abc', - customer_address: 'test', - job_delivery_datetime: 'test', - job_pickup_datetime: 'test', + additionalOptions: this.additionalOptions, + timezone: this.timezone, + customer_address: this.customerAddress, + job_delivery_datetime: this.jobDeliveryDatetime, + job_pickup_datetime: this.jobPickupDatetime, has_pickup: 0, has_delivery: 0, layout_type: 1 diff --git a/components/tookan/app/tookan.app.ts b/components/tookan/app/tookan.app.ts index 79ea2b624f0b5..68a852128948b 100644 --- a/components/tookan/app/tookan.app.ts +++ b/components/tookan/app/tookan.app.ts @@ -43,7 +43,7 @@ export default defineApp({ }, additionalOptions: { label: "Additional Options", - description: "Any optional parameters to pass to this request", + description: "Any optional parameters to pass to the request", type: "object", optional: true, }, From 6b51b61590e87016442711eef2fa9e41d03de54a Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Mon, 29 Aug 2022 03:05:02 -0300 Subject: [PATCH 10/17] Tookan actions / common --- .../create-appointment-task.ts | 2 +- .../create-delivery-task.ts | 42 ++++++++++++++++ .../create-field-workforce-task.ts | 46 +++++++++++++++++ .../create-pickup-and-delivery-task.ts | 50 +++++++++++++++++++ .../create-pickup-task/create-pickup-task.ts | 42 ++++++++++++++++ components/tookan/common/requestParams.ts | 12 ++--- 6 files changed, 187 insertions(+), 7 deletions(-) create mode 100644 components/tookan/actions/create-delivery-task/create-delivery-task.ts create mode 100644 components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts create mode 100644 components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts create mode 100644 components/tookan/actions/create-pickup-task/create-pickup-task.ts diff --git a/components/tookan/actions/create-appointment-task/create-appointment-task.ts b/components/tookan/actions/create-appointment-task/create-appointment-task.ts index ca448011c9c3c..e94bf1a805b25 100644 --- a/components/tookan/actions/create-appointment-task/create-appointment-task.ts +++ b/components/tookan/actions/create-appointment-task/create-appointment-task.ts @@ -32,8 +32,8 @@ export default defineAction({ customer_address: this.customerAddress, job_delivery_datetime: this.jobDeliveryDatetime, job_pickup_datetime: this.jobPickupDatetime, - has_pickup: 0, has_delivery: 0, + has_pickup: 0, layout_type: 1 }, }; diff --git a/components/tookan/actions/create-delivery-task/create-delivery-task.ts b/components/tookan/actions/create-delivery-task/create-delivery-task.ts new file mode 100644 index 0000000000000..2cfdb607411f6 --- /dev/null +++ b/components/tookan/actions/create-delivery-task/create-delivery-task.ts @@ -0,0 +1,42 @@ +import { defineAction } from "@pipedream/types"; +import { CreateDeliveryTaskParams } from "../../common/requestParams"; +import tookan from "../../app/tookan.app"; +import common from "../common"; + +export default defineAction({ + ...common, + name: "Create Delivery Task", + description: + "Create a delivery task [See docs here](https://tookanapi.docs.apiary.io/#reference/task/create-task/create-a-delivery-task)", + key: "tookan-create-delivery-task", + version: "0.0.1", + type: "action", + props: { + ...common.props, + customerAddress: { + propDefinition: [tookan, "customerAddress"], + }, + jobDeliveryDatetime: { + propDefinition: [tookan, "jobDeliveryDatetime"], + }, + }, + async run({ $ }) { + const params: CreateDeliveryTaskParams = { + $, + data: { + additionalOptions: this.additionalOptions, + timezone: this.timezone, + customer_address: this.customerAddress, + job_delivery_datetime: this.jobDeliveryDatetime, + has_delivery: 1, + has_pickup: 0, + layout_type: 0 + }, + }; + const data = await this.tookan.createDeliveryTask(params); + + $.export("$summary", "Created delivery task successfully"); + + return data; + }, +}); diff --git a/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts b/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts new file mode 100644 index 0000000000000..a28a9c92ee3a3 --- /dev/null +++ b/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts @@ -0,0 +1,46 @@ +import { defineAction } from "@pipedream/types"; +import { CreateFieldWorkforceTaskParams } from "../../common/requestParams"; +import tookan from "../../app/tookan.app"; +import common from "../common"; + +export default defineAction({ + ...common, + name: "Create Field Workforce Task", + description: + "Create a field workforce task [See docs here](https://tookanapi.docs.apiary.io/#reference/task/create-task/create-a-field-workforce-task)", + key: "tookan-create-field-workforce-task", + version: "0.0.1", + type: "action", + props: { + ...common.props, + customerAddress: { + propDefinition: [tookan, "customerAddress"], + }, + jobDeliveryDatetime: { + propDefinition: [tookan, "jobDeliveryDatetime"], + }, + jobPickupDatetime: { + propDefinition: [tookan, "jobPickupDatetime"], + }, + }, + async run({ $ }) { + const params: CreateFieldWorkforceTaskParams = { + $, + data: { + additionalOptions: this.additionalOptions, + timezone: this.timezone, + customer_address: this.customerAddress, + job_delivery_datetime: this.jobDeliveryDatetime, + job_pickup_datetime: this.jobPickupDatetime, + has_delivery: 0, + has_pickup: 0, + layout_type: 2 + }, + }; + const data = await this.tookan.createFieldWorkforceTask(params); + + $.export("$summary", "Created field workforce task successfully"); + + return data; + }, +}); diff --git a/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts b/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts new file mode 100644 index 0000000000000..9187c069a61bb --- /dev/null +++ b/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts @@ -0,0 +1,50 @@ +import { defineAction } from "@pipedream/types"; +import { CreatePickupAndDeliveryTaskParams } from "../../common/requestParams"; +import tookan from "../../app/tookan.app"; +import common from "../common"; + +export default defineAction({ + ...common, + name: "Create Pickup And Delivery Task", + description: + "Create a pickup and delivery task [See docs here](https://tookanapi.docs.apiary.io/#reference/task/create-task/create-a-pickup-and-delivery-task)", + key: "tookan-create-pickup-and-delivery-task", + version: "0.0.1", + type: "action", + props: { + ...common.props, + customerAddress: { + propDefinition: [tookan, "customerAddress"], + }, + jobDeliveryDatetime: { + propDefinition: [tookan, "jobDeliveryDatetime"], + }, + jobPickupAddress: { + propDefinition: [tookan, "jobPickupAddress"], + }, + jobPickupDatetime: { + propDefinition: [tookan, "jobPickupDatetime"], + }, + }, + async run({ $ }) { + const params: CreatePickupAndDeliveryTaskParams = { + $, + data: { + additionalOptions: this.additionalOptions, + timezone: this.timezone, + customer_address: this.customerAddress, + job_delivery_datetime: this.jobDeliveryDatetime, + job_pickup_address: this.jobPickupAddress, + job_pickup_datetime: this.jobPickupDatetime, + has_delivery: 1, + has_pickup: 1, + layout_type: 0 + }, + }; + const data = await this.tookan.createPickupAndDeliveryTask(params); + + $.export("$summary", "Created pickup and delivery task successfully"); + + return data; + }, +}); diff --git a/components/tookan/actions/create-pickup-task/create-pickup-task.ts b/components/tookan/actions/create-pickup-task/create-pickup-task.ts new file mode 100644 index 0000000000000..f6e9877837cc4 --- /dev/null +++ b/components/tookan/actions/create-pickup-task/create-pickup-task.ts @@ -0,0 +1,42 @@ +import { defineAction } from "@pipedream/types"; +import { CreatePickupTaskParams } from "../../common/requestParams"; +import tookan from "../../app/tookan.app"; +import common from "../common"; + +export default defineAction({ + ...common, + name: "Create Pickup Task", + description: + "Create a pickup task [See docs here](https://tookanapi.docs.apiary.io/#reference/task/create-task/create-a-pickup-task)", + key: "tookan-create-pickup-task", + version: "0.0.1", + type: "action", + props: { + ...common.props, + jobPickupAddress: { + propDefinition: [tookan, "jobPickupAddress"], + }, + jobPickupDatetime: { + propDefinition: [tookan, "jobPickupDatetime"], + }, + }, + async run({ $ }) { + const params: CreatePickupTaskParams = { + $, + data: { + additionalOptions: this.additionalOptions, + timezone: this.timezone, + job_pickup_address: this.jobPickupAddress, + job_pickup_datetime: this.jobPickupDatetime, + has_delivery: 0, + has_pickup: 1, + layout_type: 0 + }, + }; + const data = await this.tookan.createPickupTask(params); + + $.export("$summary", "Created pickup task successfully"); + + return data; + }, +}); diff --git a/components/tookan/common/requestParams.ts b/components/tookan/common/requestParams.ts index deea1664e848e..c37e5f5d653a3 100644 --- a/components/tookan/common/requestParams.ts +++ b/components/tookan/common/requestParams.ts @@ -14,8 +14,8 @@ type CreateTaskParams = ActionRequestParams & { data: { additionalOptions: object; timezone: string; - has_pickup: 0 | 1; has_delivery: 0 | 1; + has_pickup: 0 | 1; layout_type: 0 | 1 | 2; }; }; @@ -42,8 +42,8 @@ type CreateAppointmentTaskParams = CreateTaskParams & HasDeliveryParams & HasPickupDate & { data: { - has_pickup: 0; has_delivery: 0; + has_pickup: 0; layout_type: 1; }; }; @@ -51,8 +51,8 @@ type CreateAppointmentTaskParams = CreateTaskParams & type CreateDeliveryTaskParams = CreateTaskParams & HasDeliveryParams & { data: { - has_pickup: 0; has_delivery: 1; + has_pickup: 0; layout_type: 0; }; }; @@ -61,8 +61,8 @@ type CreateFieldWorkforceTaskParams = CreateTaskParams & HasDeliveryParams & HasPickupDate & { data: { - has_pickup: 0; has_delivery: 0; + has_pickup: 0; layout_type: 2; }; }; @@ -71,8 +71,8 @@ type CreatePickupTaskParams = CreateTaskParams & HasPickupDate & HasPickupAddress & { data: { - has_pickup: 1; has_delivery: 0; + has_pickup: 1; layout_type: 0; }; }; @@ -82,8 +82,8 @@ type CreatePickupAndDeliveryTaskParams = CreateTaskParams & HasDeliveryParams & HasPickupAddress & { data: { - has_pickup: 1; has_delivery: 1; + has_pickup: 1; layout_type: 0; }; }; From 4ac24a2d2a9969973f10ddf0a14efc02891eafb8 Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Tue, 30 Aug 2022 02:41:53 -0300 Subject: [PATCH 11/17] ESLint Tookan --- components/tookan/actions/common.ts | 10 +++++++-- .../create-appointment-task.ts | 17 ++++++++++---- .../create-delivery-task.ts | 12 +++++++--- .../create-field-workforce-task.ts | 17 ++++++++++---- .../create-pickup-and-delivery-task.ts | 22 ++++++++++++++----- .../create-pickup-task/create-pickup-task.ts | 12 +++++++--- components/tookan/app/tookan.app.ts | 4 ++-- 7 files changed, 71 insertions(+), 23 deletions(-) diff --git a/components/tookan/actions/common.ts b/components/tookan/actions/common.ts index 8173ec074d144..627af9c6c71d6 100644 --- a/components/tookan/actions/common.ts +++ b/components/tookan/actions/common.ts @@ -4,10 +4,16 @@ export default { props: { tookan, additionalOptions: { - propDefinition: [tookan, "additionalOptions"], + propDefinition: [ + tookan, + "additionalOptions", + ], }, timezone: { - propDefinition: [tookan, "timezone"], + propDefinition: [ + tookan, + "timezone", + ], }, }, }; diff --git a/components/tookan/actions/create-appointment-task/create-appointment-task.ts b/components/tookan/actions/create-appointment-task/create-appointment-task.ts index e94bf1a805b25..c17f00f369f69 100644 --- a/components/tookan/actions/create-appointment-task/create-appointment-task.ts +++ b/components/tookan/actions/create-appointment-task/create-appointment-task.ts @@ -14,13 +14,22 @@ export default defineAction({ props: { ...common.props, customerAddress: { - propDefinition: [tookan, "customerAddress"], + propDefinition: [ + tookan, + "customerAddress", + ], }, jobDeliveryDatetime: { - propDefinition: [tookan, "jobDeliveryDatetime"], + propDefinition: [ + tookan, + "jobDeliveryDatetime", + ], }, jobPickupDatetime: { - propDefinition: [tookan, "jobPickupDatetime"], + propDefinition: [ + tookan, + "jobPickupDatetime", + ], }, }, async run({ $ }) { @@ -34,7 +43,7 @@ export default defineAction({ job_pickup_datetime: this.jobPickupDatetime, has_delivery: 0, has_pickup: 0, - layout_type: 1 + layout_type: 1, }, }; const data = await this.tookan.createAppointmentTask(params); diff --git a/components/tookan/actions/create-delivery-task/create-delivery-task.ts b/components/tookan/actions/create-delivery-task/create-delivery-task.ts index 2cfdb607411f6..b02b82389b338 100644 --- a/components/tookan/actions/create-delivery-task/create-delivery-task.ts +++ b/components/tookan/actions/create-delivery-task/create-delivery-task.ts @@ -14,10 +14,16 @@ export default defineAction({ props: { ...common.props, customerAddress: { - propDefinition: [tookan, "customerAddress"], + propDefinition: [ + tookan, + "customerAddress", + ], }, jobDeliveryDatetime: { - propDefinition: [tookan, "jobDeliveryDatetime"], + propDefinition: [ + tookan, + "jobDeliveryDatetime", + ], }, }, async run({ $ }) { @@ -30,7 +36,7 @@ export default defineAction({ job_delivery_datetime: this.jobDeliveryDatetime, has_delivery: 1, has_pickup: 0, - layout_type: 0 + layout_type: 0, }, }; const data = await this.tookan.createDeliveryTask(params); diff --git a/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts b/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts index a28a9c92ee3a3..25db0f6f0d052 100644 --- a/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts +++ b/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts @@ -14,13 +14,22 @@ export default defineAction({ props: { ...common.props, customerAddress: { - propDefinition: [tookan, "customerAddress"], + propDefinition: [ + tookan, + "customerAddress", + ], }, jobDeliveryDatetime: { - propDefinition: [tookan, "jobDeliveryDatetime"], + propDefinition: [ + tookan, + "jobDeliveryDatetime", + ], }, jobPickupDatetime: { - propDefinition: [tookan, "jobPickupDatetime"], + propDefinition: [ + tookan, + "jobPickupDatetime", + ], }, }, async run({ $ }) { @@ -34,7 +43,7 @@ export default defineAction({ job_pickup_datetime: this.jobPickupDatetime, has_delivery: 0, has_pickup: 0, - layout_type: 2 + layout_type: 2, }, }; const data = await this.tookan.createFieldWorkforceTask(params); diff --git a/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts b/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts index 9187c069a61bb..b8e9121653d94 100644 --- a/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts +++ b/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts @@ -14,16 +14,28 @@ export default defineAction({ props: { ...common.props, customerAddress: { - propDefinition: [tookan, "customerAddress"], + propDefinition: [ + tookan, + "customerAddress", + ], }, jobDeliveryDatetime: { - propDefinition: [tookan, "jobDeliveryDatetime"], + propDefinition: [ + tookan, + "jobDeliveryDatetime", + ], }, jobPickupAddress: { - propDefinition: [tookan, "jobPickupAddress"], + propDefinition: [ + tookan, + "jobPickupAddress", + ], }, jobPickupDatetime: { - propDefinition: [tookan, "jobPickupDatetime"], + propDefinition: [ + tookan, + "jobPickupDatetime", + ], }, }, async run({ $ }) { @@ -38,7 +50,7 @@ export default defineAction({ job_pickup_datetime: this.jobPickupDatetime, has_delivery: 1, has_pickup: 1, - layout_type: 0 + layout_type: 0, }, }; const data = await this.tookan.createPickupAndDeliveryTask(params); diff --git a/components/tookan/actions/create-pickup-task/create-pickup-task.ts b/components/tookan/actions/create-pickup-task/create-pickup-task.ts index f6e9877837cc4..7801bfadc1b30 100644 --- a/components/tookan/actions/create-pickup-task/create-pickup-task.ts +++ b/components/tookan/actions/create-pickup-task/create-pickup-task.ts @@ -14,10 +14,16 @@ export default defineAction({ props: { ...common.props, jobPickupAddress: { - propDefinition: [tookan, "jobPickupAddress"], + propDefinition: [ + tookan, + "jobPickupAddress", + ], }, jobPickupDatetime: { - propDefinition: [tookan, "jobPickupDatetime"], + propDefinition: [ + tookan, + "jobPickupDatetime", + ], }, }, async run({ $ }) { @@ -30,7 +36,7 @@ export default defineAction({ job_pickup_datetime: this.jobPickupDatetime, has_delivery: 0, has_pickup: 1, - layout_type: 0 + layout_type: 0, }, }; const data = await this.tookan.createPickupTask(params); diff --git a/components/tookan/app/tookan.app.ts b/components/tookan/app/tookan.app.ts index 68a852128948b..e76269e0d9ad9 100644 --- a/components/tookan/app/tookan.app.ts +++ b/components/tookan/app/tookan.app.ts @@ -70,7 +70,7 @@ export default defineApp({ method, }); }, - async createTask(params: { data: object }) { + async createTask(params: { data: object; }) { return this._httpRequest({ endpoint: "/create_task", method: "POST", @@ -87,7 +87,7 @@ export default defineApp({ return this.createTask(params); }, async createPickupAndDeliveryTask( - params: CreatePickupAndDeliveryTaskParams + params: CreatePickupAndDeliveryTaskParams, ) { return this.createTask(params); }, From acdfad3e5dd447b242dcfcd008cc327d23b2c987 Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Tue, 30 Aug 2022 02:42:50 -0300 Subject: [PATCH 12/17] Removing temporary code --- components/tookan/actions/common.ts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/components/tookan/actions/common.ts b/components/tookan/actions/common.ts index 627af9c6c71d6..ef58cdc708ef8 100644 --- a/components/tookan/actions/common.ts +++ b/components/tookan/actions/common.ts @@ -17,18 +17,3 @@ export default { }, }, }; - -/* - customerAddress: { - propDefinition: [tookan, "customerAddress"], - }, - jobDeliveryDatetime: { - propDefinition: [tookan, "jobDeliveryDatetime"], - }, - jobPickupDatetime: { - propDefinition: [tookan, "jobPickupDatetime"], - }, - jobPickupAddress: { - propDefinition: [tookan, "jobPickupAddress"], - }, - */ From 091b6d30dae90c24aa52debf9568cb16c88a19cb Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Wed, 31 Aug 2022 02:27:21 -0300 Subject: [PATCH 13/17] Type improvements --- components/tookan/app/tookan.app.ts | 19 +++++++++++++------ components/tookan/common/requestParams.ts | 21 ++++++--------------- components/tookan/common/responseSchemas.ts | 5 +++++ 3 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 components/tookan/common/responseSchemas.ts diff --git a/components/tookan/app/tookan.app.ts b/components/tookan/app/tookan.app.ts index e76269e0d9ad9..9314392a806a4 100644 --- a/components/tookan/app/tookan.app.ts +++ b/components/tookan/app/tookan.app.ts @@ -8,6 +8,7 @@ import { CreatePickupAndDeliveryTaskParams, CreatePickupTaskParams, } from "../common/requestParams"; +import { CreateTaskResponse } from "../common/responseSchemas"; export default defineApp({ type: "app", @@ -71,27 +72,33 @@ export default defineApp({ }); }, async createTask(params: { data: object; }) { - return this._httpRequest({ + const response: CreateTaskResponse = await this._httpRequest({ endpoint: "/create_task", method: "POST", ...params, }); + + if (response.status !== 200) { + throw new Error(response.message); + } + + return response.data; }, - async createAppointmentTask(params: CreateAppointmentTaskParams) { + async createAppointmentTask(params: CreateAppointmentTaskParams): Promise { return this.createTask(params); }, - async createDeliveryTask(params: CreateDeliveryTaskParams) { + async createDeliveryTask(params: CreateDeliveryTaskParams): Promise { return this.createTask(params); }, - async createFieldWorkforceTask(params: CreateFieldWorkforceTaskParams) { + async createFieldWorkforceTask(params: CreateFieldWorkforceTaskParams): Promise { return this.createTask(params); }, async createPickupAndDeliveryTask( params: CreatePickupAndDeliveryTaskParams, - ) { + ): Promise { return this.createTask(params); }, - async createPickupTask(params: CreatePickupTaskParams) { + async createPickupTask(params: CreatePickupTaskParams): Promise { return this.createTask(params); }, }, diff --git a/components/tookan/common/requestParams.ts b/components/tookan/common/requestParams.ts index c37e5f5d653a3..f115b7f49b333 100644 --- a/components/tookan/common/requestParams.ts +++ b/components/tookan/common/requestParams.ts @@ -4,7 +4,7 @@ interface ActionRequestParams { $: Pipedream; } -interface HttpRequestParams extends ActionRequestParams { +export interface HttpRequestParams extends ActionRequestParams { endpoint: string; data?: object; method?: string; @@ -38,7 +38,7 @@ interface HasPickupAddress { }; } -type CreateAppointmentTaskParams = CreateTaskParams & +export type CreateAppointmentTaskParams = CreateTaskParams & HasDeliveryParams & HasPickupDate & { data: { @@ -48,7 +48,7 @@ type CreateAppointmentTaskParams = CreateTaskParams & }; }; -type CreateDeliveryTaskParams = CreateTaskParams & +export type CreateDeliveryTaskParams = CreateTaskParams & HasDeliveryParams & { data: { has_delivery: 1; @@ -57,7 +57,7 @@ type CreateDeliveryTaskParams = CreateTaskParams & }; }; -type CreateFieldWorkforceTaskParams = CreateTaskParams & +export type CreateFieldWorkforceTaskParams = CreateTaskParams & HasDeliveryParams & HasPickupDate & { data: { @@ -67,7 +67,7 @@ type CreateFieldWorkforceTaskParams = CreateTaskParams & }; }; -type CreatePickupTaskParams = CreateTaskParams & +export type CreatePickupTaskParams = CreateTaskParams & HasPickupDate & HasPickupAddress & { data: { @@ -77,7 +77,7 @@ type CreatePickupTaskParams = CreateTaskParams & }; }; -type CreatePickupAndDeliveryTaskParams = CreateTaskParams & +export type CreatePickupAndDeliveryTaskParams = CreateTaskParams & HasPickupDate & HasDeliveryParams & HasPickupAddress & { @@ -87,12 +87,3 @@ type CreatePickupAndDeliveryTaskParams = CreateTaskParams & layout_type: 0; }; }; - -export { - HttpRequestParams, - CreateAppointmentTaskParams, - CreateDeliveryTaskParams, - CreateFieldWorkforceTaskParams, - CreatePickupAndDeliveryTaskParams, - CreatePickupTaskParams, -}; diff --git a/components/tookan/common/responseSchemas.ts b/components/tookan/common/responseSchemas.ts new file mode 100644 index 0000000000000..cf64b11b65a33 --- /dev/null +++ b/components/tookan/common/responseSchemas.ts @@ -0,0 +1,5 @@ +export interface CreateTaskResponse { + message: string; + status: number; + data: object; +} From 5880bba7233c93ab16d87d12180ad4099f43780e Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Wed, 31 Aug 2022 02:28:44 -0300 Subject: [PATCH 14/17] Task creation type improvements --- .../actions/create-appointment-task/create-appointment-task.ts | 2 +- .../tookan/actions/create-delivery-task/create-delivery-task.ts | 2 +- .../create-field-workforce-task/create-field-workforce-task.ts | 2 +- .../create-pickup-and-delivery-task.ts | 2 +- .../tookan/actions/create-pickup-task/create-pickup-task.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/tookan/actions/create-appointment-task/create-appointment-task.ts b/components/tookan/actions/create-appointment-task/create-appointment-task.ts index c17f00f369f69..0c55dd5d153d3 100644 --- a/components/tookan/actions/create-appointment-task/create-appointment-task.ts +++ b/components/tookan/actions/create-appointment-task/create-appointment-task.ts @@ -46,7 +46,7 @@ export default defineAction({ layout_type: 1, }, }; - const data = await this.tookan.createAppointmentTask(params); + const data: object = await this.tookan.createAppointmentTask(params); $.export("$summary", "Created appointment task successfully"); diff --git a/components/tookan/actions/create-delivery-task/create-delivery-task.ts b/components/tookan/actions/create-delivery-task/create-delivery-task.ts index b02b82389b338..d3efd6d1a0b22 100644 --- a/components/tookan/actions/create-delivery-task/create-delivery-task.ts +++ b/components/tookan/actions/create-delivery-task/create-delivery-task.ts @@ -39,7 +39,7 @@ export default defineAction({ layout_type: 0, }, }; - const data = await this.tookan.createDeliveryTask(params); + const data: object = await this.tookan.createDeliveryTask(params); $.export("$summary", "Created delivery task successfully"); diff --git a/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts b/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts index 25db0f6f0d052..f39eed2f819e9 100644 --- a/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts +++ b/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts @@ -46,7 +46,7 @@ export default defineAction({ layout_type: 2, }, }; - const data = await this.tookan.createFieldWorkforceTask(params); + const data: object = await this.tookan.createFieldWorkforceTask(params); $.export("$summary", "Created field workforce task successfully"); diff --git a/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts b/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts index b8e9121653d94..a072db55a678b 100644 --- a/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts +++ b/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts @@ -53,7 +53,7 @@ export default defineAction({ layout_type: 0, }, }; - const data = await this.tookan.createPickupAndDeliveryTask(params); + const data: object = await this.tookan.createPickupAndDeliveryTask(params); $.export("$summary", "Created pickup and delivery task successfully"); diff --git a/components/tookan/actions/create-pickup-task/create-pickup-task.ts b/components/tookan/actions/create-pickup-task/create-pickup-task.ts index 7801bfadc1b30..d56f0e2c23e7f 100644 --- a/components/tookan/actions/create-pickup-task/create-pickup-task.ts +++ b/components/tookan/actions/create-pickup-task/create-pickup-task.ts @@ -39,7 +39,7 @@ export default defineAction({ layout_type: 0, }, }; - const data = await this.tookan.createPickupTask(params); + const data: object = await this.tookan.createPickupTask(params); $.export("$summary", "Created pickup task successfully"); From 0c2d9a1cfb81a4e786d7d156ff3acad0695528bc Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Wed, 31 Aug 2022 03:14:54 -0300 Subject: [PATCH 15/17] Prop and error improvements --- components/tookan/app/tookan.app.ts | 12 +++++++---- components/tookan/common/timezones.ts | 30 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 components/tookan/common/timezones.ts diff --git a/components/tookan/app/tookan.app.ts b/components/tookan/app/tookan.app.ts index 9314392a806a4..68279509db0b3 100644 --- a/components/tookan/app/tookan.app.ts +++ b/components/tookan/app/tookan.app.ts @@ -9,15 +9,19 @@ import { CreatePickupTaskParams, } from "../common/requestParams"; import { CreateTaskResponse } from "../common/responseSchemas"; +import timezoneOptions from "../common/timezones"; export default defineApp({ type: "app", app: "tookan", propDefinitions: { timezone: { - label: "Timezone", - description: "Timezone difference with UTC", + label: "Time Zone", + description: `Select a **time zone** from the list. + \\ + You can also provide a custom value indicating the difference with UTC in minutes, such as \`+480\` for PST.`, type: "string", + options: timezoneOptions, }, customerAddress: { label: "Customer Address", @@ -44,7 +48,7 @@ export default defineApp({ }, additionalOptions: { label: "Additional Options", - description: "Any optional parameters to pass to the request", + description: "Any optional parameters to pass to the request [(see the Tookan API docs for available parameters)](https://tookanapi.docs.apiary.io/#reference/task/create-task)", type: "object", optional: true, }, @@ -79,7 +83,7 @@ export default defineApp({ }); if (response.status !== 200) { - throw new Error(response.message); + throw new Error("Tookan response: " + response.message); } return response.data; diff --git a/components/tookan/common/timezones.ts b/components/tookan/common/timezones.ts new file mode 100644 index 0000000000000..e61db6e2aef7a --- /dev/null +++ b/components/tookan/common/timezones.ts @@ -0,0 +1,30 @@ +const timezoneNames = [ + "-8 (PST)", + "-7 (MST)", + "-6 (CST)", + "-5 (EST)", + "-4 (AST)", + "-3 (BRT)", + "-2", + "-1", + "0 (GMT)", + "+1 (CET)", + "+2 (EET)", + "+3 (MSK)", + "+4", +]; +let initialValue = -9 * 60; + +function getTimezoneString() { + const value = (initialValue += 60); + return value > 0 + ? `+${value}` + : value.toString(); +} + +const timezoneOptions = timezoneNames.map((name) => ({ + label: "UTC " + name, + value: getTimezoneString(), +})); + +export default timezoneOptions; From 85fe7ae908a006b10d43e76dc3a987b5ae39b7a2 Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Thu, 1 Sep 2022 13:17:28 -0300 Subject: [PATCH 16/17] PR improvements --- .../create-appointment-task/create-appointment-task.ts | 5 +++-- .../create-delivery-task/create-delivery-task.ts | 5 +++-- .../create-field-workforce-task.ts | 5 +++-- .../create-pickup-and-delivery-task.ts | 10 ++++++++-- .../actions/create-pickup-task/create-pickup-task.ts | 5 +++-- components/tookan/common/responseSchemas.ts | 7 ++++++- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/components/tookan/actions/create-appointment-task/create-appointment-task.ts b/components/tookan/actions/create-appointment-task/create-appointment-task.ts index 0c55dd5d153d3..193a3628ec10e 100644 --- a/components/tookan/actions/create-appointment-task/create-appointment-task.ts +++ b/components/tookan/actions/create-appointment-task/create-appointment-task.ts @@ -2,6 +2,7 @@ import { defineAction } from "@pipedream/types"; import { CreateAppointmentTaskParams } from "../../common/requestParams"; import tookan from "../../app/tookan.app"; import common from "../common"; +import { TaskData } from "../../common/responseSchemas"; export default defineAction({ ...common, @@ -46,9 +47,9 @@ export default defineAction({ layout_type: 1, }, }; - const data: object = await this.tookan.createAppointmentTask(params); + const data: TaskData = await this.tookan.createAppointmentTask(params); - $.export("$summary", "Created appointment task successfully"); + $.export("$summary", `Created appointment task successfully (id ${data.job_id})`); return data; }, diff --git a/components/tookan/actions/create-delivery-task/create-delivery-task.ts b/components/tookan/actions/create-delivery-task/create-delivery-task.ts index d3efd6d1a0b22..0672abd9cadc1 100644 --- a/components/tookan/actions/create-delivery-task/create-delivery-task.ts +++ b/components/tookan/actions/create-delivery-task/create-delivery-task.ts @@ -2,6 +2,7 @@ import { defineAction } from "@pipedream/types"; import { CreateDeliveryTaskParams } from "../../common/requestParams"; import tookan from "../../app/tookan.app"; import common from "../common"; +import { TaskData } from "../../common/responseSchemas"; export default defineAction({ ...common, @@ -39,9 +40,9 @@ export default defineAction({ layout_type: 0, }, }; - const data: object = await this.tookan.createDeliveryTask(params); + const data: TaskData = await this.tookan.createDeliveryTask(params); - $.export("$summary", "Created delivery task successfully"); + $.export("$summary", `Created delivery task successfully (id ${data.job_id})`); return data; }, diff --git a/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts b/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts index f39eed2f819e9..c199667f6c8eb 100644 --- a/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts +++ b/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts @@ -2,6 +2,7 @@ import { defineAction } from "@pipedream/types"; import { CreateFieldWorkforceTaskParams } from "../../common/requestParams"; import tookan from "../../app/tookan.app"; import common from "../common"; +import { TaskData } from "../../common/responseSchemas"; export default defineAction({ ...common, @@ -46,9 +47,9 @@ export default defineAction({ layout_type: 2, }, }; - const data: object = await this.tookan.createFieldWorkforceTask(params); + const data: TaskData = await this.tookan.createFieldWorkforceTask(params); - $.export("$summary", "Created field workforce task successfully"); + $.export("$summary", `Created field workforce task successfully (id ${data.job_id})`); return data; }, diff --git a/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts b/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts index a072db55a678b..775d3507d1189 100644 --- a/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts +++ b/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts @@ -2,6 +2,7 @@ import { defineAction } from "@pipedream/types"; import { CreatePickupAndDeliveryTaskParams } from "../../common/requestParams"; import tookan from "../../app/tookan.app"; import common from "../common"; +import { TaskData } from "../../common/responseSchemas"; export default defineAction({ ...common, @@ -53,9 +54,14 @@ export default defineAction({ layout_type: 0, }, }; - const data: object = await this.tookan.createPickupAndDeliveryTask(params); + const data: TaskData = await this.tookan.createPickupAndDeliveryTask( + params, + ); - $.export("$summary", "Created pickup and delivery task successfully"); + $.export( + "$summary", + `Created pickup and delivery task successfully (id ${data.job_id})`, + ); return data; }, diff --git a/components/tookan/actions/create-pickup-task/create-pickup-task.ts b/components/tookan/actions/create-pickup-task/create-pickup-task.ts index d56f0e2c23e7f..22031046838b9 100644 --- a/components/tookan/actions/create-pickup-task/create-pickup-task.ts +++ b/components/tookan/actions/create-pickup-task/create-pickup-task.ts @@ -2,6 +2,7 @@ import { defineAction } from "@pipedream/types"; import { CreatePickupTaskParams } from "../../common/requestParams"; import tookan from "../../app/tookan.app"; import common from "../common"; +import { TaskData } from "../../common/responseSchemas"; export default defineAction({ ...common, @@ -39,9 +40,9 @@ export default defineAction({ layout_type: 0, }, }; - const data: object = await this.tookan.createPickupTask(params); + const data: TaskData = await this.tookan.createPickupTask(params); - $.export("$summary", "Created pickup task successfully"); + $.export("$summary", `Created pickup task successfully (id ${data.job_id})`); return data; }, diff --git a/components/tookan/common/responseSchemas.ts b/components/tookan/common/responseSchemas.ts index cf64b11b65a33..d47d46c9fa210 100644 --- a/components/tookan/common/responseSchemas.ts +++ b/components/tookan/common/responseSchemas.ts @@ -1,5 +1,10 @@ +export interface TaskData { + job_id: number; +} + export interface CreateTaskResponse { message: string; status: number; - data: object; + data: TaskData; } + From 54bebffeb7e86bbb3028543c30811599ec683e20 Mon Sep 17 00:00:00 2001 From: "guilherme.falcao" Date: Mon, 5 Sep 2022 23:16:33 -0300 Subject: [PATCH 17/17] Fixing additional options --- .../actions/create-appointment-task/create-appointment-task.ts | 2 +- .../tookan/actions/create-delivery-task/create-delivery-task.ts | 2 +- .../create-field-workforce-task/create-field-workforce-task.ts | 2 +- .../create-pickup-and-delivery-task.ts | 2 +- .../tookan/actions/create-pickup-task/create-pickup-task.ts | 2 +- components/tookan/common/requestParams.ts | 1 - 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/components/tookan/actions/create-appointment-task/create-appointment-task.ts b/components/tookan/actions/create-appointment-task/create-appointment-task.ts index 193a3628ec10e..63bb696ec9bf1 100644 --- a/components/tookan/actions/create-appointment-task/create-appointment-task.ts +++ b/components/tookan/actions/create-appointment-task/create-appointment-task.ts @@ -37,7 +37,6 @@ export default defineAction({ const params: CreateAppointmentTaskParams = { $, data: { - additionalOptions: this.additionalOptions, timezone: this.timezone, customer_address: this.customerAddress, job_delivery_datetime: this.jobDeliveryDatetime, @@ -45,6 +44,7 @@ export default defineAction({ has_delivery: 0, has_pickup: 0, layout_type: 1, + ...this.additionalOptions, }, }; const data: TaskData = await this.tookan.createAppointmentTask(params); diff --git a/components/tookan/actions/create-delivery-task/create-delivery-task.ts b/components/tookan/actions/create-delivery-task/create-delivery-task.ts index 0672abd9cadc1..92b2be4a31718 100644 --- a/components/tookan/actions/create-delivery-task/create-delivery-task.ts +++ b/components/tookan/actions/create-delivery-task/create-delivery-task.ts @@ -31,13 +31,13 @@ export default defineAction({ const params: CreateDeliveryTaskParams = { $, data: { - additionalOptions: this.additionalOptions, timezone: this.timezone, customer_address: this.customerAddress, job_delivery_datetime: this.jobDeliveryDatetime, has_delivery: 1, has_pickup: 0, layout_type: 0, + ...this.additionalOptions, }, }; const data: TaskData = await this.tookan.createDeliveryTask(params); diff --git a/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts b/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts index c199667f6c8eb..e6c379ebcfdc3 100644 --- a/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts +++ b/components/tookan/actions/create-field-workforce-task/create-field-workforce-task.ts @@ -37,7 +37,6 @@ export default defineAction({ const params: CreateFieldWorkforceTaskParams = { $, data: { - additionalOptions: this.additionalOptions, timezone: this.timezone, customer_address: this.customerAddress, job_delivery_datetime: this.jobDeliveryDatetime, @@ -45,6 +44,7 @@ export default defineAction({ has_delivery: 0, has_pickup: 0, layout_type: 2, + ...this.additionalOptions, }, }; const data: TaskData = await this.tookan.createFieldWorkforceTask(params); diff --git a/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts b/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts index 775d3507d1189..b130622069dbc 100644 --- a/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts +++ b/components/tookan/actions/create-pickup-and-delivery-task/create-pickup-and-delivery-task.ts @@ -43,7 +43,6 @@ export default defineAction({ const params: CreatePickupAndDeliveryTaskParams = { $, data: { - additionalOptions: this.additionalOptions, timezone: this.timezone, customer_address: this.customerAddress, job_delivery_datetime: this.jobDeliveryDatetime, @@ -52,6 +51,7 @@ export default defineAction({ has_delivery: 1, has_pickup: 1, layout_type: 0, + ...this.additionalOptions, }, }; const data: TaskData = await this.tookan.createPickupAndDeliveryTask( diff --git a/components/tookan/actions/create-pickup-task/create-pickup-task.ts b/components/tookan/actions/create-pickup-task/create-pickup-task.ts index 22031046838b9..5bc0cb98c032e 100644 --- a/components/tookan/actions/create-pickup-task/create-pickup-task.ts +++ b/components/tookan/actions/create-pickup-task/create-pickup-task.ts @@ -31,13 +31,13 @@ export default defineAction({ const params: CreatePickupTaskParams = { $, data: { - additionalOptions: this.additionalOptions, timezone: this.timezone, job_pickup_address: this.jobPickupAddress, job_pickup_datetime: this.jobPickupDatetime, has_delivery: 0, has_pickup: 1, layout_type: 0, + ...this.additionalOptions, }, }; const data: TaskData = await this.tookan.createPickupTask(params); diff --git a/components/tookan/common/requestParams.ts b/components/tookan/common/requestParams.ts index f115b7f49b333..2b74a3ebda73b 100644 --- a/components/tookan/common/requestParams.ts +++ b/components/tookan/common/requestParams.ts @@ -12,7 +12,6 @@ export interface HttpRequestParams extends ActionRequestParams { type CreateTaskParams = ActionRequestParams & { data: { - additionalOptions: object; timezone: string; has_delivery: 0 | 1; has_pickup: 0 | 1;