-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat customer create run action (#67)
* feat: customer create run action * update index types * add new param types * add metadata parameter * Update bot.ts * Update bot.yaml
- Loading branch information
Abel Jimenez Molla
authored
Feb 20, 2024
1 parent
7d3d54e
commit afbc4e5
Showing
5 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
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,38 @@ | ||
import { RunActionBotApi } from "@uesio/bots" | ||
import { Params } from "@uesio/app/bots/runaction/uesio/stripe/customer_create" | ||
import { Stripe } from "stripe" | ||
|
||
export default function customer_create(bot: RunActionBotApi) { | ||
const params = bot.params.getAll() as Params | ||
const { name, email, metadata } = params | ||
const actionName = bot.getActionName() | ||
|
||
if (actionName !== "customer_create") { | ||
bot.addError("unsupported action name: " + actionName) | ||
return | ||
} | ||
|
||
const baseURL = bot.getIntegration().getBaseURL() | ||
const result = bot.http.request< | ||
Stripe.CustomerCreateParams, | ||
Stripe.Customer | ||
>({ | ||
method: "POST", | ||
url: baseURL + "/v1/customers", | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded", | ||
}, | ||
body: { | ||
name, | ||
email, | ||
metadata, | ||
}, | ||
}) | ||
|
||
if (result.code !== 200) { | ||
bot.addError("could not complete customer creation: " + result.code) | ||
return | ||
} | ||
|
||
bot.addResult("customer", result.body) | ||
} |
17 changes: 17 additions & 0 deletions
17
apps/stripe/bundle/bots/runaction/customer_create/bot.yaml
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,17 @@ | ||
name: customer_create | ||
public: true | ||
type: RUNACTION | ||
dialect: TYPESCRIPT | ||
params: | ||
- name: name | ||
label: Customer full name | ||
type: TEXT | ||
required: true | ||
- name: email | ||
type: TEXT | ||
required: true | ||
selectList: mode | ||
- name: metadata | ||
label: Set of key-value pairs | ||
type: MAP | ||
required: true |
4 changes: 4 additions & 0 deletions
4
apps/stripe/bundle/integrationactions/uesio/stripe/stripe/customer_create.yaml
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,4 @@ | ||
name: customer_create | ||
label: Create a Customer Object | ||
public: true | ||
bot: customer_create |
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
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