cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
060eef8e533bf6ca7a944dab688d4bfbcf80af59

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/accounts/subscriptions.ts

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