pocketsflow 1.0.0
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/README.md +354 -0
- package/dist/index.d.mts +483 -0
- package/dist/index.d.ts +483 -0
- package/dist/index.js +337 -0
- package/dist/index.mjs +309 -0
- package/package.json +52 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Pocketsflow: () => Pocketsflow,
|
|
24
|
+
PocketsflowError: () => PocketsflowError
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
|
|
28
|
+
// src/types.ts
|
|
29
|
+
var PocketsflowError = class extends Error {
|
|
30
|
+
constructor(message, code, status) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "PocketsflowError";
|
|
33
|
+
this.code = code;
|
|
34
|
+
this.status = status;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/client.ts
|
|
39
|
+
var DEFAULT_BASE_URL = "https://api.pocketsflow.com";
|
|
40
|
+
var DEFAULT_TIMEOUT = 3e4;
|
|
41
|
+
var Pocketsflow = class {
|
|
42
|
+
constructor(config) {
|
|
43
|
+
if (!config.apiKey) {
|
|
44
|
+
throw new PocketsflowError("API key is required");
|
|
45
|
+
}
|
|
46
|
+
this.apiKey = config.apiKey;
|
|
47
|
+
this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
|
|
48
|
+
this.timeout = config.timeout || DEFAULT_TIMEOUT;
|
|
49
|
+
this.products = new ProductsResource(this);
|
|
50
|
+
this.variants = new VariantsResource(this);
|
|
51
|
+
this.orders = new OrdersResource(this);
|
|
52
|
+
this.customers = new CustomersResource(this);
|
|
53
|
+
this.reviews = new ReviewsResource(this);
|
|
54
|
+
this.discounts = new DiscountsResource(this);
|
|
55
|
+
this.upsells = new UpsellsResource(this);
|
|
56
|
+
this.subscriptions = new SubscriptionsResource(this);
|
|
57
|
+
this.webhooks = new WebhooksResource(this);
|
|
58
|
+
this.users = new UsersResource(this);
|
|
59
|
+
this.checkout = new CheckoutResource(this);
|
|
60
|
+
this.refunds = new RefundsResource(this);
|
|
61
|
+
}
|
|
62
|
+
async request(method, path, options = {}) {
|
|
63
|
+
const url = new URL(path, this.baseUrl);
|
|
64
|
+
if (options.params) {
|
|
65
|
+
Object.entries(options.params).forEach(([key, value]) => {
|
|
66
|
+
if (value !== void 0 && value !== null) {
|
|
67
|
+
url.searchParams.append(key, String(value));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const controller = new AbortController();
|
|
72
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
73
|
+
try {
|
|
74
|
+
const response = await fetch(url.toString(), {
|
|
75
|
+
method,
|
|
76
|
+
headers: {
|
|
77
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
78
|
+
"Content-Type": "application/json"
|
|
79
|
+
},
|
|
80
|
+
body: options.body ? JSON.stringify(options.body) : void 0,
|
|
81
|
+
signal: controller.signal
|
|
82
|
+
});
|
|
83
|
+
clearTimeout(timeoutId);
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
let errorMessage = "Request failed";
|
|
86
|
+
let errorCode;
|
|
87
|
+
try {
|
|
88
|
+
const errorBody = await response.json();
|
|
89
|
+
errorMessage = errorBody.message || errorBody.error || errorMessage;
|
|
90
|
+
errorCode = errorBody.code;
|
|
91
|
+
} catch {
|
|
92
|
+
}
|
|
93
|
+
throw new PocketsflowError(errorMessage, errorCode, response.status);
|
|
94
|
+
}
|
|
95
|
+
const text = await response.text();
|
|
96
|
+
if (!text) {
|
|
97
|
+
return {};
|
|
98
|
+
}
|
|
99
|
+
return JSON.parse(text);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
clearTimeout(timeoutId);
|
|
102
|
+
if (error instanceof PocketsflowError) {
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
if (error instanceof Error) {
|
|
106
|
+
if (error.name === "AbortError") {
|
|
107
|
+
throw new PocketsflowError("Request timeout", "TIMEOUT");
|
|
108
|
+
}
|
|
109
|
+
throw new PocketsflowError(error.message);
|
|
110
|
+
}
|
|
111
|
+
throw new PocketsflowError("Unknown error occurred");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var ProductsResource = class {
|
|
116
|
+
constructor(client) {
|
|
117
|
+
this.client = client;
|
|
118
|
+
}
|
|
119
|
+
/** List all products */
|
|
120
|
+
async list() {
|
|
121
|
+
return this.client.request("GET", "/products");
|
|
122
|
+
}
|
|
123
|
+
/** Get a product by ID */
|
|
124
|
+
async get(id) {
|
|
125
|
+
return this.client.request("GET", `/products/${id}`);
|
|
126
|
+
}
|
|
127
|
+
/** Create a new product */
|
|
128
|
+
async create(params) {
|
|
129
|
+
return this.client.request("POST", "/products", { body: params });
|
|
130
|
+
}
|
|
131
|
+
/** Update a product */
|
|
132
|
+
async update(id, params) {
|
|
133
|
+
return this.client.request("POST", `/products/update/${id}`, { body: params });
|
|
134
|
+
}
|
|
135
|
+
/** Delete a product */
|
|
136
|
+
async delete(id) {
|
|
137
|
+
return this.client.request("DELETE", `/products/${id}`);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var VariantsResource = class {
|
|
141
|
+
constructor(client) {
|
|
142
|
+
this.client = client;
|
|
143
|
+
}
|
|
144
|
+
/** Create a product variant */
|
|
145
|
+
async create(params) {
|
|
146
|
+
return this.client.request("POST", "/products/variants", { body: params });
|
|
147
|
+
}
|
|
148
|
+
/** Delete a product variant */
|
|
149
|
+
async delete(id) {
|
|
150
|
+
return this.client.request("DELETE", `/products/variants/${id}`);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
var OrdersResource = class {
|
|
154
|
+
constructor(client) {
|
|
155
|
+
this.client = client;
|
|
156
|
+
}
|
|
157
|
+
/** List all orders with optional filters */
|
|
158
|
+
async list(params = {}) {
|
|
159
|
+
return this.client.request("GET", "/orders", { params });
|
|
160
|
+
}
|
|
161
|
+
/** Get an order by ID */
|
|
162
|
+
async get(id) {
|
|
163
|
+
return this.client.request("GET", `/orders/${id}`);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
var CustomersResource = class {
|
|
167
|
+
constructor(client) {
|
|
168
|
+
this.client = client;
|
|
169
|
+
}
|
|
170
|
+
/** List all customers */
|
|
171
|
+
async list(params = {}) {
|
|
172
|
+
return this.client.request("GET", "/customers", { params });
|
|
173
|
+
}
|
|
174
|
+
/** Get a customer by ID */
|
|
175
|
+
async get(id) {
|
|
176
|
+
return this.client.request("GET", `/customers/${id}`);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
var ReviewsResource = class {
|
|
180
|
+
constructor(client) {
|
|
181
|
+
this.client = client;
|
|
182
|
+
}
|
|
183
|
+
/** List all reviews */
|
|
184
|
+
async list(params = {}) {
|
|
185
|
+
return this.client.request("GET", "/reviews", { params });
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
var DiscountsResource = class {
|
|
189
|
+
constructor(client) {
|
|
190
|
+
this.client = client;
|
|
191
|
+
}
|
|
192
|
+
/** List all discounts */
|
|
193
|
+
async list() {
|
|
194
|
+
return this.client.request("GET", "/discounts");
|
|
195
|
+
}
|
|
196
|
+
/** Get a discount by ID */
|
|
197
|
+
async get(id) {
|
|
198
|
+
return this.client.request("GET", `/discounts/${id}`);
|
|
199
|
+
}
|
|
200
|
+
/** Create a new discount */
|
|
201
|
+
async create(params) {
|
|
202
|
+
return this.client.request("POST", "/discounts", { body: params });
|
|
203
|
+
}
|
|
204
|
+
/** Update a discount */
|
|
205
|
+
async update(id, params) {
|
|
206
|
+
return this.client.request("POST", `/discounts/${id}`, { body: params });
|
|
207
|
+
}
|
|
208
|
+
/** Delete a discount */
|
|
209
|
+
async delete(id) {
|
|
210
|
+
return this.client.request("DELETE", `/discounts/${id}`);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
var UpsellsResource = class {
|
|
214
|
+
constructor(client) {
|
|
215
|
+
this.client = client;
|
|
216
|
+
}
|
|
217
|
+
/** List all upsells */
|
|
218
|
+
async list() {
|
|
219
|
+
return this.client.request("GET", "/upsells");
|
|
220
|
+
}
|
|
221
|
+
/** Get an upsell by ID */
|
|
222
|
+
async get(id) {
|
|
223
|
+
return this.client.request("GET", `/upsells/${id}`);
|
|
224
|
+
}
|
|
225
|
+
/** Create a new upsell */
|
|
226
|
+
async create(params) {
|
|
227
|
+
return this.client.request("POST", "/upsells", { body: params });
|
|
228
|
+
}
|
|
229
|
+
/** Update an upsell */
|
|
230
|
+
async update(id, params) {
|
|
231
|
+
return this.client.request("POST", `/upsells/${id}`, { body: params });
|
|
232
|
+
}
|
|
233
|
+
/** Delete an upsell */
|
|
234
|
+
async delete(id) {
|
|
235
|
+
return this.client.request("DELETE", `/upsells/${id}`);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
var SubscriptionsResource = class {
|
|
239
|
+
constructor(client) {
|
|
240
|
+
this.client = client;
|
|
241
|
+
}
|
|
242
|
+
/** List subscription customers */
|
|
243
|
+
async list(params = {}) {
|
|
244
|
+
return this.client.request("POST", "/orders/subscriptions", { body: params });
|
|
245
|
+
}
|
|
246
|
+
/** Get a subscription by ID */
|
|
247
|
+
async get(id) {
|
|
248
|
+
return this.client.request("GET", `/orders/subscriptions/${id}`);
|
|
249
|
+
}
|
|
250
|
+
/** Cancel a subscription */
|
|
251
|
+
async cancel(stripeSubscriptionId) {
|
|
252
|
+
return this.client.request(
|
|
253
|
+
"POST",
|
|
254
|
+
`/orders/subscriptions/cancel/${stripeSubscriptionId}`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
/** Refund a subscription */
|
|
258
|
+
async refund(stripeSubscriptionId) {
|
|
259
|
+
return this.client.request(
|
|
260
|
+
"POST",
|
|
261
|
+
`/orders/subscriptions/refund/${stripeSubscriptionId}`
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
var WebhooksResource = class {
|
|
266
|
+
constructor(client) {
|
|
267
|
+
this.client = client;
|
|
268
|
+
}
|
|
269
|
+
/** List all webhooks */
|
|
270
|
+
async list() {
|
|
271
|
+
return this.client.request("GET", "/webhooks");
|
|
272
|
+
}
|
|
273
|
+
/** Get a webhook by ID */
|
|
274
|
+
async get(id) {
|
|
275
|
+
return this.client.request("GET", `/webhooks/${id}`);
|
|
276
|
+
}
|
|
277
|
+
/** Create a new webhook */
|
|
278
|
+
async create(params) {
|
|
279
|
+
return this.client.request("POST", "/webhooks", { body: params });
|
|
280
|
+
}
|
|
281
|
+
/** Update a webhook */
|
|
282
|
+
async update(id, params) {
|
|
283
|
+
return this.client.request("PUT", `/webhooks/${id}`, { body: params });
|
|
284
|
+
}
|
|
285
|
+
/** Delete a webhook */
|
|
286
|
+
async delete(id) {
|
|
287
|
+
return this.client.request("DELETE", `/webhooks/${id}`);
|
|
288
|
+
}
|
|
289
|
+
/** Test a webhook */
|
|
290
|
+
async test(id) {
|
|
291
|
+
return this.client.request("POST", `/webhooks/${id}/test`);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
var UsersResource = class {
|
|
295
|
+
constructor(client) {
|
|
296
|
+
this.client = client;
|
|
297
|
+
}
|
|
298
|
+
/** Get current user information */
|
|
299
|
+
async me() {
|
|
300
|
+
return this.client.request("GET", "/users/me");
|
|
301
|
+
}
|
|
302
|
+
/** Update current user */
|
|
303
|
+
async update(params) {
|
|
304
|
+
return this.client.request("POST", "/users/update", { body: params });
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
var CheckoutResource = class {
|
|
308
|
+
constructor(client) {
|
|
309
|
+
this.client = client;
|
|
310
|
+
}
|
|
311
|
+
/** Create a checkout session */
|
|
312
|
+
async create(params) {
|
|
313
|
+
return this.client.request("POST", "/checkout/sessions", { body: params });
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
var RefundsResource = class {
|
|
317
|
+
constructor(client) {
|
|
318
|
+
this.client = client;
|
|
319
|
+
}
|
|
320
|
+
/** List all refunds */
|
|
321
|
+
async list() {
|
|
322
|
+
return this.client.request("GET", "/refunds");
|
|
323
|
+
}
|
|
324
|
+
/** Get a refund by ID */
|
|
325
|
+
async get(id) {
|
|
326
|
+
return this.client.request("GET", `/refunds/${id}`);
|
|
327
|
+
}
|
|
328
|
+
/** Create a refund */
|
|
329
|
+
async create(params) {
|
|
330
|
+
return this.client.request("POST", "/refunds", { body: params });
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
334
|
+
0 && (module.exports = {
|
|
335
|
+
Pocketsflow,
|
|
336
|
+
PocketsflowError
|
|
337
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
// src/types.ts
|
|
2
|
+
var PocketsflowError = class extends Error {
|
|
3
|
+
constructor(message, code, status) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "PocketsflowError";
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.status = status;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// src/client.ts
|
|
12
|
+
var DEFAULT_BASE_URL = "https://api.pocketsflow.com";
|
|
13
|
+
var DEFAULT_TIMEOUT = 3e4;
|
|
14
|
+
var Pocketsflow = class {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
if (!config.apiKey) {
|
|
17
|
+
throw new PocketsflowError("API key is required");
|
|
18
|
+
}
|
|
19
|
+
this.apiKey = config.apiKey;
|
|
20
|
+
this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
|
|
21
|
+
this.timeout = config.timeout || DEFAULT_TIMEOUT;
|
|
22
|
+
this.products = new ProductsResource(this);
|
|
23
|
+
this.variants = new VariantsResource(this);
|
|
24
|
+
this.orders = new OrdersResource(this);
|
|
25
|
+
this.customers = new CustomersResource(this);
|
|
26
|
+
this.reviews = new ReviewsResource(this);
|
|
27
|
+
this.discounts = new DiscountsResource(this);
|
|
28
|
+
this.upsells = new UpsellsResource(this);
|
|
29
|
+
this.subscriptions = new SubscriptionsResource(this);
|
|
30
|
+
this.webhooks = new WebhooksResource(this);
|
|
31
|
+
this.users = new UsersResource(this);
|
|
32
|
+
this.checkout = new CheckoutResource(this);
|
|
33
|
+
this.refunds = new RefundsResource(this);
|
|
34
|
+
}
|
|
35
|
+
async request(method, path, options = {}) {
|
|
36
|
+
const url = new URL(path, this.baseUrl);
|
|
37
|
+
if (options.params) {
|
|
38
|
+
Object.entries(options.params).forEach(([key, value]) => {
|
|
39
|
+
if (value !== void 0 && value !== null) {
|
|
40
|
+
url.searchParams.append(key, String(value));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const controller = new AbortController();
|
|
45
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
46
|
+
try {
|
|
47
|
+
const response = await fetch(url.toString(), {
|
|
48
|
+
method,
|
|
49
|
+
headers: {
|
|
50
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
51
|
+
"Content-Type": "application/json"
|
|
52
|
+
},
|
|
53
|
+
body: options.body ? JSON.stringify(options.body) : void 0,
|
|
54
|
+
signal: controller.signal
|
|
55
|
+
});
|
|
56
|
+
clearTimeout(timeoutId);
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
let errorMessage = "Request failed";
|
|
59
|
+
let errorCode;
|
|
60
|
+
try {
|
|
61
|
+
const errorBody = await response.json();
|
|
62
|
+
errorMessage = errorBody.message || errorBody.error || errorMessage;
|
|
63
|
+
errorCode = errorBody.code;
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
throw new PocketsflowError(errorMessage, errorCode, response.status);
|
|
67
|
+
}
|
|
68
|
+
const text = await response.text();
|
|
69
|
+
if (!text) {
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
return JSON.parse(text);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
clearTimeout(timeoutId);
|
|
75
|
+
if (error instanceof PocketsflowError) {
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
if (error instanceof Error) {
|
|
79
|
+
if (error.name === "AbortError") {
|
|
80
|
+
throw new PocketsflowError("Request timeout", "TIMEOUT");
|
|
81
|
+
}
|
|
82
|
+
throw new PocketsflowError(error.message);
|
|
83
|
+
}
|
|
84
|
+
throw new PocketsflowError("Unknown error occurred");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var ProductsResource = class {
|
|
89
|
+
constructor(client) {
|
|
90
|
+
this.client = client;
|
|
91
|
+
}
|
|
92
|
+
/** List all products */
|
|
93
|
+
async list() {
|
|
94
|
+
return this.client.request("GET", "/products");
|
|
95
|
+
}
|
|
96
|
+
/** Get a product by ID */
|
|
97
|
+
async get(id) {
|
|
98
|
+
return this.client.request("GET", `/products/${id}`);
|
|
99
|
+
}
|
|
100
|
+
/** Create a new product */
|
|
101
|
+
async create(params) {
|
|
102
|
+
return this.client.request("POST", "/products", { body: params });
|
|
103
|
+
}
|
|
104
|
+
/** Update a product */
|
|
105
|
+
async update(id, params) {
|
|
106
|
+
return this.client.request("POST", `/products/update/${id}`, { body: params });
|
|
107
|
+
}
|
|
108
|
+
/** Delete a product */
|
|
109
|
+
async delete(id) {
|
|
110
|
+
return this.client.request("DELETE", `/products/${id}`);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var VariantsResource = class {
|
|
114
|
+
constructor(client) {
|
|
115
|
+
this.client = client;
|
|
116
|
+
}
|
|
117
|
+
/** Create a product variant */
|
|
118
|
+
async create(params) {
|
|
119
|
+
return this.client.request("POST", "/products/variants", { body: params });
|
|
120
|
+
}
|
|
121
|
+
/** Delete a product variant */
|
|
122
|
+
async delete(id) {
|
|
123
|
+
return this.client.request("DELETE", `/products/variants/${id}`);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var OrdersResource = class {
|
|
127
|
+
constructor(client) {
|
|
128
|
+
this.client = client;
|
|
129
|
+
}
|
|
130
|
+
/** List all orders with optional filters */
|
|
131
|
+
async list(params = {}) {
|
|
132
|
+
return this.client.request("GET", "/orders", { params });
|
|
133
|
+
}
|
|
134
|
+
/** Get an order by ID */
|
|
135
|
+
async get(id) {
|
|
136
|
+
return this.client.request("GET", `/orders/${id}`);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
var CustomersResource = class {
|
|
140
|
+
constructor(client) {
|
|
141
|
+
this.client = client;
|
|
142
|
+
}
|
|
143
|
+
/** List all customers */
|
|
144
|
+
async list(params = {}) {
|
|
145
|
+
return this.client.request("GET", "/customers", { params });
|
|
146
|
+
}
|
|
147
|
+
/** Get a customer by ID */
|
|
148
|
+
async get(id) {
|
|
149
|
+
return this.client.request("GET", `/customers/${id}`);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
var ReviewsResource = class {
|
|
153
|
+
constructor(client) {
|
|
154
|
+
this.client = client;
|
|
155
|
+
}
|
|
156
|
+
/** List all reviews */
|
|
157
|
+
async list(params = {}) {
|
|
158
|
+
return this.client.request("GET", "/reviews", { params });
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var DiscountsResource = class {
|
|
162
|
+
constructor(client) {
|
|
163
|
+
this.client = client;
|
|
164
|
+
}
|
|
165
|
+
/** List all discounts */
|
|
166
|
+
async list() {
|
|
167
|
+
return this.client.request("GET", "/discounts");
|
|
168
|
+
}
|
|
169
|
+
/** Get a discount by ID */
|
|
170
|
+
async get(id) {
|
|
171
|
+
return this.client.request("GET", `/discounts/${id}`);
|
|
172
|
+
}
|
|
173
|
+
/** Create a new discount */
|
|
174
|
+
async create(params) {
|
|
175
|
+
return this.client.request("POST", "/discounts", { body: params });
|
|
176
|
+
}
|
|
177
|
+
/** Update a discount */
|
|
178
|
+
async update(id, params) {
|
|
179
|
+
return this.client.request("POST", `/discounts/${id}`, { body: params });
|
|
180
|
+
}
|
|
181
|
+
/** Delete a discount */
|
|
182
|
+
async delete(id) {
|
|
183
|
+
return this.client.request("DELETE", `/discounts/${id}`);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
var UpsellsResource = class {
|
|
187
|
+
constructor(client) {
|
|
188
|
+
this.client = client;
|
|
189
|
+
}
|
|
190
|
+
/** List all upsells */
|
|
191
|
+
async list() {
|
|
192
|
+
return this.client.request("GET", "/upsells");
|
|
193
|
+
}
|
|
194
|
+
/** Get an upsell by ID */
|
|
195
|
+
async get(id) {
|
|
196
|
+
return this.client.request("GET", `/upsells/${id}`);
|
|
197
|
+
}
|
|
198
|
+
/** Create a new upsell */
|
|
199
|
+
async create(params) {
|
|
200
|
+
return this.client.request("POST", "/upsells", { body: params });
|
|
201
|
+
}
|
|
202
|
+
/** Update an upsell */
|
|
203
|
+
async update(id, params) {
|
|
204
|
+
return this.client.request("POST", `/upsells/${id}`, { body: params });
|
|
205
|
+
}
|
|
206
|
+
/** Delete an upsell */
|
|
207
|
+
async delete(id) {
|
|
208
|
+
return this.client.request("DELETE", `/upsells/${id}`);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
var SubscriptionsResource = class {
|
|
212
|
+
constructor(client) {
|
|
213
|
+
this.client = client;
|
|
214
|
+
}
|
|
215
|
+
/** List subscription customers */
|
|
216
|
+
async list(params = {}) {
|
|
217
|
+
return this.client.request("POST", "/orders/subscriptions", { body: params });
|
|
218
|
+
}
|
|
219
|
+
/** Get a subscription by ID */
|
|
220
|
+
async get(id) {
|
|
221
|
+
return this.client.request("GET", `/orders/subscriptions/${id}`);
|
|
222
|
+
}
|
|
223
|
+
/** Cancel a subscription */
|
|
224
|
+
async cancel(stripeSubscriptionId) {
|
|
225
|
+
return this.client.request(
|
|
226
|
+
"POST",
|
|
227
|
+
`/orders/subscriptions/cancel/${stripeSubscriptionId}`
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
/** Refund a subscription */
|
|
231
|
+
async refund(stripeSubscriptionId) {
|
|
232
|
+
return this.client.request(
|
|
233
|
+
"POST",
|
|
234
|
+
`/orders/subscriptions/refund/${stripeSubscriptionId}`
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
var WebhooksResource = class {
|
|
239
|
+
constructor(client) {
|
|
240
|
+
this.client = client;
|
|
241
|
+
}
|
|
242
|
+
/** List all webhooks */
|
|
243
|
+
async list() {
|
|
244
|
+
return this.client.request("GET", "/webhooks");
|
|
245
|
+
}
|
|
246
|
+
/** Get a webhook by ID */
|
|
247
|
+
async get(id) {
|
|
248
|
+
return this.client.request("GET", `/webhooks/${id}`);
|
|
249
|
+
}
|
|
250
|
+
/** Create a new webhook */
|
|
251
|
+
async create(params) {
|
|
252
|
+
return this.client.request("POST", "/webhooks", { body: params });
|
|
253
|
+
}
|
|
254
|
+
/** Update a webhook */
|
|
255
|
+
async update(id, params) {
|
|
256
|
+
return this.client.request("PUT", `/webhooks/${id}`, { body: params });
|
|
257
|
+
}
|
|
258
|
+
/** Delete a webhook */
|
|
259
|
+
async delete(id) {
|
|
260
|
+
return this.client.request("DELETE", `/webhooks/${id}`);
|
|
261
|
+
}
|
|
262
|
+
/** Test a webhook */
|
|
263
|
+
async test(id) {
|
|
264
|
+
return this.client.request("POST", `/webhooks/${id}/test`);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
var UsersResource = class {
|
|
268
|
+
constructor(client) {
|
|
269
|
+
this.client = client;
|
|
270
|
+
}
|
|
271
|
+
/** Get current user information */
|
|
272
|
+
async me() {
|
|
273
|
+
return this.client.request("GET", "/users/me");
|
|
274
|
+
}
|
|
275
|
+
/** Update current user */
|
|
276
|
+
async update(params) {
|
|
277
|
+
return this.client.request("POST", "/users/update", { body: params });
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
var CheckoutResource = class {
|
|
281
|
+
constructor(client) {
|
|
282
|
+
this.client = client;
|
|
283
|
+
}
|
|
284
|
+
/** Create a checkout session */
|
|
285
|
+
async create(params) {
|
|
286
|
+
return this.client.request("POST", "/checkout/sessions", { body: params });
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
var RefundsResource = class {
|
|
290
|
+
constructor(client) {
|
|
291
|
+
this.client = client;
|
|
292
|
+
}
|
|
293
|
+
/** List all refunds */
|
|
294
|
+
async list() {
|
|
295
|
+
return this.client.request("GET", "/refunds");
|
|
296
|
+
}
|
|
297
|
+
/** Get a refund by ID */
|
|
298
|
+
async get(id) {
|
|
299
|
+
return this.client.request("GET", `/refunds/${id}`);
|
|
300
|
+
}
|
|
301
|
+
/** Create a refund */
|
|
302
|
+
async create(params) {
|
|
303
|
+
return this.client.request("POST", "/refunds", { body: params });
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
export {
|
|
307
|
+
Pocketsflow,
|
|
308
|
+
PocketsflowError
|
|
309
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pocketsflow",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official Pocketsflow SDK for Node.js and TypeScript",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
20
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
21
|
+
"lint": "eslint src/",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"pocketsflow",
|
|
27
|
+
"payments",
|
|
28
|
+
"digital-products",
|
|
29
|
+
"subscriptions",
|
|
30
|
+
"api",
|
|
31
|
+
"sdk",
|
|
32
|
+
"e-commerce"
|
|
33
|
+
],
|
|
34
|
+
"author": "Pocketsflow <support@pocketsflow.com>",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/pocketsflow/pocketsflow-node"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://pocketsflow.com",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/pocketsflow/pocketsflow-node/issues"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=16.0.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "^20.10.0",
|
|
49
|
+
"tsup": "^8.0.1",
|
|
50
|
+
"typescript": "^5.3.0"
|
|
51
|
+
}
|
|
52
|
+
}
|