| import type { Client } from 'openapi-fetch' |
| import type { RequestOptions } from './common.js' |
| import type { |
| operations, |
| PlanCreate, |
| PlanReplaceUpdate, |
| paths, |
| } from './schemas.js' |
| import { transformResponse } from './utils.js' |
|
|
| |
| |
| |
| |
| export class Plans { |
| public addons: PlanAddons |
|
|
| constructor(private client: Client<paths, `${string}/${string}`>) { |
| this.addons = new PlanAddons(this.client) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public async create(plan: PlanCreate, options?: RequestOptions) { |
| const resp = await this.client.POST('/api/v1/plans', { |
| body: plan, |
| ...options, |
| }) |
|
|
| return transformResponse(resp) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public async get( |
| planId: operations['getPlan']['parameters']['path']['planId'], |
| params?: operations['getPlan']['parameters']['query'], |
| options?: RequestOptions, |
| ) { |
| const resp = await this.client.GET('/api/v1/plans/{planId}', { |
| params: { |
| path: { planId }, |
| query: params, |
| }, |
| ...options, |
| }) |
|
|
| return transformResponse(resp) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public async list( |
| params?: operations['listPlans']['parameters']['query'], |
| options?: RequestOptions, |
| ) { |
| const resp = await this.client.GET('/api/v1/plans', { |
| params: { query: params }, |
| ...options, |
| }) |
|
|
| return transformResponse(resp) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public async update( |
| planId: operations['updatePlan']['parameters']['path']['planId'], |
| plan: PlanReplaceUpdate, |
| options?: RequestOptions, |
| ) { |
| const resp = await this.client.PUT('/api/v1/plans/{planId}', { |
| body: plan, |
| params: { path: { planId } }, |
| ...options, |
| }) |
|
|
| return transformResponse(resp) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public async delete( |
| planId: operations['deletePlan']['parameters']['path']['planId'], |
| options?: RequestOptions, |
| ) { |
| const resp = await this.client.DELETE('/api/v1/plans/{planId}', { |
| params: { path: { planId } }, |
| ...options, |
| }) |
|
|
| return transformResponse(resp) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public async archive( |
| planId: operations['archivePlan']['parameters']['path']['planId'], |
| options?: RequestOptions, |
| ) { |
| const resp = await this.client.POST('/api/v1/plans/{planId}/archive', { |
| params: { path: { planId } }, |
| ...options, |
| }) |
|
|
| return transformResponse(resp) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public async publish( |
| planId: operations['publishPlan']['parameters']['path']['planId'], |
| options?: RequestOptions, |
| ) { |
| const resp = await this.client.POST('/api/v1/plans/{planId}/publish', { |
| params: { path: { planId } }, |
| ...options, |
| }) |
|
|
| return transformResponse(resp) |
| } |
| } |
|
|
| |
| |
| |
| |
| export class PlanAddons { |
| constructor(private client: Client<paths, `${string}/${string}`>) {} |
|
|
| |
| |
| |
| |
| |
| |
| |
| public async list( |
| planId: operations['listPlanAddons']['parameters']['path']['planId'], |
| params?: operations['listPlanAddons']['parameters']['query'], |
| options?: RequestOptions, |
| ) { |
| const resp = await this.client.GET('/api/v1/plans/{planId}/addons', { |
| params: { |
| path: { planId }, |
| query: params, |
| }, |
| ...options, |
| }) |
|
|
| return transformResponse(resp) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public async create( |
| planId: operations['createPlanAddon']['parameters']['path']['planId'], |
| planAddon: operations['createPlanAddon']['requestBody']['content']['application/json'], |
| options?: RequestOptions, |
| ) { |
| const resp = await this.client.POST('/api/v1/plans/{planId}/addons', { |
| body: planAddon, |
| params: { path: { planId } }, |
| ...options, |
| }) |
|
|
| return transformResponse(resp) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public async get( |
| planId: operations['getPlanAddon']['parameters']['path']['planId'], |
| planAddonId: operations['getPlanAddon']['parameters']['path']['planAddonId'], |
| options?: RequestOptions, |
| ) { |
| const resp = await this.client.GET( |
| '/api/v1/plans/{planId}/addons/{planAddonId}', |
| { |
| params: { |
| path: { planAddonId, planId }, |
| }, |
| ...options, |
| }, |
| ) |
|
|
| return transformResponse(resp) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| public async update( |
| planId: operations['updatePlanAddon']['parameters']['path']['planId'], |
| planAddonId: operations['updatePlanAddon']['parameters']['path']['planAddonId'], |
| planAddon: operations['updatePlanAddon']['requestBody']['content']['application/json'], |
| options?: RequestOptions, |
| ) { |
| const resp = await this.client.PUT( |
| '/api/v1/plans/{planId}/addons/{planAddonId}', |
| { |
| body: planAddon, |
| params: { path: { planAddonId, planId } }, |
| ...options, |
| }, |
| ) |
|
|
| return transformResponse(resp) |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public async delete( |
| planId: operations['deletePlanAddon']['parameters']['path']['planId'], |
| planAddonId: operations['deletePlanAddon']['parameters']['path']['planAddonId'], |
| options?: RequestOptions, |
| ) { |
| const resp = await this.client.DELETE( |
| '/api/v1/plans/{planId}/addons/{planAddonId}', |
| { |
| params: { path: { planAddonId, planId } }, |
| ...options, |
| }, |
| ) |
|
|
| return transformResponse(resp) |
| } |
| } |
|
|