|
1 | 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
2 | 2 |
|
3 | 3 | import { APIResource } from '../../resource'; |
| 4 | +import * as Core from '../../core'; |
| 5 | +import * as Shared from '../shared'; |
4 | 6 |
|
5 | | -export class Subscriptions extends APIResource {} |
| 7 | +export class Subscriptions extends APIResource { |
| 8 | + /** |
| 9 | + * Create a zone subscription, either plan or add-ons. |
| 10 | + * |
| 11 | + * @example |
| 12 | + * ```ts |
| 13 | + * const subscription = |
| 14 | + * await client.zones.subscriptions.create({ |
| 15 | + * zone_id: '506e3185e9c882d175a2d0cb0093d9f2', |
| 16 | + * }); |
| 17 | + * ``` |
| 18 | + */ |
| 19 | + create( |
| 20 | + params: SubscriptionCreateParams, |
| 21 | + options?: Core.RequestOptions, |
| 22 | + ): Core.APIPromise<Shared.Subscription> { |
| 23 | + const { zone_id, ...body } = params; |
| 24 | + return ( |
| 25 | + this._client.post(`/zones/${zone_id}/subscription`, { body, ...options }) as Core.APIPromise<{ |
| 26 | + result: Shared.Subscription; |
| 27 | + }> |
| 28 | + )._thenUnwrap((obj) => obj.result); |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * Updates zone subscriptions, either plan or add-ons. |
| 33 | + * |
| 34 | + * @example |
| 35 | + * ```ts |
| 36 | + * const subscription = |
| 37 | + * await client.zones.subscriptions.update({ |
| 38 | + * zone_id: '506e3185e9c882d175a2d0cb0093d9f2', |
| 39 | + * }); |
| 40 | + * ``` |
| 41 | + */ |
| 42 | + update( |
| 43 | + params: SubscriptionUpdateParams, |
| 44 | + options?: Core.RequestOptions, |
| 45 | + ): Core.APIPromise<Shared.Subscription> { |
| 46 | + const { zone_id, ...body } = params; |
| 47 | + return ( |
| 48 | + this._client.put(`/zones/${zone_id}/subscription`, { body, ...options }) as Core.APIPromise<{ |
| 49 | + result: Shared.Subscription; |
| 50 | + }> |
| 51 | + )._thenUnwrap((obj) => obj.result); |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * Lists zone subscription details. |
| 56 | + * |
| 57 | + * @example |
| 58 | + * ```ts |
| 59 | + * const subscription = await client.zones.subscriptions.get({ |
| 60 | + * zone_id: '506e3185e9c882d175a2d0cb0093d9f2', |
| 61 | + * }); |
| 62 | + * ``` |
| 63 | + */ |
| 64 | + get(params: SubscriptionGetParams, options?: Core.RequestOptions): Core.APIPromise<Shared.Subscription> { |
| 65 | + const { zone_id } = params; |
| 66 | + return ( |
| 67 | + this._client.get(`/zones/${zone_id}/subscription`, options) as Core.APIPromise<{ |
| 68 | + result: Shared.Subscription; |
| 69 | + }> |
| 70 | + )._thenUnwrap((obj) => obj.result); |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +export interface SubscriptionCreateParams { |
| 75 | + /** |
| 76 | + * Path param: Subscription identifier tag. |
| 77 | + */ |
| 78 | + zone_id: string; |
| 79 | + |
| 80 | + /** |
| 81 | + * Body param: How often the subscription is renewed automatically. |
| 82 | + */ |
| 83 | + frequency?: 'weekly' | 'monthly' | 'quarterly' | 'yearly'; |
| 84 | + |
| 85 | + /** |
| 86 | + * Body param: The rate plan applied to the subscription. |
| 87 | + */ |
| 88 | + rate_plan?: Shared.RatePlanParam; |
| 89 | +} |
| 90 | + |
| 91 | +export interface SubscriptionUpdateParams { |
| 92 | + /** |
| 93 | + * Path param: Subscription identifier tag. |
| 94 | + */ |
| 95 | + zone_id: string; |
| 96 | + |
| 97 | + /** |
| 98 | + * Body param: How often the subscription is renewed automatically. |
| 99 | + */ |
| 100 | + frequency?: 'weekly' | 'monthly' | 'quarterly' | 'yearly'; |
| 101 | + |
| 102 | + /** |
| 103 | + * Body param: The rate plan applied to the subscription. |
| 104 | + */ |
| 105 | + rate_plan?: Shared.RatePlanParam; |
| 106 | +} |
| 107 | + |
| 108 | +export interface SubscriptionGetParams { |
| 109 | + /** |
| 110 | + * Subscription identifier tag. |
| 111 | + */ |
| 112 | + zone_id: string; |
| 113 | +} |
| 114 | + |
| 115 | +export declare namespace Subscriptions { |
| 116 | + export { |
| 117 | + type SubscriptionCreateParams as SubscriptionCreateParams, |
| 118 | + type SubscriptionUpdateParams as SubscriptionUpdateParams, |
| 119 | + type SubscriptionGetParams as SubscriptionGetParams, |
| 120 | + }; |
| 121 | +} |
0 commit comments