@stigg/typescript 0.1.0-alpha.4 → 0.1.0-alpha.7
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.
- package/CHANGELOG.md +53 -0
- package/README.md +9 -0
- package/client.d.mts +4 -6
- package/client.d.mts.map +1 -1
- package/client.d.ts +4 -6
- package/client.d.ts.map +1 -1
- package/client.js +16 -21
- package/client.js.map +1 -1
- package/client.mjs +16 -21
- package/client.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/qs/formats.d.mts +7 -0
- package/internal/qs/formats.d.mts.map +1 -0
- package/internal/qs/formats.d.ts +7 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +13 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +9 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.mts +10 -0
- package/internal/qs/index.d.mts.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +14 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +10 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.mts +3 -0
- package/internal/qs/stringify.d.mts.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +277 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +274 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.mts +57 -0
- package/internal/qs/types.d.mts.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +3 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +2 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.mts +15 -0
- package/internal/qs/utils.d.mts.map +1 -0
- package/internal/qs/utils.d.ts +15 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +230 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +217 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/package.json +1 -1
- package/resources/v1/coupons.d.mts +49 -7
- package/resources/v1/coupons.d.mts.map +1 -1
- package/resources/v1/coupons.d.ts +49 -7
- package/resources/v1/coupons.d.ts.map +1 -1
- package/resources/v1/coupons.js +4 -3
- package/resources/v1/coupons.js.map +1 -1
- package/resources/v1/coupons.mjs +4 -3
- package/resources/v1/coupons.mjs.map +1 -1
- package/resources/v1/customers/customers.d.mts +72 -8
- package/resources/v1/customers/customers.d.mts.map +1 -1
- package/resources/v1/customers/customers.d.ts +72 -8
- package/resources/v1/customers/customers.d.ts.map +1 -1
- package/resources/v1/customers/customers.js +18 -7
- package/resources/v1/customers/customers.js.map +1 -1
- package/resources/v1/customers/customers.mjs +18 -7
- package/resources/v1/customers/customers.mjs.map +1 -1
- package/resources/v1/customers/index.d.mts +1 -1
- package/resources/v1/customers/index.d.mts.map +1 -1
- package/resources/v1/customers/index.d.ts +1 -1
- package/resources/v1/customers/index.d.ts.map +1 -1
- package/resources/v1/customers/index.js.map +1 -1
- package/resources/v1/customers/index.mjs.map +1 -1
- package/resources/v1/customers/payment-method.d.mts +4 -2
- package/resources/v1/customers/payment-method.d.mts.map +1 -1
- package/resources/v1/customers/payment-method.d.ts +4 -2
- package/resources/v1/customers/payment-method.d.ts.map +1 -1
- package/resources/v1/customers/payment-method.js +4 -2
- package/resources/v1/customers/payment-method.js.map +1 -1
- package/resources/v1/customers/payment-method.mjs +4 -2
- package/resources/v1/customers/payment-method.mjs.map +1 -1
- package/resources/v1/customers/promotional-entitlements.d.mts +4 -2
- package/resources/v1/customers/promotional-entitlements.d.mts.map +1 -1
- package/resources/v1/customers/promotional-entitlements.d.ts +4 -2
- package/resources/v1/customers/promotional-entitlements.d.ts.map +1 -1
- package/resources/v1/customers/promotional-entitlements.js +4 -2
- package/resources/v1/customers/promotional-entitlements.js.map +1 -1
- package/resources/v1/customers/promotional-entitlements.mjs +4 -2
- package/resources/v1/customers/promotional-entitlements.mjs.map +1 -1
- package/resources/v1/events.d.mts +2 -1
- package/resources/v1/events.d.mts.map +1 -1
- package/resources/v1/events.d.ts +2 -1
- package/resources/v1/events.d.ts.map +1 -1
- package/resources/v1/events.js +2 -1
- package/resources/v1/events.js.map +1 -1
- package/resources/v1/events.mjs +2 -1
- package/resources/v1/events.mjs.map +1 -1
- package/resources/v1/index.d.mts +2 -1
- package/resources/v1/index.d.mts.map +1 -1
- package/resources/v1/index.d.ts +2 -1
- package/resources/v1/index.d.ts.map +1 -1
- package/resources/v1/index.js +3 -1
- package/resources/v1/index.js.map +1 -1
- package/resources/v1/index.mjs +1 -0
- package/resources/v1/index.mjs.map +1 -1
- package/resources/v1/products.d.mts +126 -0
- package/resources/v1/products.d.mts.map +1 -0
- package/resources/v1/products.d.ts +126 -0
- package/resources/v1/products.d.ts.map +1 -0
- package/resources/v1/products.js +19 -0
- package/resources/v1/products.js.map +1 -0
- package/resources/v1/products.mjs +15 -0
- package/resources/v1/products.mjs.map +1 -0
- package/resources/v1/subscriptions/future-update.d.mts +3 -2
- package/resources/v1/subscriptions/future-update.d.mts.map +1 -1
- package/resources/v1/subscriptions/future-update.d.ts +3 -2
- package/resources/v1/subscriptions/future-update.d.ts.map +1 -1
- package/resources/v1/subscriptions/future-update.js +3 -2
- package/resources/v1/subscriptions/future-update.js.map +1 -1
- package/resources/v1/subscriptions/future-update.mjs +3 -2
- package/resources/v1/subscriptions/future-update.mjs.map +1 -1
- package/resources/v1/subscriptions/subscriptions.d.mts +158 -34
- package/resources/v1/subscriptions/subscriptions.d.mts.map +1 -1
- package/resources/v1/subscriptions/subscriptions.d.ts +158 -34
- package/resources/v1/subscriptions/subscriptions.d.ts.map +1 -1
- package/resources/v1/subscriptions/subscriptions.js +20 -10
- package/resources/v1/subscriptions/subscriptions.js.map +1 -1
- package/resources/v1/subscriptions/subscriptions.mjs +20 -10
- package/resources/v1/subscriptions/subscriptions.mjs.map +1 -1
- package/resources/v1/usage.d.mts +3 -2
- package/resources/v1/usage.d.mts.map +1 -1
- package/resources/v1/usage.d.ts +3 -2
- package/resources/v1/usage.d.ts.map +1 -1
- package/resources/v1/usage.js +3 -2
- package/resources/v1/usage.js.map +1 -1
- package/resources/v1/usage.mjs +3 -2
- package/resources/v1/usage.mjs.map +1 -1
- package/resources/v1/v1.d.mts +6 -2
- package/resources/v1/v1.d.mts.map +1 -1
- package/resources/v1/v1.d.ts +6 -2
- package/resources/v1/v1.d.ts.map +1 -1
- package/resources/v1/v1.js +4 -0
- package/resources/v1/v1.js.map +1 -1
- package/resources/v1/v1.mjs +4 -0
- package/resources/v1/v1.mjs.map +1 -1
- package/src/client.ts +23 -26
- package/src/internal/parse.ts +6 -0
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +10 -0
- package/src/internal/qs/index.ts +13 -0
- package/src/internal/qs/stringify.ts +385 -0
- package/src/internal/qs/types.ts +71 -0
- package/src/internal/qs/utils.ts +265 -0
- package/src/resources/v1/coupons.ts +57 -9
- package/src/resources/v1/customers/customers.ts +97 -8
- package/src/resources/v1/customers/index.ts +3 -0
- package/src/resources/v1/customers/payment-method.ts +4 -2
- package/src/resources/v1/customers/promotional-entitlements.ts +4 -2
- package/src/resources/v1/events.ts +2 -1
- package/src/resources/v1/index.ts +9 -0
- package/src/resources/v1/products.ts +162 -0
- package/src/resources/v1/subscriptions/future-update.ts +3 -2
- package/src/resources/v1/subscriptions/subscriptions.ts +218 -36
- package/src/resources/v1/usage.ts +3 -2
- package/src/resources/v1/v1.ts +22 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { RFC1738 } from './formats';
|
|
2
|
+
import type { DefaultEncoder, Format } from './types';
|
|
3
|
+
import { isArray } from '../utils/values';
|
|
4
|
+
|
|
5
|
+
export let has = (obj: object, key: PropertyKey): boolean => (
|
|
6
|
+
(has = (Object as any).hasOwn ?? Function.prototype.call.bind(Object.prototype.hasOwnProperty)),
|
|
7
|
+
has(obj, key)
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const hex_table = /* @__PURE__ */ (() => {
|
|
11
|
+
const array = [];
|
|
12
|
+
for (let i = 0; i < 256; ++i) {
|
|
13
|
+
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return array;
|
|
17
|
+
})();
|
|
18
|
+
|
|
19
|
+
function compact_queue<T extends Record<string, any>>(queue: Array<{ obj: T; prop: string }>) {
|
|
20
|
+
while (queue.length > 1) {
|
|
21
|
+
const item = queue.pop();
|
|
22
|
+
if (!item) continue;
|
|
23
|
+
|
|
24
|
+
const obj = item.obj[item.prop];
|
|
25
|
+
|
|
26
|
+
if (isArray(obj)) {
|
|
27
|
+
const compacted: unknown[] = [];
|
|
28
|
+
|
|
29
|
+
for (let j = 0; j < obj.length; ++j) {
|
|
30
|
+
if (typeof obj[j] !== 'undefined') {
|
|
31
|
+
compacted.push(obj[j]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
item.obj[item.prop] = compacted;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function array_to_object(source: any[], options: { plainObjects: boolean }) {
|
|
42
|
+
const obj = options && options.plainObjects ? Object.create(null) : {};
|
|
43
|
+
for (let i = 0; i < source.length; ++i) {
|
|
44
|
+
if (typeof source[i] !== 'undefined') {
|
|
45
|
+
obj[i] = source[i];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return obj;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function merge(
|
|
53
|
+
target: any,
|
|
54
|
+
source: any,
|
|
55
|
+
options: { plainObjects?: boolean; allowPrototypes?: boolean } = {},
|
|
56
|
+
) {
|
|
57
|
+
if (!source) {
|
|
58
|
+
return target;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (typeof source !== 'object') {
|
|
62
|
+
if (isArray(target)) {
|
|
63
|
+
target.push(source);
|
|
64
|
+
} else if (target && typeof target === 'object') {
|
|
65
|
+
if ((options && (options.plainObjects || options.allowPrototypes)) || !has(Object.prototype, source)) {
|
|
66
|
+
target[source] = true;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
return [target, source];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return target;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!target || typeof target !== 'object') {
|
|
76
|
+
return [target].concat(source);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let mergeTarget = target;
|
|
80
|
+
if (isArray(target) && !isArray(source)) {
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
mergeTarget = array_to_object(target, options);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (isArray(target) && isArray(source)) {
|
|
86
|
+
source.forEach(function (item, i) {
|
|
87
|
+
if (has(target, i)) {
|
|
88
|
+
const targetItem = target[i];
|
|
89
|
+
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
90
|
+
target[i] = merge(targetItem, item, options);
|
|
91
|
+
} else {
|
|
92
|
+
target.push(item);
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
target[i] = item;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
102
|
+
const value = source[key];
|
|
103
|
+
|
|
104
|
+
if (has(acc, key)) {
|
|
105
|
+
acc[key] = merge(acc[key], value, options);
|
|
106
|
+
} else {
|
|
107
|
+
acc[key] = value;
|
|
108
|
+
}
|
|
109
|
+
return acc;
|
|
110
|
+
}, mergeTarget);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function assign_single_source(target: any, source: any) {
|
|
114
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
115
|
+
acc[key] = source[key];
|
|
116
|
+
return acc;
|
|
117
|
+
}, target);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function decode(str: string, _: any, charset: string) {
|
|
121
|
+
const strWithoutPlus = str.replace(/\+/g, ' ');
|
|
122
|
+
if (charset === 'iso-8859-1') {
|
|
123
|
+
// unescape never throws, no try...catch needed:
|
|
124
|
+
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
|
125
|
+
}
|
|
126
|
+
// utf-8
|
|
127
|
+
try {
|
|
128
|
+
return decodeURIComponent(strWithoutPlus);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return strWithoutPlus;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const limit = 1024;
|
|
135
|
+
|
|
136
|
+
export const encode: (
|
|
137
|
+
str: any,
|
|
138
|
+
defaultEncoder: DefaultEncoder,
|
|
139
|
+
charset: string,
|
|
140
|
+
type: 'key' | 'value',
|
|
141
|
+
format: Format,
|
|
142
|
+
) => string = (str, _defaultEncoder, charset, _kind, format: Format) => {
|
|
143
|
+
// This code was originally written by Brian White for the io.js core querystring library.
|
|
144
|
+
// It has been adapted here for stricter adherence to RFC 3986
|
|
145
|
+
if (str.length === 0) {
|
|
146
|
+
return str;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let string = str;
|
|
150
|
+
if (typeof str === 'symbol') {
|
|
151
|
+
string = Symbol.prototype.toString.call(str);
|
|
152
|
+
} else if (typeof str !== 'string') {
|
|
153
|
+
string = String(str);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (charset === 'iso-8859-1') {
|
|
157
|
+
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
|
158
|
+
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let out = '';
|
|
163
|
+
for (let j = 0; j < string.length; j += limit) {
|
|
164
|
+
const segment = string.length >= limit ? string.slice(j, j + limit) : string;
|
|
165
|
+
const arr = [];
|
|
166
|
+
|
|
167
|
+
for (let i = 0; i < segment.length; ++i) {
|
|
168
|
+
let c = segment.charCodeAt(i);
|
|
169
|
+
if (
|
|
170
|
+
c === 0x2d || // -
|
|
171
|
+
c === 0x2e || // .
|
|
172
|
+
c === 0x5f || // _
|
|
173
|
+
c === 0x7e || // ~
|
|
174
|
+
(c >= 0x30 && c <= 0x39) || // 0-9
|
|
175
|
+
(c >= 0x41 && c <= 0x5a) || // a-z
|
|
176
|
+
(c >= 0x61 && c <= 0x7a) || // A-Z
|
|
177
|
+
(format === RFC1738 && (c === 0x28 || c === 0x29)) // ( )
|
|
178
|
+
) {
|
|
179
|
+
arr[arr.length] = segment.charAt(i);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (c < 0x80) {
|
|
184
|
+
arr[arr.length] = hex_table[c];
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (c < 0x800) {
|
|
189
|
+
arr[arr.length] = hex_table[0xc0 | (c >> 6)]! + hex_table[0x80 | (c & 0x3f)];
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (c < 0xd800 || c >= 0xe000) {
|
|
194
|
+
arr[arr.length] =
|
|
195
|
+
hex_table[0xe0 | (c >> 12)]! + hex_table[0x80 | ((c >> 6) & 0x3f)] + hex_table[0x80 | (c & 0x3f)];
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
i += 1;
|
|
200
|
+
c = 0x10000 + (((c & 0x3ff) << 10) | (segment.charCodeAt(i) & 0x3ff));
|
|
201
|
+
|
|
202
|
+
arr[arr.length] =
|
|
203
|
+
hex_table[0xf0 | (c >> 18)]! +
|
|
204
|
+
hex_table[0x80 | ((c >> 12) & 0x3f)] +
|
|
205
|
+
hex_table[0x80 | ((c >> 6) & 0x3f)] +
|
|
206
|
+
hex_table[0x80 | (c & 0x3f)];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
out += arr.join('');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return out;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export function compact(value: any) {
|
|
216
|
+
const queue = [{ obj: { o: value }, prop: 'o' }];
|
|
217
|
+
const refs = [];
|
|
218
|
+
|
|
219
|
+
for (let i = 0; i < queue.length; ++i) {
|
|
220
|
+
const item = queue[i];
|
|
221
|
+
// @ts-ignore
|
|
222
|
+
const obj = item.obj[item.prop];
|
|
223
|
+
|
|
224
|
+
const keys = Object.keys(obj);
|
|
225
|
+
for (let j = 0; j < keys.length; ++j) {
|
|
226
|
+
const key = keys[j]!;
|
|
227
|
+
const val = obj[key];
|
|
228
|
+
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
229
|
+
queue.push({ obj: obj, prop: key });
|
|
230
|
+
refs.push(val);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
compact_queue(queue);
|
|
236
|
+
|
|
237
|
+
return value;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function is_regexp(obj: any) {
|
|
241
|
+
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function is_buffer(obj: any) {
|
|
245
|
+
if (!obj || typeof obj !== 'object') {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function combine(a: any, b: any) {
|
|
253
|
+
return [].concat(a, b);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function maybe_map<T>(val: T[], fn: (v: T) => T) {
|
|
257
|
+
if (isArray(val)) {
|
|
258
|
+
const mapped = [];
|
|
259
|
+
for (let i = 0; i < val.length; i += 1) {
|
|
260
|
+
mapped.push(fn(val[i]!));
|
|
261
|
+
}
|
|
262
|
+
return mapped;
|
|
263
|
+
}
|
|
264
|
+
return fn(val);
|
|
265
|
+
}
|
|
@@ -8,21 +8,22 @@ import { path } from '../../internal/utils/path';
|
|
|
8
8
|
|
|
9
9
|
export class Coupons extends APIResource {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Creates a new discount coupon with percentage or fixed amount off, applicable to
|
|
12
|
+
* customer subscriptions.
|
|
12
13
|
*/
|
|
13
14
|
create(body: CouponCreateParams, options?: RequestOptions): APIPromise<Coupon> {
|
|
14
15
|
return this._client.post('/api/v1/coupons', { body, ...options });
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
|
-
*
|
|
19
|
+
* Retrieves a coupon by its unique identifier.
|
|
19
20
|
*/
|
|
20
21
|
retrieve(id: string, options?: RequestOptions): APIPromise<Coupon> {
|
|
21
22
|
return this._client.get(path`/api/v1/coupons/${id}`, options);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* Retrieves a paginated list of coupons in the environment.
|
|
26
27
|
*/
|
|
27
28
|
list(
|
|
28
29
|
query: CouponListParams | null | undefined = {},
|
|
@@ -476,6 +477,11 @@ export interface CouponCreateParams {
|
|
|
476
477
|
*/
|
|
477
478
|
durationInMonths: number | null;
|
|
478
479
|
|
|
480
|
+
/**
|
|
481
|
+
* Metadata associated with the entity
|
|
482
|
+
*/
|
|
483
|
+
metadata: { [key: string]: string } | null;
|
|
484
|
+
|
|
479
485
|
/**
|
|
480
486
|
* Name of the coupon
|
|
481
487
|
*/
|
|
@@ -485,11 +491,6 @@ export interface CouponCreateParams {
|
|
|
485
491
|
* Percentage discount off the original price
|
|
486
492
|
*/
|
|
487
493
|
percentOff: number | null;
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* Metadata associated with the entity
|
|
491
|
-
*/
|
|
492
|
-
additionalMetaData?: unknown;
|
|
493
494
|
}
|
|
494
495
|
|
|
495
496
|
export namespace CouponCreateParams {
|
|
@@ -625,7 +626,54 @@ export namespace CouponCreateParams {
|
|
|
625
626
|
}
|
|
626
627
|
}
|
|
627
628
|
|
|
628
|
-
export interface CouponListParams extends MyCursorIDPageParams {
|
|
629
|
+
export interface CouponListParams extends MyCursorIDPageParams {
|
|
630
|
+
/**
|
|
631
|
+
* Filter by entity ID
|
|
632
|
+
*/
|
|
633
|
+
id?: string;
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Filter by creation date using range operators: gt, gte, lt, lte
|
|
637
|
+
*/
|
|
638
|
+
createdAt?: CouponListParams.CreatedAt;
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Filter by coupon status. Supports comma-separated values for multiple statuses
|
|
642
|
+
*/
|
|
643
|
+
status?: string;
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Filter by coupon type (FIXED or PERCENTAGE)
|
|
647
|
+
*/
|
|
648
|
+
type?: 'FIXED' | 'PERCENTAGE';
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
export namespace CouponListParams {
|
|
652
|
+
/**
|
|
653
|
+
* Filter by creation date using range operators: gt, gte, lt, lte
|
|
654
|
+
*/
|
|
655
|
+
export interface CreatedAt {
|
|
656
|
+
/**
|
|
657
|
+
* Greater than the specified createdAt value
|
|
658
|
+
*/
|
|
659
|
+
gt?: string;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Greater than or equal to the specified createdAt value
|
|
663
|
+
*/
|
|
664
|
+
gte?: string;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Less than the specified createdAt value
|
|
668
|
+
*/
|
|
669
|
+
lt?: string;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Less than or equal to the specified createdAt value
|
|
673
|
+
*/
|
|
674
|
+
lte?: string;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
629
677
|
|
|
630
678
|
export declare namespace Coupons {
|
|
631
679
|
export {
|
|
@@ -22,21 +22,23 @@ export class Customers extends APIResource {
|
|
|
22
22
|
new PromotionalEntitlementsAPI.PromotionalEntitlements(this._client);
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Retrieves a customer by their unique identifier, including billing information
|
|
26
|
+
* and subscription status.
|
|
26
27
|
*/
|
|
27
28
|
retrieve(id: string, options?: RequestOptions): APIPromise<CustomerResponse> {
|
|
28
29
|
return this._client.get(path`/api/v1/customers/${id}`, options);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
|
-
*
|
|
33
|
+
* Updates an existing customer's properties such as name, email, and billing
|
|
34
|
+
* information.
|
|
33
35
|
*/
|
|
34
36
|
update(id: string, body: CustomerUpdateParams, options?: RequestOptions): APIPromise<CustomerResponse> {
|
|
35
37
|
return this._client.patch(path`/api/v1/customers/${id}`, { body, ...options });
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
|
-
*
|
|
41
|
+
* Retrieves a paginated list of customers in the environment.
|
|
40
42
|
*/
|
|
41
43
|
list(
|
|
42
44
|
query: CustomerListParams | null | undefined = {},
|
|
@@ -49,28 +51,46 @@ export class Customers extends APIResource {
|
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
/**
|
|
52
|
-
*
|
|
54
|
+
* Archives a customer, preventing new subscriptions. Optionally cancels existing
|
|
55
|
+
* subscriptions.
|
|
53
56
|
*/
|
|
54
57
|
archive(id: string, options?: RequestOptions): APIPromise<CustomerResponse> {
|
|
55
58
|
return this._client.post(path`/api/v1/customers/${id}/archive`, options);
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
/**
|
|
59
|
-
*
|
|
62
|
+
* Imports multiple customers in bulk. Used for migrating customer data from
|
|
63
|
+
* external systems.
|
|
60
64
|
*/
|
|
61
65
|
import(body: CustomerImportParams, options?: RequestOptions): APIPromise<CustomerImportResponse> {
|
|
62
66
|
return this._client.post('/api/v1/customers/import', { body, ...options });
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
/**
|
|
66
|
-
*
|
|
70
|
+
* Get a list of customerresources
|
|
71
|
+
*/
|
|
72
|
+
listResources(
|
|
73
|
+
id: string,
|
|
74
|
+
query: CustomerListResourcesParams | null | undefined = {},
|
|
75
|
+
options?: RequestOptions,
|
|
76
|
+
): PagePromise<CustomerListResourcesResponsesMyCursorIDPage, CustomerListResourcesResponse> {
|
|
77
|
+
return this._client.getAPIList(
|
|
78
|
+
path`/api/v1/customers/${id}/resources`,
|
|
79
|
+
MyCursorIDPage<CustomerListResourcesResponse>,
|
|
80
|
+
{ query, ...options },
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Creates a new customer and optionally provisions an initial subscription in a
|
|
86
|
+
* single operation.
|
|
67
87
|
*/
|
|
68
88
|
provision(body: CustomerProvisionParams, options?: RequestOptions): APIPromise<CustomerResponse> {
|
|
69
89
|
return this._client.post('/api/v1/customers', { body, ...options });
|
|
70
90
|
}
|
|
71
91
|
|
|
72
92
|
/**
|
|
73
|
-
*
|
|
93
|
+
* Restores an archived customer, allowing them to create new subscriptions again.
|
|
74
94
|
*/
|
|
75
95
|
unarchive(id: string, options?: RequestOptions): APIPromise<CustomerResponse> {
|
|
76
96
|
return this._client.post(path`/api/v1/customers/${id}/unarchive`, options);
|
|
@@ -79,6 +99,8 @@ export class Customers extends APIResource {
|
|
|
79
99
|
|
|
80
100
|
export type CustomerListResponsesMyCursorIDPage = MyCursorIDPage<CustomerListResponse>;
|
|
81
101
|
|
|
102
|
+
export type CustomerListResourcesResponsesMyCursorIDPage = MyCursorIDPage<CustomerListResourcesResponse>;
|
|
103
|
+
|
|
82
104
|
/**
|
|
83
105
|
* Response object
|
|
84
106
|
*/
|
|
@@ -347,6 +369,26 @@ export namespace CustomerImportResponse {
|
|
|
347
369
|
}
|
|
348
370
|
}
|
|
349
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Resource object that belongs to a customer
|
|
374
|
+
*/
|
|
375
|
+
export interface CustomerListResourcesResponse {
|
|
376
|
+
/**
|
|
377
|
+
* Resource slug
|
|
378
|
+
*/
|
|
379
|
+
id: string;
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Timestamp of when the record was created
|
|
383
|
+
*/
|
|
384
|
+
createdAt: string;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Timestamp of when the record was last updated
|
|
388
|
+
*/
|
|
389
|
+
updatedAt: string;
|
|
390
|
+
}
|
|
391
|
+
|
|
350
392
|
export interface CustomerUpdateParams {
|
|
351
393
|
/**
|
|
352
394
|
* Customer level coupon
|
|
@@ -406,7 +448,49 @@ export namespace CustomerUpdateParams {
|
|
|
406
448
|
}
|
|
407
449
|
}
|
|
408
450
|
|
|
409
|
-
export interface CustomerListParams extends MyCursorIDPageParams {
|
|
451
|
+
export interface CustomerListParams extends MyCursorIDPageParams {
|
|
452
|
+
/**
|
|
453
|
+
* Filter by creation date using range operators: gt, gte, lt, lte
|
|
454
|
+
*/
|
|
455
|
+
createdAt?: CustomerListParams.CreatedAt;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Filter by exact customer email address
|
|
459
|
+
*/
|
|
460
|
+
email?: string;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Filter by exact customer name
|
|
464
|
+
*/
|
|
465
|
+
name?: string;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export namespace CustomerListParams {
|
|
469
|
+
/**
|
|
470
|
+
* Filter by creation date using range operators: gt, gte, lt, lte
|
|
471
|
+
*/
|
|
472
|
+
export interface CreatedAt {
|
|
473
|
+
/**
|
|
474
|
+
* Greater than the specified createdAt value
|
|
475
|
+
*/
|
|
476
|
+
gt?: string;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Greater than or equal to the specified createdAt value
|
|
480
|
+
*/
|
|
481
|
+
gte?: string;
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Less than the specified createdAt value
|
|
485
|
+
*/
|
|
486
|
+
lt?: string;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Less than or equal to the specified createdAt value
|
|
490
|
+
*/
|
|
491
|
+
lte?: string;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
410
494
|
|
|
411
495
|
export interface CustomerImportParams {
|
|
412
496
|
/**
|
|
@@ -449,6 +533,8 @@ export namespace CustomerImportParams {
|
|
|
449
533
|
}
|
|
450
534
|
}
|
|
451
535
|
|
|
536
|
+
export interface CustomerListResourcesParams extends MyCursorIDPageParams {}
|
|
537
|
+
|
|
452
538
|
export interface CustomerProvisionParams {
|
|
453
539
|
/**
|
|
454
540
|
* Customer slug
|
|
@@ -556,10 +642,13 @@ export declare namespace Customers {
|
|
|
556
642
|
type CustomerResponse as CustomerResponse,
|
|
557
643
|
type CustomerListResponse as CustomerListResponse,
|
|
558
644
|
type CustomerImportResponse as CustomerImportResponse,
|
|
645
|
+
type CustomerListResourcesResponse as CustomerListResourcesResponse,
|
|
559
646
|
type CustomerListResponsesMyCursorIDPage as CustomerListResponsesMyCursorIDPage,
|
|
647
|
+
type CustomerListResourcesResponsesMyCursorIDPage as CustomerListResourcesResponsesMyCursorIDPage,
|
|
560
648
|
type CustomerUpdateParams as CustomerUpdateParams,
|
|
561
649
|
type CustomerListParams as CustomerListParams,
|
|
562
650
|
type CustomerImportParams as CustomerImportParams,
|
|
651
|
+
type CustomerListResourcesParams as CustomerListResourcesParams,
|
|
563
652
|
type CustomerProvisionParams as CustomerProvisionParams,
|
|
564
653
|
};
|
|
565
654
|
|
|
@@ -5,11 +5,14 @@ export {
|
|
|
5
5
|
type CustomerResponse,
|
|
6
6
|
type CustomerListResponse,
|
|
7
7
|
type CustomerImportResponse,
|
|
8
|
+
type CustomerListResourcesResponse,
|
|
8
9
|
type CustomerUpdateParams,
|
|
9
10
|
type CustomerListParams,
|
|
10
11
|
type CustomerImportParams,
|
|
12
|
+
type CustomerListResourcesParams,
|
|
11
13
|
type CustomerProvisionParams,
|
|
12
14
|
type CustomerListResponsesMyCursorIDPage,
|
|
15
|
+
type CustomerListResourcesResponsesMyCursorIDPage,
|
|
13
16
|
} from './customers';
|
|
14
17
|
export { PaymentMethod, type PaymentMethodAttachParams } from './payment-method';
|
|
15
18
|
export {
|
|
@@ -8,7 +8,8 @@ import { path } from '../../../internal/utils/path';
|
|
|
8
8
|
|
|
9
9
|
export class PaymentMethod extends APIResource {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Attaches a payment method to a customer for billing. Required for paid
|
|
12
|
+
* subscriptions when integrated with a billing provider.
|
|
12
13
|
*/
|
|
13
14
|
attach(
|
|
14
15
|
id: string,
|
|
@@ -19,7 +20,8 @@ export class PaymentMethod extends APIResource {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* Removes the payment method from a customer. Ensure active paid subscriptions
|
|
24
|
+
* have an alternative payment method.
|
|
23
25
|
*/
|
|
24
26
|
detach(id: string, options?: RequestOptions): APIPromise<CustomersAPI.CustomerResponse> {
|
|
25
27
|
return this._client.delete(path`/api/v1/customers/${id}/payment-method`, options);
|
|
@@ -7,7 +7,8 @@ import { path } from '../../../internal/utils/path';
|
|
|
7
7
|
|
|
8
8
|
export class PromotionalEntitlements extends APIResource {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Grants promotional entitlements to a customer, providing feature access outside
|
|
11
|
+
* their subscription. Entitlements can be time-limited or permanent.
|
|
11
12
|
*/
|
|
12
13
|
grant(
|
|
13
14
|
customerID: string,
|
|
@@ -18,7 +19,8 @@ export class PromotionalEntitlements extends APIResource {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* Revokes a previously granted promotional entitlement from a customer for a
|
|
23
|
+
* specific feature.
|
|
22
24
|
*/
|
|
23
25
|
revoke(
|
|
24
26
|
featureID: string,
|
|
@@ -6,7 +6,8 @@ import { RequestOptions } from '../../internal/request-options';
|
|
|
6
6
|
|
|
7
7
|
export class Events extends APIResource {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Reports raw usage events for event-based metering. Events are ingested
|
|
10
|
+
* asynchronously and aggregated into usage totals.
|
|
10
11
|
*/
|
|
11
12
|
report(body: EventReportParams, options?: RequestOptions): APIPromise<EventReportResponse> {
|
|
12
13
|
return this._client.post('/api/v1/events', { body, ...options });
|
|
@@ -13,13 +13,22 @@ export {
|
|
|
13
13
|
type CustomerResponse,
|
|
14
14
|
type CustomerListResponse,
|
|
15
15
|
type CustomerImportResponse,
|
|
16
|
+
type CustomerListResourcesResponse,
|
|
16
17
|
type CustomerUpdateParams,
|
|
17
18
|
type CustomerListParams,
|
|
18
19
|
type CustomerImportParams,
|
|
20
|
+
type CustomerListResourcesParams,
|
|
19
21
|
type CustomerProvisionParams,
|
|
20
22
|
type CustomerListResponsesMyCursorIDPage,
|
|
23
|
+
type CustomerListResourcesResponsesMyCursorIDPage,
|
|
21
24
|
} from './customers/index';
|
|
22
25
|
export { Events, type EventReportResponse, type EventReportParams } from './events';
|
|
26
|
+
export {
|
|
27
|
+
Products,
|
|
28
|
+
type ProductListProductsResponse,
|
|
29
|
+
type ProductListProductsParams,
|
|
30
|
+
type ProductListProductsResponsesMyCursorIDPage,
|
|
31
|
+
} from './products';
|
|
23
32
|
export {
|
|
24
33
|
Subscriptions,
|
|
25
34
|
type Subscription,
|