-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] finerworks #10976 #18830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
08b3ac4
Added actions
lcaresia 045c9ed
Added actions
lcaresia ca7b96b
Added actions
lcaresia 24f7e5c
Added actions
lcaresia 4bf481a
merge
lcaresia 7dd11b2
Update components/finerworks/actions/get-product-details/get-product-…
GTFalcao 927c805
Update components/finerworks/actions/validate-address/validate-addres…
GTFalcao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| 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: { | ||
| products: [ | ||
| { | ||
| product_qty: this.productQty, | ||
| product_sku: this.productSku, | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
| $.export("$summary", `Successfully retrieved ${response.prices.length} ${response.prices.length > 1 | ||
| ? "prices" | ||
| : "price"} for product SKU ${this.productSku}`); | ||
| return response; | ||
| }, | ||
| }; | ||
44 changes: 44 additions & 0 deletions
44
components/finerworks/actions/get-product-details/get-product-details.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 retrieved details for product SKU ${this.productSku}`); | ||
| return response; | ||
| }, | ||
| }; |
105 changes: 105 additions & 0 deletions
105
components/finerworks/actions/validate-address/validate-address.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 validated the address: " + response.status.success); | ||
| return response; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,149 @@ | ||
| 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; | ||
| console.log({ | ||
| ...otherOpts, | ||
| url: this._baseUrl() + path, | ||
| headers: { | ||
| "web_api_key": `${this.$auth.web_api_key}`, | ||
| "app_key": `${this.$auth.app_key}`, | ||
| ...headers, | ||
| }, | ||
| }); | ||
| 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, | ||
| }); | ||
| }, | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
🧩 Analysis chain
Simplify summary and verify response structure.
The inline ternary for pluralization reduces readability. Consider simplifying or extracting to a helper. Additionally, verify that the API response structure includes
response.pricesas an array, since this code assumes that structure without validation.Apply this diff to simplify:
Run the following script to verify the response structure from the API:
🏁 Script executed:
Length of output: 0
Length of output: 57
🏁 Script executed:
Length of output: 197
🏁 Script executed:
Length of output: 0
Length of output: 1046
Length of output: 3543
Simplify summary and add defensive response handling.
The inline ternary for pluralization reduces readability. Additionally, the code directly accesses
response.prices.lengthwithout validating the response structure, which could fail if the API returns an unexpected format.Consider extracting the pluralization logic and using optional chaining for defensive programming:
🤖 Prompt for AI Agents