cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/accounts/subscriptions.ts
144lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import { APIResource } from '../../resource'; |
| 4 | import * as Core from '../../core'; |
| 5 | import * as SubscriptionsAPI from './subscriptions'; |
| 6 | import * as Shared from '../shared'; |
| 7 | |
| 8 | export class Subscriptions extends APIResource { |
| 9 | /** |
| 10 | * Creates an account subscription. |
| 11 | */ |
| 12 | create( |
| 13 | params: SubscriptionCreateParams, |
| 14 | options?: Core.RequestOptions, |
| 15 | ): Core.APIPromise<SubscriptionCreateResponse> { |
| 16 | const { account_id, ...body } = params; |
| 17 | return ( |
| 18 | this._client.post(`/accounts/${account_id}/subscriptions`, { body, ...options }) as Core.APIPromise<{ |
| 19 | result: SubscriptionCreateResponse; |
| 20 | }> |
| 21 | )._thenUnwrap((obj) => obj.result); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Updates an account subscription. |
| 26 | */ |
| 27 | update( |
| 28 | subscriptionIdentifier: string, |
| 29 | params: SubscriptionUpdateParams, |
| 30 | options?: Core.RequestOptions, |
| 31 | ): Core.APIPromise<SubscriptionUpdateResponse> { |
| 32 | const { account_id, ...body } = params; |
| 33 | return ( |
| 34 | this._client.put(`/accounts/${account_id}/subscriptions/${subscriptionIdentifier}`, { |
| 35 | body, |
| 36 | ...options, |
| 37 | }) as Core.APIPromise<{ result: SubscriptionUpdateResponse }> |
| 38 | )._thenUnwrap((obj) => obj.result); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Deletes an account's subscription. |
| 43 | */ |
| 44 | delete( |
| 45 | subscriptionIdentifier: string, |
| 46 | params: SubscriptionDeleteParams, |
| 47 | options?: Core.RequestOptions, |
| 48 | ): Core.APIPromise<SubscriptionDeleteResponse> { |
| 49 | const { account_id } = params; |
| 50 | return ( |
| 51 | this._client.delete( |
| 52 | `/accounts/${account_id}/subscriptions/${subscriptionIdentifier}`, |
| 53 | options, |
| 54 | ) as Core.APIPromise<{ result: SubscriptionDeleteResponse }> |
| 55 | )._thenUnwrap((obj) => obj.result); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Lists all of an account's subscriptions. |
| 60 | */ |
| 61 | get( |
| 62 | params: SubscriptionGetParams, |
| 63 | options?: Core.RequestOptions, |
| 64 | ): Core.APIPromise<SubscriptionGetResponse | null> { |
| 65 | const { account_id } = params; |
| 66 | return ( |
| 67 | this._client.get(`/accounts/${account_id}/subscriptions`, options) as Core.APIPromise<{ |
| 68 | result: SubscriptionGetResponse | null; |
| 69 | }> |
| 70 | )._thenUnwrap((obj) => obj.result); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | export type SubscriptionCreateResponse = unknown | string | null; |
| 75 | |
| 76 | export type SubscriptionUpdateResponse = unknown | string | null; |
| 77 | |
| 78 | export interface SubscriptionDeleteResponse { |
| 79 | /** |
| 80 | * Subscription identifier tag. |
| 81 | */ |
| 82 | subscription_id?: string; |
| 83 | } |
| 84 | |
| 85 | export type SubscriptionGetResponse = Array<Shared.Subscription>; |
| 86 | |
| 87 | export interface SubscriptionCreateParams { |
| 88 | /** |
| 89 | * Path param: Identifier |
| 90 | */ |
| 91 | account_id: string; |
| 92 | |
| 93 | /** |
| 94 | * Body param: How often the subscription is renewed automatically. |
| 95 | */ |
| 96 | frequency?: 'weekly' | 'monthly' | 'quarterly' | 'yearly'; |
| 97 | |
| 98 | /** |
| 99 | * Body param: The rate plan applied to the subscription. |
| 100 | */ |
| 101 | rate_plan?: Shared.RatePlanParam; |
| 102 | } |
| 103 | |
| 104 | export interface SubscriptionUpdateParams { |
| 105 | /** |
| 106 | * Path param: Identifier |
| 107 | */ |
| 108 | account_id: string; |
| 109 | |
| 110 | /** |
| 111 | * Body param: How often the subscription is renewed automatically. |
| 112 | */ |
| 113 | frequency?: 'weekly' | 'monthly' | 'quarterly' | 'yearly'; |
| 114 | |
| 115 | /** |
| 116 | * Body param: The rate plan applied to the subscription. |
| 117 | */ |
| 118 | rate_plan?: Shared.RatePlanParam; |
| 119 | } |
| 120 | |
| 121 | export interface SubscriptionDeleteParams { |
| 122 | /** |
| 123 | * Identifier |
| 124 | */ |
| 125 | account_id: string; |
| 126 | } |
| 127 | |
| 128 | export interface SubscriptionGetParams { |
| 129 | /** |
| 130 | * Identifier |
| 131 | */ |
| 132 | account_id: string; |
| 133 | } |
| 134 | |
| 135 | export namespace Subscriptions { |
| 136 | export import SubscriptionCreateResponse = SubscriptionsAPI.SubscriptionCreateResponse; |
| 137 | export import SubscriptionUpdateResponse = SubscriptionsAPI.SubscriptionUpdateResponse; |
| 138 | export import SubscriptionDeleteResponse = SubscriptionsAPI.SubscriptionDeleteResponse; |
| 139 | export import SubscriptionGetResponse = SubscriptionsAPI.SubscriptionGetResponse; |
| 140 | export import SubscriptionCreateParams = SubscriptionsAPI.SubscriptionCreateParams; |
| 141 | export import SubscriptionUpdateParams = SubscriptionsAPI.SubscriptionUpdateParams; |
| 142 | export import SubscriptionDeleteParams = SubscriptionsAPI.SubscriptionDeleteParams; |
| 143 | export import SubscriptionGetParams = SubscriptionsAPI.SubscriptionGetParams; |
| 144 | } |
| 145 | |