cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
dc2c35e0eaee6169f220ff4de53afa8ecffd409d

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/resources/accounts/subscriptions.ts

144lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { APIResource } from '../../resource';
4import * as Core from '../../core';
5import * as SubscriptionsAPI from './subscriptions';
6import * as Shared from '../shared';
7
8export 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
74export type SubscriptionCreateResponse = unknown | string | null;
75
76export type SubscriptionUpdateResponse = unknown | string | null;
77
78export interface SubscriptionDeleteResponse {
79 /**
80 * Subscription identifier tag.
81 */
82 subscription_id?: string;
83}
84
85export type SubscriptionGetResponse = Array<Shared.Subscription>;
86
87export 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
104export 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
121export interface SubscriptionDeleteParams {
122 /**
123 * Identifier
124 */
125 account_id: string;
126}
127
128export interface SubscriptionGetParams {
129 /**
130 * Identifier
131 */
132 account_id: string;
133}
134
135export 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