Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import app from "../../crowdpower.app.mjs";

export default {
key: "crowdpower-create-customer-charge",
name: "Create Customer Charge",
description: "Create a charge for a user. [See the documentation](https://documenter.getpostman.com/view/17896162/UV5TFKbh#d89820d6-5d65-4ff7-87ba-6cddb359d8f3)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
type: "action",
props: {
app,
userId: {
propDefinition: [
app,
"userId",
],
},
amount: {
propDefinition: [
app,
"amount",
],
},
},
async run({ $ }) {
const response = await this.app.createCustomerCharge({
$,
data: {
user_id: this.userId,
amount: this.amount,
},
});

$.export("$summary", response.success
? `Request succeeded with code ${response.code}`
: `Request failed with code ${response.code}`);

Check failure on line 41 in components/crowdpower/actions/create-customer-charge/create-customer-charge.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Trailing spaces not allowed
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import app from "../../crowdpower.app.mjs";

export default {
key: "crowdpower-create-customer-event",
name: "Create Customer Event",
description: "Create a new event related to a customer. [See the documentation](https://documenter.getpostman.com/view/17896162/UV5TFKbh#63159fcd-7df3-46c5-ac83-eeb72678b650)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
type: "action",
props: {
app,
userId: {
propDefinition: [
app,
"userId",
],
},
customAttributes: {
propDefinition: [
app,
"customAttributes",
],
description: "Custom attributes of the event",
},
action: {
propDefinition: [
app,
"action",
],
},
},
async run({ $ }) {
const response = await this.app.createCustomerEvent({
$,
data: {
user_id: this.userId,
custom_attributes: this.customAttributes,
action: this.action,
Comment on lines +40 to +42
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs show this endpoint accepting properties user_id, action, and properties. Are you sure custom_attributes is correct?

If correct, add an example to the description of prop customAttributes.
If not, add prop properties with an example in the prop description.

},
});
$.export("$summary", response.success
? `Request succeeded with code ${response.code}`
: `Request failed with code ${response.code}`);
return response;
},
};
57 changes: 57 additions & 0 deletions components/crowdpower/actions/upsert-customer/upsert-customer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import app from "../../crowdpower.app.mjs";

export default {
key: "crowdpower-upsert-customer",
name: "Upsert Customer",
description: "Create or update a customer. [See the documentation](https://documenter.getpostman.com/view/17896162/UV5TFKbh#9415bd14-59ab-47b1-b0ec-73826d9cb5db)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
type: "action",
props: {
app,
userId: {
propDefinition: [
app,
"userId",
],
description: "ID of the customer that will be created or updated",
},
email: {
propDefinition: [
app,
"email",
],
},
name: {
propDefinition: [
app,
"name",
],
},
customAttributes: {
propDefinition: [
app,
"customAttributes",
],
},
Comment on lines +35 to +40
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should include an example of valid input in the prop description.

},
async run({ $ }) {
const response = await this.app.upsertCustomer({
$,
data: {
user_id: this.userId,
email: this.email,
name: this.name,
custom_attributes: this.customAttributes,
},
});
$.export("$summary", response.success
? `Request succeeded with code ${response.code}`
: `Request failed with code ${response.code}`);
return response;
},
};
77 changes: 73 additions & 4 deletions components/crowdpower/crowdpower.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,80 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "crowdpower",
propDefinitions: {},
propDefinitions: {
userId: {
type: "string",
label: "User ID",
description: "ID of the user",
},
Comment on lines +7 to +11
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the get customers endpoint to list the ids?

amount: {
type: "string",
label: "Amount",
description: "Amount of the charge",
},
email: {
type: "string",
label: "Email",
description: "Email of the customer",
},
name: {
type: "string",
label: "Name",
description: "Name of the customer",
},
customAttributes: {
type: "object",
label: "Custom Attributes",
description: "Custom attributes",
},
action: {
type: "string",
label: "Action",
description: "Action related to the event",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://beacon.crowdpower.io";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
"Authorization": `Bearer ${this.$auth.application_key}`,
...headers,
},
});
},
async createCustomerCharge(args = {}) {
return this._makeRequest({
path: "/charges",
method: "post",
...args,
});
},
async upsertCustomer(args = {}) {
return this._makeRequest({
path: "/customers",
method: "post",
...args,
});
},
async createCustomerEvent(args = {}) {
return this._makeRequest({
path: "/events",
method: "post",
...args,
});
},
},
};
5 changes: 4 additions & 1 deletion components/crowdpower/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/crowdpower",
"version": "0.0.4",
"version": "0.1.0",
"description": "Pipedream CrowdPower Components",
"main": "crowdpower.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.1"
}
}
13 changes: 8 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading