Skip to content

Commit 4d596e3

Browse files
committed
new components
1 parent 12d6e2d commit 4d596e3

File tree

15 files changed

+680
-279
lines changed

15 files changed

+680
-279
lines changed

components/chargify/actions/create-customer/create-customer.mjs

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,102 @@ import chargify from "../../chargify.app.mjs";
33
export default {
44
key: "chargify-create-customer",
55
name: "Create Customer",
6-
description: "Creates a new customer in Chargify",
7-
version: "0.0.{{ts}}",
6+
description: "Creates a new customer in Chargify. [See the documentation](https://developers.maxio.com/http/advanced-billing-api/api-endpoints/customers/create-customer)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
chargify,
11-
name: {
11+
firstName: {
1212
type: "string",
13-
label: "Name",
14-
description: "The name of the customer",
13+
label: "First Name",
14+
description: "The first name of the customer",
15+
},
16+
lastName: {
17+
type: "string",
18+
label: "Last Name",
19+
description: "The last name of the customer",
1520
},
1621
email: {
1722
type: "string",
1823
label: "Email",
1924
description: "The email of the customer",
20-
optional: true,
2125
},
2226
organization: {
2327
type: "string",
2428
label: "Organization",
2529
description: "The organization of the customer",
2630
optional: true,
2731
},
32+
address: {
33+
type: "string",
34+
label: "Street Address",
35+
description: "Street address of the customer (line 1)",
36+
optional: true,
37+
},
38+
address2: {
39+
type: "string",
40+
label: "Street Address (line 2)",
41+
description: "Street address of the customer (line 2)",
42+
optional: true,
43+
},
44+
city: {
45+
type: "string",
46+
label: "City",
47+
description: "City of the customer",
48+
optional: true,
49+
},
50+
state: {
51+
type: "string",
52+
label: "State",
53+
description: "State/Region of the customer",
54+
optional: true,
55+
},
56+
zip: {
57+
type: "string",
58+
label: "Zip",
59+
description: "Zip code of the customer",
60+
optional: true,
61+
},
62+
country: {
63+
type: "string",
64+
label: "Country",
65+
description: "The country code of the customer. Example: `US`",
66+
optional: true,
67+
},
68+
phone: {
69+
type: "string",
70+
label: "Phone",
71+
description: "Phone number of the customer",
72+
optional: true,
73+
},
74+
taxExempt: {
75+
type: "boolean",
76+
label: "Tax Exempt",
77+
description: "Set to `true` if the customer is tax exempt.",
78+
optional: true,
79+
},
2880
},
2981
async run({ $ }) {
30-
const response = await this.chargify.createCustomer({
82+
const { customer } = await this.chargify.createCustomer({
83+
$,
3184
data: {
3285
customer: {
33-
first_name: this.name,
86+
first_name: this.firstName,
87+
last_name: this.lastName,
3488
email: this.email,
3589
organization: this.organization,
90+
address: this.address,
91+
address_2: this.address2,
92+
city: this.city,
93+
state: this.state,
94+
zip: this.zip,
95+
country: this.country,
96+
phone: this.phone,
97+
tax_exempt: this.taxExempt,
3698
},
3799
},
38100
});
39-
$.export("$summary", `Successfully created customer ${this.name}`);
40-
return response;
101+
$.export("$summary", `Successfully created customer with ID ${customer.id}`);
102+
return customer;
41103
},
42-
};
104+
};
Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,58 @@
1-
js
21
import chargify from "../../chargify.app.mjs";
32

43
export default {
54
key: "chargify-create-subscription",
65
name: "Create Subscription",
7-
description: "Establishes a new subscription for a given customer in Chargify",
8-
version: "0.0.{{ts}}",
6+
description: "Establishes a new subscription for a given customer in Chargify. [See the documentation](https://developers.maxio.com/http/advanced-billing-api/api-endpoints/subscriptions/create-subscription)",
7+
version: "0.0.1",
98
type: "action",
109
props: {
1110
chargify,
1211
customerId: {
1312
propDefinition: [
1413
chargify,
15-
"customerId"
16-
]
14+
"customerId",
15+
],
1716
},
1817
productId: {
1918
propDefinition: [
2019
chargify,
21-
"productId"
22-
]
20+
"productId",
21+
],
2322
},
2423
couponCode: {
2524
propDefinition: [
2625
chargify,
27-
"couponCode"
26+
"couponCode",
2827
],
29-
optional: true
3028
},
3129
nextBillingAt: {
3230
propDefinition: [
3331
chargify,
34-
"nextBillingAt"
32+
"nextBillingAt",
33+
],
34+
},
35+
paymentCollectionMethod: {
36+
propDefinition: [
37+
chargify,
38+
"paymentCollectionMethod",
3539
],
36-
optional: true
3740
},
3841
},
3942
async run({ $ }) {
4043
const response = await this.chargify.createSubscription({
44+
$,
4145
data: {
4246
subscription: {
4347
customer_id: this.customerId,
4448
product_id: this.productId,
4549
coupon_code: this.couponCode,
46-
next_billing_at: this.nextBillingAt
47-
}
48-
}
50+
next_billing_at: this.nextBillingAt,
51+
payment_collection_method: this.paymentCollectionMethod,
52+
},
53+
},
4954
});
5055
$.export("$summary", `Successfully created subscription with ID: ${response.id}`);
5156
return response;
5257
},
53-
};
58+
};

components/chargify/actions/update-subscription/update-subscription.mjs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import chargify from "../../chargify.app.mjs";
33
export default {
44
key: "chargify-update-subscription",
55
name: "Update Subscription",
6-
description: "Modifies an existing subscription in Chargify using its unique 'subscription_id'.",
7-
version: "0.0.{{ts}}",
6+
description: "Modifies an existing subscription in Chargify. [See the documentation](https://developers.maxio.com/http/advanced-billing-api/api-endpoints/subscriptions/update-subscription)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
chargify,
@@ -19,32 +19,41 @@ export default {
1919
chargify,
2020
"productId",
2121
],
22+
optional: true,
23+
},
24+
couponCode: {
25+
propDefinition: [
26+
chargify,
27+
"couponCode",
28+
],
2229
},
2330
nextBillingAt: {
2431
propDefinition: [
2532
chargify,
2633
"nextBillingAt",
2734
],
2835
},
29-
couponCode: {
36+
paymentCollectionMethod: {
3037
propDefinition: [
3138
chargify,
32-
"couponCode",
39+
"paymentCollectionMethod",
3340
],
3441
},
3542
},
3643
async run({ $ }) {
3744
const response = await this.chargify.updateSubscription({
45+
$,
3846
subscriptionId: this.subscriptionId,
3947
data: {
4048
subscription: {
4149
product_id: this.productId,
42-
next_billing_at: this.nextBillingAt,
4350
coupon_code: this.couponCode,
51+
next_billing_at: this.nextBillingAt,
52+
payment_collection_method: this.paymentCollectionMethod,
4453
},
4554
},
4655
});
4756
$.export("$summary", `Successfully updated subscription ${this.subscriptionId}`);
4857
return response;
4958
},
50-
};
59+
};

0 commit comments

Comments
 (0)