|
1 | 1 | import app from "../../tremendous.app.mjs"; |
2 | | -import { FUNDING_SOURCE_OPTIONS } from "../../common/constants.mjs"; |
| 2 | +import { DELIVERY_METHOD_OPTIONS } from "../../common/constants.mjs"; |
3 | 3 |
|
4 | 4 | export default { |
5 | 5 | name: "Create Order Email Reward", |
@@ -28,31 +28,74 @@ export default { |
28 | 28 | alertType: "info", |
29 | 29 | content: "Either `Products` or `Campaign ID` must be specified. [See the documentation](https://developers.tremendous.com/reference/create-order) for more information.", |
30 | 30 | }, |
| 31 | + fundingSourceId: { |
| 32 | + propDefinition: [ |
| 33 | + app, |
| 34 | + "fundingSourceId", |
| 35 | + ], |
| 36 | + default: "balance", |
| 37 | + }, |
31 | 38 | externalId: { |
32 | 39 | type: "string", |
33 | 40 | label: "External ID", |
34 | 41 | 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.", |
35 | 42 | optional: true, |
36 | 43 | }, |
37 | | - fundingSourceId: { |
| 44 | + valueAmount: { |
38 | 45 | 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, |
43 | 74 | }, |
44 | 75 | }, |
45 | 76 | async run({ $ }) { |
46 | 77 | const response = await this.app.createOrder({ |
47 | 78 | $, |
48 | 79 | data: { |
49 | 80 | external_id: this.externalId, |
50 | | - payment: this.fundingSourceId && { |
| 81 | + payment: { |
51 | 82 | funding_source_id: this.fundingSourceId, |
52 | 83 | }, |
53 | 84 | reward: { |
54 | 85 | campaign_id: this.campaignId, |
55 | 86 | 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 | + }, |
56 | 99 | }, |
57 | 100 | }, |
58 | 101 | }); |
|
0 commit comments