export type Entity = {id?: string | undefined, updatedDate?: string | undefined, createdDate?: string | undefined}; export type AuditLog = {changeType?: string | undefined, changeDate?: string | undefined, objectType?: ('ACCOUNT' | 'ACCOUNT_EMAIL' | 'BLOCKING_STATES' | 'BUNDLE' | 'CUSTOM_FIELD' | 'INVOICE' | 'PAYMENT' | 'TRANSACTION' | 'INVOICE_ITEM' | 'INVOICE_PAYMENT' | 'SUBSCRIPTION' | 'SUBSCRIPTION_EVENT' | 'SERVICE_BROADCAST' | 'PAYMENT_ATTEMPT' | 'PAYMENT_METHOD' | 'TAG' | 'TAG_DEFINITION' | 'TENANT' | 'TENANT_KVS') | undefined, objectId?: string | undefined, changedBy?: string | undefined, reasonCode?: string | undefined, comments?: string | undefined, userToken?: string | undefined, history?: Entity | undefined}; export type EventSubscription = {eventId?: string | undefined, billingPeriod?: ('DAILY' | 'WEEKLY' | 'BIWEEKLY' | 'THIRTY_DAYS' | 'SIXTY_DAYS' | 'NINETY_DAYS' | 'MONTHLY' | 'BIMESTRIAL' | 'QUARTERLY' | 'TRIANNUAL' | 'BIANNUAL' | 'ANNUAL' | 'BIENNIAL' | 'NO_BILLING_PERIOD') | undefined, effectiveDate?: string | undefined, plan?: string | undefined, product?: string | undefined, priceList?: string | undefined, eventType?: ('START_ENTITLEMENT' | 'START_BILLING' | 'PAUSE_ENTITLEMENT' | 'PAUSE_BILLING' | 'RESUME_ENTITLEMENT' | 'RESUME_BILLING' | 'PHASE' | 'CHANGE' | 'STOP_ENTITLEMENT' | 'STOP_BILLING' | 'SERVICE_STATE_CHANGE') | undefined, isBlockedBilling?: boolean | undefined, isBlockedEntitlement?: boolean | undefined, serviceName?: string | undefined, serviceStateName?: string | undefined, phase?: string | undefined, auditLogs?: Array | undefined}; export type BlockPrice = {unitName?: string | undefined, size?: number | undefined, price?: number | undefined, max?: number | undefined}; export type TierPrice = {blockPrices?: Array | undefined}; export type UsagePrice = {usageName?: string | undefined, usageType?: ('CAPACITY' | 'CONSUMABLE') | undefined, billingMode?: ('IN_ADVANCE' | 'IN_ARREAR') | undefined, tierBlockPolicy?: ('ALL_TIERS' | 'TOP_TIER') | undefined, tierPrices?: Array | undefined}; export type PhasePrice = {planName?: string | undefined, phaseName?: string | undefined, phaseType?: string | undefined, fixedPrice?: number | undefined, recurringPrice?: number | undefined, usagePrices?: Array | undefined}; export type Subscription = {accountId?: string | undefined, bundleId?: string | undefined, bundleExternalKey?: string | undefined, subscriptionId?: string | undefined, externalKey?: string | undefined, startDate?: string | undefined, productName: string, productCategory?: ('BASE' | 'ADD_ON' | 'STANDALONE') | undefined, billingPeriod: 'DAILY' | 'WEEKLY' | 'BIWEEKLY' | 'THIRTY_DAYS' | 'SIXTY_DAYS' | 'NINETY_DAYS' | 'MONTHLY' | 'BIMESTRIAL' | 'QUARTERLY' | 'TRIANNUAL' | 'BIANNUAL' | 'ANNUAL' | 'BIENNIAL' | 'NO_BILLING_PERIOD', phaseType?: ('TRIAL' | 'DISCOUNT' | 'FIXEDTERM' | 'EVERGREEN') | undefined, priceList: string, planName: string, state?: ('PENDING' | 'ACTIVE' | 'BLOCKED' | 'CANCELLED' | 'EXPIRED') | undefined, sourceType?: ('NATIVE' | 'MIGRATED' | 'TRANSFERRED') | undefined, cancelledDate?: string | undefined, chargedThroughDate?: string | undefined, billingStartDate?: string | undefined, billingEndDate?: string | undefined, billCycleDayLocal?: number | undefined, events?: Array | undefined, priceOverrides?: Array | undefined, prices?: Array | undefined, auditLogs?: Array | undefined}; export type UpdateApi10KbSubscriptionsSubscriptionIdArgs = {subscriptionId: string, requestedDate?: string | undefined, callCompletion?: boolean | undefined, callTimeoutSec?: number | undefined, billingPolicy?: ('START_OF_TERM' | 'END_OF_TERM' | 'IMMEDIATE' | 'ILLEGAL') | undefined, pluginProperty?: Array | undefined, 'X-Killbill-CreatedBy': string, 'X-Killbill-Reason'?: string | undefined, 'X-Killbill-Comment'?: string | undefined, body: Subscription}; export type UpdateApi10KbSubscriptionsSubscriptionIdOptions = {baseUrl: string, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Change entitlement plan * * PUT /1.0/kb/subscriptions/{subscriptionId} * * Also accepts auth: Killbill_Api_Key, Killbill_Api_Secret */ export const updateApi10KbSubscriptionsSubscriptionId = async (args: UpdateApi10KbSubscriptionsSubscriptionIdArgs, options: UpdateApi10KbSubscriptionsSubscriptionIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.requestedDate != null) query.append("requestedDate", String(args.requestedDate)) if (args.callCompletion != null) query.append("callCompletion", String(args.callCompletion)) if (args.callTimeoutSec != null) query.append("callTimeoutSec", String(args.callTimeoutSec)) if (args.billingPolicy != null) query.append("billingPolicy", String(args.billingPolicy)) for (const item of args.pluginProperty ?? []) query.append("pluginProperty", String(item)) if (args['X-Killbill-CreatedBy'] != null) headers.set("X-Killbill-CreatedBy", String(args['X-Killbill-CreatedBy'])) if (args['X-Killbill-Reason'] != null) headers.set("X-Killbill-Reason", String(args['X-Killbill-Reason'])) if (args['X-Killbill-Comment'] != null) headers.set("X-Killbill-Comment", String(args['X-Killbill-Comment'])) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/1.0/kb/subscriptions/${encodeURIComponent(String(args.subscriptionId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };