Skip to content

Commit 6f0a79b

Browse files
committed
Adding and adjusting several props
1 parent ade3114 commit 6f0a79b

File tree

3 files changed

+78
-19
lines changed

3 files changed

+78
-19
lines changed

components/tremendous/actions/create-order-email-reward/create-order-email-reward.mjs

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import app from "../../tremendous.app.mjs";
2-
import { FUNDING_SOURCE_OPTIONS } from "../../common/constants.mjs";
2+
import { DELIVERY_METHOD_OPTIONS } from "../../common/constants.mjs";
33

44
export default {
55
name: "Create Order Email Reward",
@@ -28,31 +28,74 @@ export default {
2828
alertType: "info",
2929
content: "Either `Products` or `Campaign ID` must be specified. [See the documentation](https://developers.tremendous.com/reference/create-order) for more information.",
3030
},
31+
fundingSourceId: {
32+
propDefinition: [
33+
app,
34+
"fundingSourceId",
35+
],
36+
default: "balance",
37+
},
3138
externalId: {
3239
type: "string",
3340
label: "External ID",
3441
description: "Reference for this order. If set, any subsequent requests with the same `External ID` will not create any further orders, and simply return the initially created order.",
3542
optional: true,
3643
},
37-
fundingSourceId: {
44+
valueAmount: {
3845
type: "string",
39-
label: "Funding Source",
40-
description: "Tremendous ID of the funding source that will be used to pay for the order.",
41-
options: FUNDING_SOURCE_OPTIONS,
42-
optional: true,
46+
label: "Value Amount",
47+
description: "Amount of the reward.",
48+
},
49+
valueCurrencyCode: {
50+
type: "string",
51+
label: "Value Currency Code",
52+
description: "Currency of the reward.",
53+
},
54+
recipientName: {
55+
type: "string",
56+
label: "Recipient Name",
57+
description: "Name of the recipient.",
58+
},
59+
recipientEmail: {
60+
type: "string",
61+
label: "Recipient Email",
62+
description: "Email address of the recipient.",
63+
},
64+
recipientPhone: {
65+
type: "string",
66+
label: "Recipient Phone",
67+
description: "Phone number of the recipient. For non-US phone numbers, specify the country code (prefixed with `+`).",
68+
},
69+
deliveryMethod: {
70+
type: "string",
71+
label: "Delivery Method",
72+
description: "How to deliver the reward to the recipient.",
73+
options: DELIVERY_METHOD_OPTIONS,
4374
},
4475
},
4576
async run({ $ }) {
4677
const response = await this.app.createOrder({
4778
$,
4879
data: {
4980
external_id: this.externalId,
50-
payment: this.fundingSourceId && {
81+
payment: {
5182
funding_source_id: this.fundingSourceId,
5283
},
5384
reward: {
5485
campaign_id: this.campaignId,
5586
products: this.products,
87+
value: {
88+
denomination: this.valueAmount,
89+
currency_code: this.valueCurrencyCode,
90+
},
91+
recipient: {
92+
name: this.recipientName,
93+
email: this.recipientEmail,
94+
phone: this.recipientPhone,
95+
},
96+
delivery: {
97+
method: this.deliveryMethod,
98+
},
5699
},
57100
},
58101
});
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
export const FUNDING_SOURCE_OPTIONS = [
1+
export const DELIVERY_METHOD_OPTIONS = [
22
{
3-
value: "balance",
4-
label:
5-
"Pre-funded balance in your Tremendous account to draw funds from to send rewards to recipients.",
3+
value: "EMAIL",
4+
label: "Deliver the reward to the recipient by email",
65
},
76
{
8-
value: "bank_account",
9-
label: "Bank account to draw funds from to send rewards to recipients.",
7+
value: "LINK",
8+
label: "Deliver the reward to the recipient via a link.",
109
},
10+
1111
{
12-
value: "credit_card",
13-
label: "Credit card to draw funds from to send rewards to recipients.",
14-
},
15-
{
16-
value: "invoice",
17-
label: "Send rewards to recipients and pay by invoice.",
12+
value: "PHONE",
13+
label: "Deliver the reward to the recipient by SMS",
1814
},
1915
];

components/tremendous/tremendous.app.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ export default {
3232
}));
3333
},
3434
},
35+
fundingSourceId: {
36+
type: "string",
37+
label: "Funding Source ID",
38+
description: "Tremendous ID of the funding source that will be used to pay for the order. Use `balance` to use your Tremendous's balance.",
39+
async options() {
40+
const response = await this.listFundingSources();
41+
return response.funding_sources?.map(({
42+
id, method,
43+
}) => ({
44+
label: `${id} - ${method}`,
45+
value: id,
46+
}));
47+
},
48+
},
3549
},
3650
methods: {
3751
_baseRequest({
@@ -65,5 +79,11 @@ export default {
6579
url: "/products",
6680
});
6781
},
82+
listFundingSources() {
83+
return this._baseRequest({
84+
method: "GET",
85+
url: "/funding_sources",
86+
});
87+
},
6888
},
6989
};

0 commit comments

Comments
 (0)