-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] swell #13415 #16244
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
[Components] swell #13415 #16244
Changes from all 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
56 changes: 56 additions & 0 deletions
56
components/swell/actions/create-account/create-account.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,56 @@ | ||
| import app from "../../swell.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "swell-create-account", | ||
| name: "Create Account", | ||
| description: "Create a new customer account. [See the documentation](https://developers.swell.is/backend-api/accounts/create-an-account)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| email: { | ||
| propDefinition: [ | ||
| app, | ||
| "email", | ||
| ], | ||
| }, | ||
| firstName: { | ||
| propDefinition: [ | ||
| app, | ||
| "firstName", | ||
| ], | ||
| }, | ||
| lastName: { | ||
| propDefinition: [ | ||
| app, | ||
| "lastName", | ||
| ], | ||
| }, | ||
| phone: { | ||
| propDefinition: [ | ||
| app, | ||
| "phone", | ||
| ], | ||
| }, | ||
| notes: { | ||
| propDefinition: [ | ||
| app, | ||
| "notes", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.createAccount({ | ||
| $, | ||
| data: { | ||
| email: this.email, | ||
| first_name: this.firstName, | ||
| last_name: this.lastName, | ||
| phone: this.phone, | ||
| notes: this.notes, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully created account with ID: " + response.id); | ||
| return response; | ||
| }, | ||
| }; |
56 changes: 56 additions & 0 deletions
56
components/swell/actions/create-product/create-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,56 @@ | ||
| import app from "../../swell.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "swell-create-product", | ||
| name: "Create Product", | ||
| description: "Create a new product. [See the documentation](https://developers.swell.is/backend-api/products/create-a-product)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| name: { | ||
| propDefinition: [ | ||
| app, | ||
| "name", | ||
| ], | ||
| }, | ||
| price: { | ||
| propDefinition: [ | ||
| app, | ||
| "price", | ||
| ], | ||
| }, | ||
| active: { | ||
| propDefinition: [ | ||
| app, | ||
| "active", | ||
| ], | ||
| }, | ||
| description: { | ||
| propDefinition: [ | ||
| app, | ||
| "description", | ||
| ], | ||
| }, | ||
| discontinued: { | ||
| propDefinition: [ | ||
| app, | ||
| "discontinued", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.createProduct({ | ||
| $, | ||
| data: { | ||
| name: this.name, | ||
| price: this.price, | ||
| active: this.active, | ||
| description: this.description, | ||
| discontinued: this.discontinued, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully created product with ID: " + response.id); | ||
| return response; | ||
| }, | ||
| }; |
63 changes: 63 additions & 0 deletions
63
components/swell/actions/update-account/update-account.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 app from "../../swell.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "swell-update-account", | ||
| name: "Update Account", | ||
| description: "Update an existing account with the corresponding ID. [See the documentation](https://developers.swell.is/backend-api/accounts/update-an-account)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| email: { | ||
| propDefinition: [ | ||
| app, | ||
| "email", | ||
| ], | ||
| }, | ||
| firstName: { | ||
| propDefinition: [ | ||
| app, | ||
| "firstName", | ||
| ], | ||
| }, | ||
| lastName: { | ||
| propDefinition: [ | ||
| app, | ||
| "lastName", | ||
| ], | ||
| }, | ||
| phone: { | ||
| propDefinition: [ | ||
| app, | ||
| "phone", | ||
| ], | ||
| }, | ||
| notes: { | ||
| propDefinition: [ | ||
| app, | ||
| "notes", | ||
| ], | ||
| }, | ||
| accountId: { | ||
| propDefinition: [ | ||
| app, | ||
| "accountId", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.updateAccount({ | ||
| $, | ||
| accountId: this.accountId, | ||
| data: { | ||
| email: this.email, | ||
| first_name: this.firstName, | ||
| last_name: this.lastName, | ||
| phone: this.phone, | ||
| notes: this.notes, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully updated account with ID: " + this.id); | ||
| 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,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/swell", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Swell Components", | ||
| "main": "swell.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
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,125 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "swell", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| email: { | ||
| type: "string", | ||
| label: "Email", | ||
| description: "The account's email address", | ||
| }, | ||
| firstName: { | ||
| type: "string", | ||
| label: "First Name", | ||
| description: "The account's first name", | ||
| optional: true, | ||
| }, | ||
| lastName: { | ||
| type: "string", | ||
| label: "Last Name", | ||
| description: "The account's last name", | ||
| optional: true, | ||
| }, | ||
| phone: { | ||
| type: "string", | ||
| label: "Phone", | ||
| description: "The account's phone number", | ||
| optional: true, | ||
| }, | ||
| notes: { | ||
| type: "string", | ||
| label: "Notes", | ||
| description: "Additional notes about the account", | ||
| optional: true, | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "The product's full name or display name", | ||
| }, | ||
| price: { | ||
| type: "string", | ||
| label: "Price", | ||
| description: "The price associated with the product", | ||
| optional: true, | ||
| }, | ||
| active: { | ||
| type: "boolean", | ||
| label: "Active", | ||
| description: "Whether the product is active", | ||
| optional: true, | ||
| }, | ||
| description: { | ||
| type: "string", | ||
| label: "Description", | ||
| description: "A description of the product", | ||
| optional: true, | ||
| }, | ||
| discontinued: { | ||
| type: "boolean", | ||
| label: "Discontinued", | ||
| description: "Whether the product is discontinued", | ||
| optional: true, | ||
| }, | ||
| accountId: { | ||
| type: "string", | ||
| label: "Account ID", | ||
| description: "ID of the account that will be updated", | ||
| async options() { | ||
| const { results } = await this.getAccounts(); | ||
| return results.map(({ | ||
| email, id, | ||
| }) => ({ | ||
| label: email, | ||
| value: id, | ||
| })); | ||
| }, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return `https://${this.$auth.store_id}:${this.$auth.secret_key}@api.swell.store`; | ||
| }, | ||
| async _makeRequest(opts = {}) { | ||
| const { | ||
| $ = this, | ||
| path, | ||
| ...otherOpts | ||
| } = opts; | ||
| return axios($, { | ||
| ...otherOpts, | ||
| url: this._baseUrl() + path, | ||
| }); | ||
| }, | ||
| async createAccount(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/accounts", | ||
| method: "post", | ||
| ...args, | ||
| }); | ||
| }, | ||
| async createProduct(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/products", | ||
| method: "post", | ||
| ...args, | ||
| }); | ||
| }, | ||
| async updateAccount({ | ||
| accountId, ...args | ||
| }) { | ||
| return this._makeRequest({ | ||
| path: `/accounts/${accountId}`, | ||
| method: "put", | ||
| ...args, | ||
| }); | ||
| }, | ||
| async getAccounts(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/accounts", | ||
| ...args, | ||
| }); | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
| }; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.