-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] paddle #10926 #18510
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
Open
lcaresia
wants to merge
5
commits into
master
Choose a base branch
from
issue-10926
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Components] paddle #10926 #18510
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
47 changes: 47 additions & 0 deletions
47
components/paddle/actions/create-customer/create-customer.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,47 @@ | ||
import app from "../../paddle.app.mjs"; | ||
|
||
export default { | ||
key: "paddle-create-customer", | ||
name: "Create Customer", | ||
description: "Create a new customer in Paddle. [See the documentation](https://developer.paddle.com/api-reference/customers/create-customer)", | ||
version: "0.0.1", | ||
annotations: { | ||
openWorldHint: true, | ||
destructiveHint: false, | ||
readOnlyHint: false, | ||
}, | ||
type: "action", | ||
props: { | ||
app, | ||
email: { | ||
propDefinition: [ | ||
app, | ||
"email", | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
app, | ||
"name", | ||
], | ||
}, | ||
customData: { | ||
propDefinition: [ | ||
app, | ||
"customData", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.createCustomer({ | ||
$, | ||
data: { | ||
email: this.email, | ||
name: this.name, | ||
custom_data: this.customData, | ||
}, | ||
}); | ||
$.export("$summary", "Successfully created a new customer with the ID: " + response.data.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import app from "../../paddle.app.mjs"; | ||
|
||
export default { | ||
key: "paddle-get-customers", | ||
name: "Get Customers", | ||
description: "Get a list of customers registered in Paddle. [See the documentation](https://developer.paddle.com/api-reference/customers/list-customers)", | ||
version: "0.0.1", | ||
annotations: { | ||
openWorldHint: true, | ||
destructiveHint: false, | ||
readOnlyHint: true, | ||
}, | ||
type: "action", | ||
props: { | ||
app, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.getCustomers({ | ||
$, | ||
}); | ||
$.export("$summary", "Successfully retrieved " + response.data.length + " customers"); | ||
return response; | ||
}, | ||
}; |
61 changes: 61 additions & 0 deletions
61
components/paddle/actions/update-customer/update-customer.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,61 @@ | ||
import app from "../../paddle.app.mjs"; | ||
|
||
export default { | ||
key: "paddle-update-customer", | ||
name: "Update Customer", | ||
description: "Update the customer with the specified ID. [See the documentation](https://developer.paddle.com/api-reference/customers/update-customer)", | ||
version: "0.0.1", | ||
annotations: { | ||
openWorldHint: true, | ||
destructiveHint: true, | ||
readOnlyHint: false, | ||
}, | ||
type: "action", | ||
props: { | ||
app, | ||
customerId: { | ||
propDefinition: [ | ||
app, | ||
"customerId", | ||
], | ||
}, | ||
email: { | ||
propDefinition: [ | ||
app, | ||
"email", | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
app, | ||
"name", | ||
], | ||
}, | ||
customData: { | ||
propDefinition: [ | ||
app, | ||
"customData", | ||
], | ||
}, | ||
status: { | ||
propDefinition: [ | ||
app, | ||
"status", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.updateCustomer({ | ||
$, | ||
customerId: this.customerId, | ||
data: { | ||
email: this.email, | ||
name: this.name, | ||
custom_data: this.customData, | ||
status: this.status, | ||
}, | ||
}); | ||
$.export("$summary", "Successfully updated the customer with ID: " + this.customerId); | ||
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
STATUS_OPTIONS: [ | ||
"active", | ||
"archived", | ||
], | ||
}; |
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/paddle", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream Paddle Components", | ||
"main": "paddle.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.1.0" | ||
} | ||
} |
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,92 @@ | ||
import { axios } from "@pipedream/platform"; | ||
import constants from "./common/constants.mjs"; | ||
|
||
export default { | ||
type: "app", | ||
app: "paddle", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
email: { | ||
type: "string", | ||
label: "Email", | ||
description: "Customer's email address", | ||
}, | ||
name: { | ||
type: "string", | ||
label: "Name", | ||
description: "Customer's full name", | ||
}, | ||
customData: { | ||
type: "object", | ||
label: "Custom Data", | ||
description: "Your own structured key-value data", | ||
optional: true, | ||
}, | ||
status: { | ||
type: "string", | ||
label: "Status", | ||
description: "Customer's status", | ||
options: constants.STATUS_OPTIONS, | ||
}, | ||
customerId: { | ||
type: "string", | ||
label: "Customer ID", | ||
description: "Unique identifier of the customer", | ||
async options() { | ||
const response = await this.getCustomers(); | ||
const data = response.data; | ||
return data.map(({ | ||
id, name, | ||
}) => ({ | ||
value: id, | ||
label: name, | ||
})); | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
_baseUrl() { | ||
return "https://api.paddle.com"; | ||
}, | ||
async _makeRequest(opts = {}) { | ||
const { | ||
$ = this, | ||
path, | ||
headers, | ||
...otherOpts | ||
} = opts; | ||
return axios($, { | ||
...otherOpts, | ||
url: this._baseUrl() + path, | ||
headers: { | ||
Authorization: `Bearer ${this.$auth.auth_code}`, | ||
...headers, | ||
}, | ||
}); | ||
}, | ||
|
||
async getCustomers(args = {}) { | ||
return this._makeRequest({ | ||
path: "/customers", | ||
...args, | ||
}); | ||
}, | ||
|
||
async createCustomer(args = {}) { | ||
return this._makeRequest({ | ||
path: "/customers", | ||
method: "post", | ||
...args, | ||
}); | ||
}, | ||
|
||
async updateCustomer({ | ||
customerId, ...args | ||
}) { | ||
return this._makeRequest({ | ||
path: `/customers/${customerId}`, | ||
method: "patch", | ||
...args, | ||
}); | ||
}, | ||
GTFalcao 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.