Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add subscription update #72

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions apps/stripe/bundle/bots/runaction/checkout/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ export default function checkout(bot: RunActionBotApi) {
const params = bot.params.getAll() as Params
// eslint-disable-next-line @typescript-eslint/naming-convention
const { currency, customer, success_url, cancel_url } = params
const actionName = bot.getActionName()
const mode = params.mode as Stripe.Checkout.SessionCreateParams.Mode
// eslint-disable-next-line @typescript-eslint/naming-convention
const line_items = params.line_items as
| Stripe.Checkout.SessionCreateParams.LineItem[]
| undefined

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

const baseURL = bot.getIntegration().getBaseURL()
const result = bot.http.request<
Stripe.Checkout.SessionCreateParams,
Expand Down
6 changes: 0 additions & 6 deletions apps/stripe/bundle/bots/runaction/checkout_retrieve/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import { Stripe } from "stripe"
export default function checkout_retrieve(bot: RunActionBotApi) {
const params = bot.params.getAll() as Params
const { id } = params
const actionName = bot.getActionName()

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

const baseURL = bot.getIntegration().getBaseURL()
const result = bot.http.request<null, Stripe.Checkout.Session>({
Expand Down
6 changes: 0 additions & 6 deletions apps/stripe/bundle/bots/runaction/customer_create/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ 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<
Expand Down
6 changes: 0 additions & 6 deletions apps/stripe/bundle/bots/runaction/customer_search/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import { Stripe } from "stripe"

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

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

const buildQueryString = (params: Params) => {
let query = ""
Expand Down
6 changes: 0 additions & 6 deletions apps/stripe/bundle/bots/runaction/subscription_list/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ 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<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import { Stripe } from "stripe"
export default function subscription_retrieve(bot: RunActionBotApi) {
const params = bot.params.getAll() as Params
const { id } = params
const actionName = bot.getActionName()

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

const baseURL = bot.getIntegration().getBaseURL()
const result = bot.http.request<null, Stripe.Subscription>({
Expand Down
27 changes: 27 additions & 0 deletions apps/stripe/bundle/bots/runaction/subscription_update/bot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { RunActionBotApi } from "@uesio/bots"
import { Params } from "@uesio/app/bots/runaction/uesio/stripe/subscription_update"
import { Stripe } from "stripe"

export default function subscription_update(bot: RunActionBotApi) {
const params = bot.params.getAll() as Params
const { id, items } = params

const baseURL = bot.getIntegration().getBaseURL()
const result = bot.http.request<
Stripe.SubscriptionUpdateParams,
Stripe.Subscription
>({
method: "POST",
url: baseURL + `/v1/subscriptions/${id}`,
body: {
items,
},
})

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

bot.addResult("subscription", result.body)
}
13 changes: 13 additions & 0 deletions apps/stripe/bundle/bots/runaction/subscription_update/bot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: subscription_list
public: true
type: RUNACTION
dialect: TYPESCRIPT
params:
- name: id
label: Subscription Id
type: TEXT
required: true
- name: items
label: Items
type: MAP #TO-DO This must be a List of Struct using MAP so we got undefined type in typescript
required: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: subscription_update
label: Update Subscription
public: true
bot: subscription_update
Loading