@mailmeteor/ts-sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,143 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+
3
+ import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
4
+ import {
5
+ type ArraySeparatorStyle,
6
+ serializeArrayParam,
7
+ serializeObjectParam,
8
+ serializePrimitiveParam,
9
+ } from './pathSerializer.gen';
10
+
11
+ export interface PathSerializer {
12
+ path: Record<string, unknown>;
13
+ url: string;
14
+ }
15
+
16
+ export const PATH_PARAM_RE = /\{[^{}]+\}/g;
17
+
18
+ export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
19
+ let url = _url;
20
+ const matches = _url.match(PATH_PARAM_RE);
21
+ if (matches) {
22
+ for (const match of matches) {
23
+ let explode = false;
24
+ let name = match.substring(1, match.length - 1);
25
+ let style: ArraySeparatorStyle = 'simple';
26
+
27
+ if (name.endsWith('*')) {
28
+ explode = true;
29
+ name = name.substring(0, name.length - 1);
30
+ }
31
+
32
+ if (name.startsWith('.')) {
33
+ name = name.substring(1);
34
+ style = 'label';
35
+ } else if (name.startsWith(';')) {
36
+ name = name.substring(1);
37
+ style = 'matrix';
38
+ }
39
+
40
+ const value = path[name];
41
+
42
+ if (value === undefined || value === null) {
43
+ continue;
44
+ }
45
+
46
+ if (Array.isArray(value)) {
47
+ url = url.replace(
48
+ match,
49
+ serializeArrayParam({ explode, name, style, value }),
50
+ );
51
+ continue;
52
+ }
53
+
54
+ if (typeof value === 'object') {
55
+ url = url.replace(
56
+ match,
57
+ serializeObjectParam({
58
+ explode,
59
+ name,
60
+ style,
61
+ value: value as Record<string, unknown>,
62
+ valueOnly: true,
63
+ }),
64
+ );
65
+ continue;
66
+ }
67
+
68
+ if (style === 'matrix') {
69
+ url = url.replace(
70
+ match,
71
+ `;${serializePrimitiveParam({
72
+ name,
73
+ value: value as string,
74
+ })}`,
75
+ );
76
+ continue;
77
+ }
78
+
79
+ const replaceValue = encodeURIComponent(
80
+ style === 'label' ? `.${value as string}` : (value as string),
81
+ );
82
+ url = url.replace(match, replaceValue);
83
+ }
84
+ }
85
+ return url;
86
+ };
87
+
88
+ export const getUrl = ({
89
+ baseUrl,
90
+ path,
91
+ query,
92
+ querySerializer,
93
+ url: _url,
94
+ }: {
95
+ baseUrl?: string;
96
+ path?: Record<string, unknown>;
97
+ query?: Record<string, unknown>;
98
+ querySerializer: QuerySerializer;
99
+ url: string;
100
+ }) => {
101
+ const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
102
+ let url = (baseUrl ?? '') + pathUrl;
103
+ if (path) {
104
+ url = defaultPathSerializer({ path, url });
105
+ }
106
+ let search = query ? querySerializer(query) : '';
107
+ if (search.startsWith('?')) {
108
+ search = search.substring(1);
109
+ }
110
+ if (search) {
111
+ url += `?${search}`;
112
+ }
113
+ return url;
114
+ };
115
+
116
+ export function getValidRequestBody(options: {
117
+ body?: unknown;
118
+ bodySerializer?: BodySerializer | null;
119
+ serializedBody?: unknown;
120
+ }) {
121
+ const hasBody = options.body !== undefined;
122
+ const isSerializedBody = hasBody && options.bodySerializer;
123
+
124
+ if (isSerializedBody) {
125
+ if ('serializedBody' in options) {
126
+ const hasSerializedBody =
127
+ options.serializedBody !== undefined && options.serializedBody !== '';
128
+
129
+ return hasSerializedBody ? options.serializedBody : null;
130
+ }
131
+
132
+ // not all clients implement a serializedBody property (i.e. client-axios)
133
+ return options.body !== '' ? options.body : null;
134
+ }
135
+
136
+ // plain/text body
137
+ if (hasBody) {
138
+ return options.body;
139
+ }
140
+
141
+ // no body was provided
142
+ return undefined;
143
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+
3
+ export { Billing, BillingAddons, BillingSubscription, Default, type Options } from './sdk.gen';
4
+ export type { ClientOptions, GetAddonsData, GetAddonsResponse, GetAddonsResponses, GetAddonUsagesData, GetAddonUsagesResponse, GetAddonUsagesResponses, GetData, GetOpenapiJsonData, GetOpenapiJsonResponses, GetPricesData, GetPricesResponse, GetPricesResponses, GetResponse, GetResponses, PreviewUpdate2Data, PreviewUpdate2Response, PreviewUpdate2Responses, PreviewUpdateData, PreviewUpdateResponse, PreviewUpdateResponses, Update2Data, Update2Response, Update2Responses, UpdateData, UpdateResponse, UpdateResponses } from './types.gen';
package/src/sdk.gen.ts ADDED
@@ -0,0 +1,115 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+
3
+ import type { Client, Options as Options2, TDataShape } from './client';
4
+ import { client } from './client.gen';
5
+ import type { GetAddonsData, GetAddonsResponses, GetAddonUsagesData, GetAddonUsagesResponses, GetData, GetOpenapiJsonData, GetOpenapiJsonResponses, GetPricesData, GetPricesResponses, GetResponses, PreviewUpdate2Data, PreviewUpdate2Responses, PreviewUpdateData, PreviewUpdateResponses, Update2Data, Update2Responses, UpdateData, UpdateResponses } from './types.gen';
6
+
7
+ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
8
+ /**
9
+ * You can provide a client instance returned by `createClient()` instead of
10
+ * individual options. This might be also useful if you want to implement a
11
+ * custom client.
12
+ */
13
+ client?: Client;
14
+ /**
15
+ * You can pass arbitrary values through the `meta` object. This can be
16
+ * used to access values that aren't defined as part of the SDK function.
17
+ */
18
+ meta?: Record<string, unknown>;
19
+ };
20
+
21
+ export class BillingAddons {
22
+ public static getAddons<ThrowOnError extends boolean = false>(options?: Options<GetAddonsData, ThrowOnError>) {
23
+ return (options?.client ?? client).get<GetAddonsResponses, unknown, ThrowOnError>({
24
+ security: [{ scheme: 'bearer', type: 'http' }],
25
+ url: '/billing/addons',
26
+ ...options
27
+ });
28
+ }
29
+
30
+ public static previewUpdate<ThrowOnError extends boolean = false>(options: Options<PreviewUpdateData, ThrowOnError>) {
31
+ return (options.client ?? client).post<PreviewUpdateResponses, unknown, ThrowOnError>({
32
+ security: [{ scheme: 'bearer', type: 'http' }],
33
+ url: '/billing/addons/{addon}/preview',
34
+ ...options,
35
+ headers: {
36
+ 'Content-Type': 'application/json',
37
+ ...options.headers
38
+ }
39
+ });
40
+ }
41
+
42
+ public static getAddonUsages<ThrowOnError extends boolean = false>(options: Options<GetAddonUsagesData, ThrowOnError>) {
43
+ return (options.client ?? client).get<GetAddonUsagesResponses, unknown, ThrowOnError>({
44
+ security: [{ scheme: 'bearer', type: 'http' }],
45
+ url: '/billing/addons/{addon}',
46
+ ...options
47
+ });
48
+ }
49
+
50
+ public static update<ThrowOnError extends boolean = false>(options: Options<UpdateData, ThrowOnError>) {
51
+ return (options.client ?? client).post<UpdateResponses, unknown, ThrowOnError>({
52
+ security: [{ scheme: 'bearer', type: 'http' }],
53
+ url: '/billing/addons/{addon}',
54
+ ...options,
55
+ headers: {
56
+ 'Content-Type': 'application/json',
57
+ ...options.headers
58
+ }
59
+ });
60
+ }
61
+ }
62
+
63
+ export class Default {
64
+ public static getOpenapiJson<ThrowOnError extends boolean = false>(options?: Options<GetOpenapiJsonData, ThrowOnError>) {
65
+ return (options?.client ?? client).get<GetOpenapiJsonResponses, unknown, ThrowOnError>({
66
+ security: [{ scheme: 'bearer', type: 'http' }],
67
+ url: '/openapi.json',
68
+ ...options
69
+ });
70
+ }
71
+ }
72
+
73
+ export class Billing {
74
+ public static getPrices<ThrowOnError extends boolean = false>(options: Options<GetPricesData, ThrowOnError>) {
75
+ return (options.client ?? client).get<GetPricesResponses, unknown, ThrowOnError>({
76
+ security: [{ scheme: 'bearer', type: 'http' }],
77
+ url: '/billing/prices',
78
+ ...options
79
+ });
80
+ }
81
+ }
82
+
83
+ export class BillingSubscription {
84
+ public static get<ThrowOnError extends boolean = false>(options?: Options<GetData, ThrowOnError>) {
85
+ return (options?.client ?? client).get<GetResponses, unknown, ThrowOnError>({
86
+ security: [{ scheme: 'bearer', type: 'http' }],
87
+ url: '/billing/subscription',
88
+ ...options
89
+ });
90
+ }
91
+
92
+ public static update<ThrowOnError extends boolean = false>(options?: Options<Update2Data, ThrowOnError>) {
93
+ return (options?.client ?? client).post<Update2Responses, unknown, ThrowOnError>({
94
+ security: [{ scheme: 'bearer', type: 'http' }],
95
+ url: '/billing/subscription',
96
+ ...options,
97
+ headers: {
98
+ 'Content-Type': 'application/json',
99
+ ...options?.headers
100
+ }
101
+ });
102
+ }
103
+
104
+ public static previewUpdate<ThrowOnError extends boolean = false>(options?: Options<PreviewUpdate2Data, ThrowOnError>) {
105
+ return (options?.client ?? client).post<PreviewUpdate2Responses, unknown, ThrowOnError>({
106
+ security: [{ scheme: 'bearer', type: 'http' }],
107
+ url: '/billing/subscription/preview',
108
+ ...options,
109
+ headers: {
110
+ 'Content-Type': 'application/json',
111
+ ...options?.headers
112
+ }
113
+ });
114
+ }
115
+ }
@@ -0,0 +1,245 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+
3
+ export type ClientOptions = {
4
+ baseUrl: `${string}://${string}/v1` | (string & {});
5
+ };
6
+
7
+ export type GetAddonsData = {
8
+ body?: never;
9
+ path?: never;
10
+ query?: never;
11
+ url: '/billing/addons';
12
+ };
13
+
14
+ export type GetAddonsResponses = {
15
+ /**
16
+ * Response
17
+ */
18
+ 200: {
19
+ [key: string]: {
20
+ included_per_seat: number;
21
+ included_total: number;
22
+ used: number;
23
+ extra: {
24
+ price_amount: number;
25
+ currency: string;
26
+ quantity_per_addon: number;
27
+ interval: 'day' | 'week' | 'month' | 'year';
28
+ subscribed: number;
29
+ } | null;
30
+ };
31
+ };
32
+ };
33
+
34
+ export type GetAddonsResponse = GetAddonsResponses[keyof GetAddonsResponses];
35
+
36
+ export type PreviewUpdateData = {
37
+ body?: {
38
+ quantity: number;
39
+ };
40
+ path: {
41
+ addon: string;
42
+ };
43
+ query?: never;
44
+ url: '/billing/addons/{addon}/preview';
45
+ };
46
+
47
+ export type PreviewUpdateResponses = {
48
+ /**
49
+ * Response
50
+ */
51
+ 200: {
52
+ discount_percents: Array<number>;
53
+ total_excluding_tax: number;
54
+ total: number;
55
+ amount_due: number;
56
+ added_from_balance: number;
57
+ consumed_balance: number;
58
+ credited_to_balance: number;
59
+ };
60
+ };
61
+
62
+ export type PreviewUpdateResponse = PreviewUpdateResponses[keyof PreviewUpdateResponses];
63
+
64
+ export type GetAddonUsagesData = {
65
+ body?: never;
66
+ path: {
67
+ addon: string;
68
+ };
69
+ query?: never;
70
+ url: '/billing/addons/{addon}';
71
+ };
72
+
73
+ export type GetAddonUsagesResponses = {
74
+ /**
75
+ * Response
76
+ */
77
+ 200: Array<{
78
+ id: string;
79
+ email: string;
80
+ usage: number;
81
+ }>;
82
+ };
83
+
84
+ export type GetAddonUsagesResponse = GetAddonUsagesResponses[keyof GetAddonUsagesResponses];
85
+
86
+ export type UpdateData = {
87
+ body?: {
88
+ quantity: number;
89
+ };
90
+ path: {
91
+ addon: string;
92
+ };
93
+ query?: never;
94
+ url: '/billing/addons/{addon}';
95
+ };
96
+
97
+ export type UpdateResponses = {
98
+ /**
99
+ * Response
100
+ */
101
+ 200: {
102
+ status: 'confirmation_required' | 'success' | 'payment_failed';
103
+ client_secret?: string;
104
+ failure_code?: string;
105
+ };
106
+ };
107
+
108
+ export type UpdateResponse = UpdateResponses[keyof UpdateResponses];
109
+
110
+ export type GetOpenapiJsonData = {
111
+ body?: never;
112
+ path?: never;
113
+ query?: never;
114
+ url: '/openapi.json';
115
+ };
116
+
117
+ export type GetOpenapiJsonResponses = {
118
+ /**
119
+ * Response
120
+ */
121
+ 200: unknown;
122
+ };
123
+
124
+ export type GetPricesData = {
125
+ body?: never;
126
+ path?: never;
127
+ query: {
128
+ currency: string;
129
+ };
130
+ url: '/billing/prices';
131
+ };
132
+
133
+ export type GetPricesResponses = {
134
+ /**
135
+ * Response
136
+ */
137
+ 200: {
138
+ [key: string]: {
139
+ month: number;
140
+ year: number;
141
+ };
142
+ };
143
+ };
144
+
145
+ export type GetPricesResponse = GetPricesResponses[keyof GetPricesResponses];
146
+
147
+ export type GetData = {
148
+ body?: never;
149
+ path?: never;
150
+ query?: never;
151
+ url: '/billing/subscription';
152
+ };
153
+
154
+ export type GetResponses = {
155
+ /**
156
+ * Response
157
+ */
158
+ 200: {
159
+ id: string;
160
+ created_at: number;
161
+ current_period_start: number;
162
+ current_period_end: number;
163
+ quantity: number;
164
+ currency: string;
165
+ amount: number | null;
166
+ discount_percentage?: number | null;
167
+ name: string | null;
168
+ billing_period: 'day' | 'week' | 'month' | 'year';
169
+ plan: 'free' | 'starter' | 'pro' | 'premium' | 'business';
170
+ default_payment_method: {
171
+ brand: string | null;
172
+ last4: string | null;
173
+ exp_month: number | null;
174
+ exp_year: number | null;
175
+ } | null;
176
+ addons: {
177
+ [key: string]: {
178
+ quantity: number;
179
+ };
180
+ };
181
+ } | null;
182
+ };
183
+
184
+ export type GetResponse = GetResponses[keyof GetResponses];
185
+
186
+ export type Update2Data = {
187
+ body?: {
188
+ plan: 'free' | 'starter' | 'pro' | 'premium' | 'business';
189
+ billing_period: 'month' | 'year';
190
+ };
191
+ path?: never;
192
+ query?: never;
193
+ url: '/billing/subscription';
194
+ };
195
+
196
+ export type Update2Responses = {
197
+ /**
198
+ * Response
199
+ */
200
+ 200: {
201
+ status: 'confirmation_required' | 'success' | 'payment_failed';
202
+ client_secret?: string;
203
+ failure_code?: string;
204
+ };
205
+ };
206
+
207
+ export type Update2Response = Update2Responses[keyof Update2Responses];
208
+
209
+ export type PreviewUpdate2Data = {
210
+ body?: {
211
+ plan: 'free' | 'starter' | 'pro' | 'premium' | 'business';
212
+ billing_period: 'month' | 'year';
213
+ };
214
+ path?: never;
215
+ query?: never;
216
+ url: '/billing/subscription/preview';
217
+ };
218
+
219
+ export type PreviewUpdate2Responses = {
220
+ /**
221
+ * Response
222
+ */
223
+ 200: {
224
+ discount_percents: Array<number>;
225
+ total_excluding_tax: number;
226
+ total: number;
227
+ amount_due: number;
228
+ added_from_balance: number;
229
+ consumed_balance: number;
230
+ credited_to_balance: number;
231
+ lines: Array<{
232
+ amount: number;
233
+ billing_period: 'day' | 'week' | 'month' | 'year';
234
+ proration: boolean;
235
+ plan?: 'free' | 'starter' | 'pro' | 'premium' | 'business';
236
+ addon?: 'senders' | 'email_warmups';
237
+ }>;
238
+ next_renewal: number;
239
+ total_tax_amounts: Array<{
240
+ amount: number;
241
+ }>;
242
+ };
243
+ };
244
+
245
+ export type PreviewUpdate2Response = PreviewUpdate2Responses[keyof PreviewUpdate2Responses];