From 08b3ac466bf516c61e3016b3db61ceaebea1b674 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Wed, 22 Oct 2025 09:15:58 -0300 Subject: [PATCH 1/2] Added actions --- .../actions/get-prices/get-prices.mjs | 42 ++++++ .../get-product-details.mjs | 44 ++++++ .../validate-address/validate-address.mjs | 105 ++++++++++++++ components/finerworks/finerworks.app.mjs | 137 +++++++++++++++++- components/finerworks/package.json | 3 + pnpm-lock.yaml | 33 ++--- 6 files changed, 341 insertions(+), 23 deletions(-) create mode 100644 components/finerworks/actions/get-prices/get-prices.mjs create mode 100644 components/finerworks/actions/get-product-details/get-product-details.mjs create mode 100644 components/finerworks/actions/validate-address/validate-address.mjs diff --git a/components/finerworks/actions/get-prices/get-prices.mjs b/components/finerworks/actions/get-prices/get-prices.mjs new file mode 100644 index 0000000000000..25c195e441ac0 --- /dev/null +++ b/components/finerworks/actions/get-prices/get-prices.mjs @@ -0,0 +1,42 @@ +import app from "../../finerworks.app.mjs"; + +export default { + key: "finerworks-get-prices", + name: "Get Prices", + description: "Get the price of a product. [See the documentation](https://v2.api.finerworks.com/Help/Api/POST-v3-get_prices)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + productSku: { + propDefinition: [ + app, + "productSku", + ], + }, + productQty: { + propDefinition: [ + app, + "productQty", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getPrices({ + $, + data: [ + { + product_qty: this.productQty, + product_sku: this.productSku, + }, + ], + }); + $.export("$summary", "Successfully sent the request"); + return response; + }, +}; diff --git a/components/finerworks/actions/get-product-details/get-product-details.mjs b/components/finerworks/actions/get-product-details/get-product-details.mjs new file mode 100644 index 0000000000000..d00c69a75e791 --- /dev/null +++ b/components/finerworks/actions/get-product-details/get-product-details.mjs @@ -0,0 +1,44 @@ +import app from "../../finerworks.app.mjs"; + +export default { + key: "finerworks-get-product-details", + name: "Get Product Details", + description: "Get details of a product. [See the documentation](https://v2.api.finerworks.com/Help/Api/POST-v3-get_product_details)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + productSku: { + propDefinition: [ + app, + "productSku", + ], + }, + productQty: { + propDefinition: [ + app, + "productQty", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getProductDetails({ + $, + data: { + products: [ + { + product_sku: this.productSku, + product_qty: this.productQty, + }, + ], + }, + }); + $.export("$summary", "Successfully sent the request to get details of the specified product"); + return response; + }, +}; diff --git a/components/finerworks/actions/validate-address/validate-address.mjs b/components/finerworks/actions/validate-address/validate-address.mjs new file mode 100644 index 0000000000000..ff867e378a21b --- /dev/null +++ b/components/finerworks/actions/validate-address/validate-address.mjs @@ -0,0 +1,105 @@ +import app from "../../finerworks.app.mjs"; + +export default { + key: "finerworks-validate-address", + name: "Validate Address", + description: "Validate an address. [See the documentation](https://v2.api.finerworks.com/Help/Api/POST-v3-validate_recipient_address)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + firstName: { + propDefinition: [ + app, + "firstName", + ], + }, + lastName: { + propDefinition: [ + app, + "lastName", + ], + }, + companyName: { + propDefinition: [ + app, + "companyName", + ], + }, + address: { + propDefinition: [ + app, + "address", + ], + }, + city: { + propDefinition: [ + app, + "city", + ], + }, + stateCode: { + propDefinition: [ + app, + "stateCode", + ], + }, + province: { + propDefinition: [ + app, + "province", + ], + }, + zipPostalCode: { + propDefinition: [ + app, + "zipPostalCode", + ], + }, + countryCode: { + propDefinition: [ + app, + "countryCode", + ], + }, + phone: { + propDefinition: [ + app, + "phone", + ], + }, + email: { + propDefinition: [ + app, + "email", + ], + }, + }, + async run({ $ }) { + const response = await this.app.validateAddress({ + $, + data: { + recipient: { + first_name: this.firstName, + last_name: this.lastName, + company_name: this.companyName, + address_1: this.address, + city: this.city, + state_code: this.stateCode, + province: this.province, + zip_postal_code: this.zipPostalCode, + country_code: this.countryCode, + phone: this.phone, + email: this.email, + }, + }, + }); + $.export("$summary", "Successfully sent the request. Validation success: " + response.status.success); + return response; + }, +}; diff --git a/components/finerworks/finerworks.app.mjs b/components/finerworks/finerworks.app.mjs index 18c88ec8e4d8a..50e4f2427e298 100644 --- a/components/finerworks/finerworks.app.mjs +++ b/components/finerworks/finerworks.app.mjs @@ -1,11 +1,140 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "finerworks", - propDefinitions: {}, + propDefinitions: { + firstName: { + type: "string", + label: "First Name", + description: "Recipient first name", + }, + lastName: { + type: "string", + label: "Last Name", + description: "Recipient last name", + }, + companyName: { + type: "string", + label: "Company Name", + description: "Recipient company name", + optional: true, + }, + address: { + type: "string", + label: "Address", + description: "Street address for the recipient", + }, + city: { + type: "string", + label: "City", + description: "Recipient city", + optional: true, + }, + stateCode: { + type: "string", + label: "State Code", + description: "Required if in U.S. A valid USPS recognized 2 digit state code, i.e.: `CA`", + optional: true, + }, + province: { + type: "string", + label: "Province", + description: "Province or region name", + optional: true, + }, + zipPostalCode: { + type: "string", + label: "ZIP or Postal Code", + description: "ZIP or postal code of the recipient", + }, + countryCode: { + type: "string", + label: "Country Code", + description: "Two-letter ISO country code, e.g.: `US`, `CA`, `GB`", + }, + phone: { + type: "string", + label: "Phone", + description: "Recipient phone number", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "Recipient email address", + optional: true, + }, + productQty: { + type: "integer", + label: "Product Quantity", + description: "Quantity of the product", + }, + productSku: { + type: "string", + label: "Product SKU", + description: "SKU identifier of the product", + async options() { + const response = await this.getProducts(); + const products = response.products; + return products.map(({ + sku, name, + }) => ({ + label: name, + value: sku, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://v2.api.finerworks.com/v3"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + "web_api_key": `${this.$auth.web_api_key}`, + "app_key": `${this.$auth.app_key}`, + ...headers, + }, + }); + }, + async validateAddress(args = {}) { + return this._makeRequest({ + path: "/validate_recipient_address", + method: "post", + ...args, + }); + }, + async getPrices(args = {}) { + return this._makeRequest({ + path: "/get_prices", + method: "post", + ...args, + }); + }, + async getProductDetails(args = {}) { + return this._makeRequest({ + path: "/get_product_details", + method: "post", + ...args, + }); + }, + async getProducts(args = {}) { + return this._makeRequest({ + path: "/list_virtual_inventory", + method: "post", + data: {}, + ...args, + }); }, }, }; diff --git a/components/finerworks/package.json b/components/finerworks/package.json index 2a9bd043fa4df..0664696674635 100644 --- a/components/finerworks/package.json +++ b/components/finerworks/package.json @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0dd78eaa20d1a..4680bca45894a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2870,8 +2870,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/cloud_66: - specifiers: {} + components/cloud_66: {} components/cloud_convert: dependencies: @@ -3006,8 +3005,7 @@ importers: components/codeberg: {} - components/codefresh: - specifiers: {} + components/codefresh: {} components/codegpt: {} @@ -3064,8 +3062,7 @@ importers: specifier: ^7.10.6 version: 7.14.0(@aws-sdk/client-sso-oidc@3.696.0(@aws-sdk/client-sts@3.696.0(aws-crt@1.25.0))(aws-crt@1.25.0))(aws-crt@1.25.0) - components/coinapi: - specifiers: {} + components/coinapi: {} components/coinbase: dependencies: @@ -3123,8 +3120,7 @@ importers: specifier: ^0.0.6 version: 0.0.6 - components/cometapi: - specifiers: {} + components/cometapi: {} components/cometly: dependencies: @@ -3310,8 +3306,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/copicake: - specifiers: {} + components/copicake: {} components/copper: dependencies: @@ -3399,11 +3394,9 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/cronly: - specifiers: {} + components/cronly: {} - components/crossmint: - specifiers: {} + components/crossmint: {} components/crove_app: dependencies: @@ -5041,7 +5034,11 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/finerworks: {} + components/finerworks: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/fingertip: {} @@ -10931,8 +10928,7 @@ importers: specifier: ^1.3.0 version: 1.6.6 - components/piwik_pro: - specifiers: {} + components/piwik_pro: {} components/pixelbin: dependencies: @@ -14788,8 +14784,7 @@ importers: specifier: ^0.1.4 version: 0.1.6 - components/topdesk: - specifiers: {} + components/topdesk: {} components/topmessage: dependencies: From 045c9ed2a409b928313ff060929895e8cf6fce1f Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Wed, 22 Oct 2025 09:24:23 -0300 Subject: [PATCH 2/2] Added actions --- components/finerworks/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/finerworks/package.json b/components/finerworks/package.json index 0664696674635..d39de26e61ef5 100644 --- a/components/finerworks/package.json +++ b/components/finerworks/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/finerworks", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream FinerWorks Components", "main": "finerworks.app.mjs", "keywords": [