Skip to content

Commit

Permalink
add subscription list
Browse files Browse the repository at this point in the history
  • Loading branch information
humandad committed Feb 23, 2024
1 parent c8929ea commit 2ea1c33
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
33 changes: 33 additions & 0 deletions apps/stripe/bundle/bots/runaction/subscription_list/bot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { RunActionBotApi } from "@uesio/bots"
import { Params } from "@uesio/app/bots/runaction/uesio/stripe/subscription_list"
import { Stripe } from "stripe"

export default function subscription_retrieve(bot: RunActionBotApi) {
const params = bot.params.getAll() as Params
const { customer } = params
const actionName = bot.getActionName()

if (actionName !== "subscription_list") {
bot.addError("unsupported action name: " + actionName)
return
}

const baseURL = bot.getIntegration().getBaseURL()
const result = bot.http.request<
Stripe.SubscriptionListParams,
Stripe.Subscription
>({
method: "GET",
url: baseURL + `/v1/subscriptions`,
body: {
customer: customer as string,
},
})

if (result.code !== 200) {
bot.addError("could not complete subscription list: " + result.code)
return
}

bot.addResult("subscriptions", result.body)
}
9 changes: 9 additions & 0 deletions apps/stripe/bundle/bots/runaction/subscription_list/bot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: subscription_list
public: true
type: RUNACTION
dialect: TYPESCRIPT
params:
- name: customer
label: Customer Id
type: TEXT
required: true
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"prettier": "2.7.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"stripe": "^14.18.0",
"ts-jest": "^29.1.1",
"ts-node": "10.9.1",
"typescript": "4.8.4"
Expand Down

0 comments on commit 2ea1c33

Please sign in to comment.