-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* App and package updates * pnpm * Create Order action * Prop definitions and requests * Type adjustment * Import fix * Adding and adjusting several props
- Loading branch information
Showing
5 changed files
with
228 additions
and
4 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
components/tremendous/actions/create-order-email-reward/create-order-email-reward.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import app from "../../tremendous.app.mjs"; | ||
import { DELIVERY_METHOD_OPTIONS } from "../../common/constants.mjs"; | ||
|
||
export default { | ||
name: "Create Order Email Reward", | ||
version: "0.0.1", | ||
key: "tremendous-create-order-email-reward", | ||
description: "Create an order to send out a reward. [See the documentation](https://developers.tremendous.com/reference/create-order)", | ||
type: "action", | ||
props: { | ||
app, | ||
campaignId: { | ||
propDefinition: [ | ||
app, | ||
"campaignId", | ||
], | ||
optional: true, | ||
}, | ||
products: { | ||
propDefinition: [ | ||
app, | ||
"products", | ||
], | ||
optional: true, | ||
}, | ||
infoBox: { | ||
type: "alert", | ||
alertType: "info", | ||
content: "Either `Products` or `Campaign ID` must be specified. [See the documentation](https://developers.tremendous.com/reference/create-order) for more information.", | ||
}, | ||
fundingSourceId: { | ||
propDefinition: [ | ||
app, | ||
"fundingSourceId", | ||
], | ||
default: "balance", | ||
}, | ||
externalId: { | ||
type: "string", | ||
label: "External ID", | ||
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.", | ||
optional: true, | ||
}, | ||
valueAmount: { | ||
type: "string", | ||
label: "Value Amount", | ||
description: "Amount of the reward.", | ||
}, | ||
valueCurrencyCode: { | ||
type: "string", | ||
label: "Value Currency Code", | ||
description: "Currency of the reward.", | ||
}, | ||
recipientName: { | ||
type: "string", | ||
label: "Recipient Name", | ||
description: "Name of the recipient.", | ||
}, | ||
recipientEmail: { | ||
type: "string", | ||
label: "Recipient Email", | ||
description: "Email address of the recipient.", | ||
}, | ||
recipientPhone: { | ||
type: "string", | ||
label: "Recipient Phone", | ||
description: "Phone number of the recipient. For non-US phone numbers, specify the country code (prefixed with `+`).", | ||
}, | ||
deliveryMethod: { | ||
type: "string", | ||
label: "Delivery Method", | ||
description: "How to deliver the reward to the recipient.", | ||
options: DELIVERY_METHOD_OPTIONS, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.createOrder({ | ||
$, | ||
data: { | ||
external_id: this.externalId, | ||
payment: { | ||
funding_source_id: this.fundingSourceId, | ||
}, | ||
reward: { | ||
campaign_id: this.campaignId, | ||
products: this.products, | ||
value: { | ||
denomination: this.valueAmount, | ||
currency_code: this.valueCurrencyCode, | ||
}, | ||
recipient: { | ||
name: this.recipientName, | ||
email: this.recipientEmail, | ||
phone: this.recipientPhone, | ||
}, | ||
delivery: { | ||
method: this.deliveryMethod, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created order (ID: ${response?.order?.id})`); | ||
|
||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const DELIVERY_METHOD_OPTIONS = [ | ||
{ | ||
value: "EMAIL", | ||
label: "Deliver the reward to the recipient by email", | ||
}, | ||
{ | ||
value: "LINK", | ||
label: "Deliver the reward to the recipient via a link.", | ||
}, | ||
|
||
{ | ||
value: "PHONE", | ||
label: "Deliver the reward to the recipient by SMS", | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@pipedream/tremendous", | ||
"version": "0.0.1", | ||
"description": "Pipedream Tremendous Components", | ||
"main": "tremendous.app.mjs", | ||
"keywords": [ | ||
"pipedream", | ||
"tremendous" | ||
], | ||
"homepage": "https://pipedream.com/apps/tremendous", | ||
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.0.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,89 @@ | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
type: "app", | ||
app: "tremendous", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
campaignId: { | ||
type: "string", | ||
label: "Campaign ID", | ||
description: "ID of the campaign in your account, that defines the available products (different gift cards, charity, etc.) that the recipient can choose from.", | ||
async options() { | ||
const { campaigns } = await this.listCampaigns(); | ||
return campaigns?.map(({ | ||
id, name, | ||
}) => ({ | ||
label: name, | ||
value: id, | ||
})); | ||
}, | ||
}, | ||
products: { | ||
type: "string[]", | ||
label: "Products", | ||
description: "IDs of products (different gift cards, charity, etc.) that will be available to the recipient to choose from. If this and `Campaign ID` are specified, this will override the products made available by the campaign. It will not override other campaign attributes, like the message and customization of the look and feel.", | ||
async options() { | ||
const { products } = await this.listProducts(); | ||
return products?.map(({ | ||
id, name, | ||
}) => ({ | ||
label: name, | ||
value: id, | ||
})); | ||
}, | ||
}, | ||
fundingSourceId: { | ||
type: "string", | ||
label: "Funding Source ID", | ||
description: "Tremendous ID of the funding source that will be used to pay for the order. Use `balance` to use your Tremendous's balance.", | ||
async options() { | ||
const response = await this.listFundingSources(); | ||
return response.funding_sources?.map(({ | ||
id, method, | ||
}) => ({ | ||
label: `${id} - ${method}`, | ||
value: id, | ||
})); | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
_baseRequest({ | ||
$, headers, ...args | ||
}) { | ||
return axios($, { | ||
headers: { | ||
...headers, | ||
Authorization: `Bearer ${this.$auth.api_key}`, | ||
}, | ||
baseURL: "https://testflight.tremendous.com/api/v2", | ||
...args, | ||
}); | ||
}, | ||
createOrder(args) { | ||
return this._baseRequest({ | ||
method: "POST", | ||
url: "/orders", | ||
...args, | ||
}); | ||
}, | ||
listCampaigns() { | ||
return this._baseRequest({ | ||
method: "GET", | ||
url: "/campaigns", | ||
}); | ||
}, | ||
listProducts() { | ||
return this._baseRequest({ | ||
method: "GET", | ||
url: "/products", | ||
}); | ||
}, | ||
listFundingSources() { | ||
return this._baseRequest({ | ||
method: "GET", | ||
url: "/funding_sources", | ||
}); | ||
}, | ||
}, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.