cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v4.2.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/resources/accounts/subscriptions.ts

141lines · 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';
6import { SubscriptionsSinglePage } 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.PagePromise<SubscriptionsSinglePage, Shared.Subscription> {
65 const { account_id } = params;
66 return this._client.getAPIList(`/accounts/${account_id}/subscriptions`, SubscriptionsSinglePage, options);
67 }
68}
69
70export type SubscriptionCreateResponse = unknown | string | null;
71
72export type SubscriptionUpdateResponse = unknown | string | null;
73
74export interface SubscriptionDeleteResponse {
75 /**
76 * Subscription identifier tag.
77 */
78 subscription_id?: string;
79}
80
81export interface SubscriptionCreateParams {
82 /**
83 * Path param: Identifier
84 */
85 account_id: string;
86
87 /**
88 * Body param: How often the subscription is renewed automatically.
89 */
90 frequency?: 'weekly' | 'monthly' | 'quarterly' | 'yearly';
91
92 /**
93 * Body param: The rate plan applied to the subscription.
94 */
95 rate_plan?: Shared.RatePlanParam;
96}
97
98export interface SubscriptionUpdateParams {
99 /**
100 * Path param: Identifier
101 */
102 account_id: string;
103
104 /**
105 * Body param: How often the subscription is renewed automatically.
106 */
107 frequency?: 'weekly' | 'monthly' | 'quarterly' | 'yearly';
108
109 /**
110 * Body param: The rate plan applied to the subscription.
111 */
112 rate_plan?: Shared.RatePlanParam;
113}
114
115export interface SubscriptionDeleteParams {
116 /**
117 * Identifier
118 */
119 account_id: string;
120}
121
122export interface SubscriptionGetParams {
123 /**
124 * Identifier
125 */
126 account_id: string;
127}
128
129export declare namespace Subscriptions {
130 export {
131 type SubscriptionCreateResponse as SubscriptionCreateResponse,
132 type SubscriptionUpdateResponse as SubscriptionUpdateResponse,
133 type SubscriptionDeleteResponse as SubscriptionDeleteResponse,
134 type SubscriptionCreateParams as SubscriptionCreateParams,
135 type SubscriptionUpdateParams as SubscriptionUpdateParams,
136 type SubscriptionDeleteParams as SubscriptionDeleteParams,
137 type SubscriptionGetParams as SubscriptionGetParams,
138 };
139}
140
141export { SubscriptionsSinglePage };
142