import { AppcondaException, Client, Payload } from "../client"; export class TenantSubscription { client: Client; constructor(client: Client) { this.client = client; } async getOrPersistTenantSubscription(tenantId: string): Promise { if (typeof tenantId === 'undefined') { throw new AppcondaException('Missing required parameter: "tenantId"'); } const apiPath = `/tenant/subscriptions/${tenantId}`; const payload: Payload = {}; if (typeof tenantId !== 'undefined') { payload['tenantId'] = tenantId; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', } return await this.client.call( 'get', uri, apiHeaders, payload, 'arrayBuffer' ); } async getTenantSubscriptions(): Promise { const apiPath = `/tenant/subscriptions`; const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', } return await this.client.call( 'get', uri, apiHeaders, payload, 'arrayBuffer' ); } async createTenantSubscription(tenantId: string, stripeCustomerId: string): Promise<{id: string, tenantId: string, stripeCustomerId: string}> { if (typeof tenantId === 'undefined') { throw new AppcondaException('Missing required parameter: "tenantId"'); } if (typeof stripeCustomerId === 'undefined') { throw new AppcondaException('Missing required parameter: "stripeCustomerId"'); } const apiPath = '/tenant/subscriptions'; const payload: Payload = {}; if (typeof tenantId !== 'undefined') { payload['tenantId'] = tenantId; } if (typeof stripeCustomerId !== 'undefined') { payload['stripeCustomerId'] = stripeCustomerId; } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { 'content-type': 'application/json', } return await this.client.call( 'post', uri, apiHeaders, payload, ); } }