-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - printful #15436
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
New Components - printful #15436
Changes from 3 commits
Commits
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
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
components/printful/actions/calculate-shipping-rates/calculate-shipping-rates.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,90 @@ | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import printful from "../../printful.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "printful-calculate-shipping-rates", | ||
| name: "Calculate Shipping Rates", | ||
| description: "Fetches available shipping rates for a given destination. [See the documentation](https://developers.printful.com/docs/#tag/Shipping-Rate-API/operation/calculateShippingRates)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| printful, | ||
| storeId: { | ||
| propDefinition: [ | ||
| printful, | ||
| "storeId", | ||
| ], | ||
| }, | ||
| address1: { | ||
| label: "Address 1", | ||
| description: "The address 1", | ||
| type: "string", | ||
| }, | ||
| city: { | ||
| label: "City", | ||
| description: "The city", | ||
| type: "string", | ||
| }, | ||
| stateCode: { | ||
| label: "State Code", | ||
| description: "The state code. E.g. `SC`", | ||
| type: "string", | ||
| }, | ||
| countryCode: { | ||
| label: "Country Code", | ||
| description: "The country code. E.g. `BR`", | ||
| type: "string", | ||
| }, | ||
| zip: { | ||
| label: "ZIP/Postal Code", | ||
| description: "The ZIP/postal code. E.g. `89221525`", | ||
| type: "string", | ||
| }, | ||
| phone: { | ||
| label: "Phone", | ||
| description: "The phone number", | ||
| type: "string", | ||
| optional: true, | ||
| }, | ||
| items: { | ||
| type: "string[]", | ||
| label: "Items", | ||
| description: "A list of items in JSON format. **Example: [{\"variant_id\": \"123456\", \"external_variant_id\": \"123456\", \"quantity\": 123, \"value\": \"12345\" }]**", | ||
| }, | ||
| currency: { | ||
| type: "string", | ||
| label: "Currency", | ||
| description: "3 letter currency code (optional), required if the rates need to be converted to another currency instead of store default currency", | ||
| optional: true, | ||
| }, | ||
| locale: { | ||
| type: "string", | ||
| label: "Locale", | ||
| description: "Locale in which shipping rate names will be returned. Available options: `en_US` (default), `es_ES`", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const shippingRates = await this.printful.fetchShippingRates({ | ||
| $, | ||
| headers: { | ||
| "X-PF-Store-Id": this.storeId, | ||
| }, | ||
| data: { | ||
| recipient: { | ||
| address1: this.address1, | ||
| city: this.city, | ||
| state_code: this.stateCode, | ||
| country_code: this.countryCode, | ||
| zip: this.zip, | ||
| phone: this.phone, | ||
| }, | ||
| items: parseObject(this.items), | ||
| currency: this.currency, | ||
| locale: this.locale, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Fetched shipping rates successfully"); | ||
| return shippingRates; | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
144 changes: 144 additions & 0 deletions
144
components/printful/actions/create-order/create-order.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,144 @@ | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import printful from "../../printful.app.mjs"; | ||
|
|
||
| export default { | ||
| name: "Create Order", | ||
| version: "0.0.1", | ||
| key: "printful-create-order", | ||
| description: "Creates a new order in your Printful account. [See docs here](https://developers.printful.com/docs/#operation/createOrder)", | ||
luancazarine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| type: "action", | ||
| props: { | ||
| printful, | ||
| storeId: { | ||
| propDefinition: [ | ||
| printful, | ||
| "storeId", | ||
| ], | ||
| }, | ||
| externalId: { | ||
| label: "External ID", | ||
| description: "Order ID from the external system", | ||
| type: "string", | ||
| optional: true, | ||
| }, | ||
| recipientName: { | ||
| label: "Recipient Name", | ||
| description: "The recipient full name", | ||
| type: "string", | ||
| }, | ||
| recipientCompanyName: { | ||
| label: "Recipient Company Name", | ||
| description: "The recipient company name", | ||
| type: "string", | ||
| optional: true, | ||
| }, | ||
| address1: { | ||
| label: "Address 1", | ||
| description: "The address 1", | ||
| type: "string", | ||
| }, | ||
| address2: { | ||
| label: "Address 2", | ||
| description: "The address 2", | ||
| type: "string", | ||
| optional: true, | ||
| }, | ||
| city: { | ||
| label: "City", | ||
| description: "The city", | ||
| type: "string", | ||
| }, | ||
| stateCode: { | ||
| label: "State Code", | ||
| description: "The state code. E.g. `SC`", | ||
| type: "string", | ||
| }, | ||
| countryCode: { | ||
| label: "Country Code", | ||
| description: "The country code. E.g. `BR`", | ||
| type: "string", | ||
| reloadProps: true, | ||
| }, | ||
| taxNumber: { | ||
| label: "Tax Number", | ||
| description: "TAX number (`optional`, but in case of Brazil country this field becomes `required` and will be used as CPF/CNPJ number)", | ||
| type: "string", | ||
| optional: true, | ||
| }, | ||
| zip: { | ||
| label: "ZIP/Postal Code", | ||
| description: "The ZIP/postal code. E.g. `89221525`", | ||
| type: "string", | ||
| reloadProps: true, | ||
| }, | ||
| phone: { | ||
| label: "Phone", | ||
| description: "The phone number", | ||
| type: "string", | ||
| optional: true, | ||
| }, | ||
| email: { | ||
| label: "Email", | ||
| description: "The email", | ||
| type: "string", | ||
| optional: true, | ||
| }, | ||
| giftSubject: { | ||
| label: "Gift Subject", | ||
| description: "Gift message title", | ||
| type: "string", | ||
| optional: true, | ||
| }, | ||
| giftMessage: { | ||
| label: "Gift Message", | ||
| description: "Gift message text", | ||
| type: "string", | ||
| optional: true, | ||
| }, | ||
| items: { | ||
| label: "Items", | ||
| description: "Array of items in the order. E.g. `[ { \"id\": 1, \"variant_id\": 2, \"quantity\": 3, \"price\": \"13.60\", \"retail_price\": \"9.90\", \"name\": \"Beauty Poster\", \"product\": { \"product_id\": 301, \"variant_id\": 500, \"name\": \"Red T-Shirt\" }, \"files\": [{\"url\": \"https://file.com/060b204a37f.png\"}] } ]`", | ||
| type: "string", | ||
luancazarine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| additionalProps(props) { | ||
| props.taxNumber.optional = this.countryCode != "BR"; | ||
| return {}; | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.printful.createOrder({ | ||
| $, | ||
| headers: { | ||
| "X-PF-Store-Id": this.storeId, | ||
| }, | ||
| data: { | ||
| external_id: this.externalId, | ||
| shipping: "STANDARD", | ||
| recipient: { | ||
| name: this.recipientName, | ||
| company: this.recipientCompanyName, | ||
| address1: this.address1, | ||
| address2: this.address2, | ||
| city: this.city, | ||
| state_code: this.stateCode, | ||
| country_code: this.countryCode, | ||
| zip: this.zip, | ||
| phone: this.phone, | ||
| email: this.email, | ||
| tax_number: this.taxNumber, | ||
| }, | ||
| gift: { | ||
| subject: this.giftSubject, | ||
| message: this.giftMessage, | ||
| }, | ||
| items: parseObject(this.items), | ||
| }, | ||
| }); | ||
|
|
||
| if (response) { | ||
| $.export("$summary", `Successfully created order with id ${response.result.id}`); | ||
| } | ||
|
|
||
| return response; | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
63 changes: 63 additions & 0 deletions
63
components/printful/actions/update-product/update-product.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,63 @@ | ||
| import { parseObject } from "../../common/utils.mjs"; | ||
| import printful from "../../printful.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "printful-update-product", | ||
| name: "Update Product", | ||
| description: "Updates an existing product in your Printful store. [See the documentation](https://developers.printful.com/docs/#tag/Products-API/operation/updateSyncProduct)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| printful, | ||
| storeId: { | ||
| propDefinition: [ | ||
| printful, | ||
| "storeId", | ||
| ], | ||
| }, | ||
| productId: { | ||
| propDefinition: [ | ||
| printful, | ||
| "productId", | ||
| ({ storeId }) => ({ | ||
| storeId, | ||
| }), | ||
| ], | ||
| }, | ||
| alert: { | ||
|
Check warning on line 27 in components/printful/actions/update-product/update-product.mjs
|
||
| type: "alert", | ||
| alertType: "warning", | ||
| content: `Please note that in the request body you only need to specify the fields that need to be changed. | ||
| \nFurthermore, if you want to update existing sync variants, then in the sync variants array you must specify the IDs of all existing sync variants. | ||
| \nAll omitted existing sync variants will be deleted. All new sync variants without an ID will be created.`, | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| syncProduct: { | ||
| type: "object", | ||
| label: "Sync Product", | ||
| description: "Information about the SyncProduct. **Example: {\"external_id\": \"4235234213\", \"name\": \"T-shirt\", \"thumbnail\": \"http://your-domain.com/path/to/thumbnail.png\", \"is_ignored\": true}**", | ||
| optional: true, | ||
| }, | ||
| syncVariants: { | ||
| type: "string[]", | ||
| label: "Sync Variants", | ||
| description: "Information about the Sync Variants. **Example: [{\"external_id\": \"12312414\", \"variant_id\": 3001, \"retail_price\": \"29.99\", \"is_ignored\": true, \"sku\": \"SKU1234\", \"files\": [{ \"type\": \"default\", \"url\": \"https://www.example.com/files/tshirts/example.png\", \"options\": [{ \"id\": \"template_type\", \"value\": \"native\" }], \"filename\": \"shirt1.png\", \"visible\": true }], \"options\": [{ \"id\": \"embroidery_type\", \"value\": \"flat\" }], \"availability_status\": \"active\" }]**", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
|
|
||
| const response = await this.printful.updateProduct({ | ||
| $, | ||
| headers: { | ||
| "X-PF-Store-Id": this.storeId, | ||
| }, | ||
| productId: this.productId, | ||
| data: { | ||
| sync_product: parseObject(this.syncProduct), | ||
| sync_variants: parseObject(this.syncVariants), | ||
| }, | ||
| }); | ||
| $.export("$summary", `Updated product ${this.productId}`); | ||
| return response; | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
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 @@ | ||
| export const LIMIT = 100; |
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,24 @@ | ||
| export const parseObject = (obj) => { | ||
| if (!obj) return undefined; | ||
|
|
||
| if (Array.isArray(obj)) { | ||
| return obj.map((item) => { | ||
| if (typeof item === "string") { | ||
| try { | ||
| return JSON.parse(item); | ||
| } catch (e) { | ||
| return item; | ||
| } | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| if (typeof obj === "string") { | ||
| try { | ||
| return JSON.parse(obj); | ||
| } catch (e) { | ||
| return obj; | ||
| } | ||
| } | ||
| return obj; | ||
| }; |
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,18 @@ | ||
| { | ||
| "name": "@pipedream/printful", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Printful Components", | ||
| "main": "printful.app.mjs", | ||
| "keywords": [ | ||
| "pipedream", | ||
| "printful" | ||
| ], | ||
| "homepage": "https://pipedream.com/apps/printful", | ||
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.