Skip to content

Commit 9a70095

Browse files
committed
Create Customer action
1 parent fddf3fa commit 9a70095

File tree

3 files changed

+73
-2
lines changed

3 files changed

+73
-2
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import chargebee from "../../chargebee.app.mjs";
2+
3+
export default {
4+
key: "chargebee-create-customer",
5+
name: "Create Customer",
6+
description: "Create a customer in Chargebee. [See the documentation](https://apidocs.chargebee.com/docs/api/customers?lang=node-v3#create_a_customer)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
chargebee,
11+
id: {
12+
type: "string",
13+
label: "ID",
14+
description: "ID for the new customer. If not given, this will be auto-generated.",
15+
optional: true,
16+
},
17+
firstName: {
18+
type: "string",
19+
label: "First Name",
20+
description: "First name of the customer.",
21+
optional: true,
22+
},
23+
lastName: {
24+
type: "string",
25+
label: "Last Name",
26+
description: "Last name of the customer.",
27+
optional: true,
28+
},
29+
email: {
30+
type: "string",
31+
label: "Email",
32+
description: "Email of the customer.",
33+
optional: true,
34+
},
35+
phone: {
36+
type: "string",
37+
label: "Phone",
38+
description: "Phone number of the customer.",
39+
optional: true,
40+
},
41+
company: {
42+
type: "string",
43+
label: "Company",
44+
description: "Company name of the customer.",
45+
optional: true,
46+
},
47+
additionalFields: {
48+
type: "object",
49+
label: "Additional Fields",
50+
description: "Additional fields and values to set for the customer. [See the documentation](https://apidocs.chargebee.com/docs/api/customers?lang=curl#create_a_customer) for all available fields.",
51+
optional: true,
52+
},
53+
},
54+
async run({ $ }) {
55+
const response = await this.chargebee.createCustomer(Object.fromEntries(Object.entries({
56+
id: this.id,
57+
first_name: this.firstName,
58+
last_name: this.lastName,
59+
email: this.email,
60+
phone: this.phone,
61+
company: this.company,
62+
...this.additionalFields,
63+
}).filter(([_, v]) => v !== undefined)));
64+
65+
$.export("$summary", `Successfully created customer (ID: ${response?.customer?.id})`);
66+
return response;
67+
},
68+
};

components/chargebee/chargebee.app.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,8 @@ export default {
2929
getEvents(args = {}) {
3030
return this.instance().event.list(args).request();
3131
},
32+
createCustomer(args = {}) {
33+
return this.instance().customer.create(args).request();
34+
}
3235
},
3336
};

components/chargebee/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/chargebee",
3-
"version": "0.0.2",
3+
"version": "0.1.0",
44
"description": "Pipedream Chargebee Components",
55
"main": "chargebee.app.mjs",
66
"keywords": [
@@ -11,7 +11,7 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"license": "MIT",
1313
"dependencies": {
14-
"@pipedream/platform": "^1.4.1",
14+
"@pipedream/platform": "^3.0.3",
1515
"chargebee": "^2.22.3"
1616
},
1717
"publishConfig": {

0 commit comments

Comments
 (0)