pocketsflow 1.1.0 → 1.2.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 +20 -133
- package/dist/index.d.mts +60 -410
- package/dist/index.d.ts +60 -410
- package/dist/index.js +8 -246
- package/dist/index.mjs +8 -246
- package/package.json +3 -4
package/dist/index.js
CHANGED
|
@@ -55,11 +55,6 @@ var Pocketsflow = class {
|
|
|
55
55
|
this.upsells = new UpsellsResource(this);
|
|
56
56
|
this.subscriptions = new SubscriptionsResource(this);
|
|
57
57
|
this.subscriptionOffers = new SubscriptionOffersResource(this);
|
|
58
|
-
this.subscribers = new SubscribersResource(this);
|
|
59
|
-
this.payments = new PaymentsResource(this);
|
|
60
|
-
this.creatorPages = new CreatorPagesResource(this);
|
|
61
|
-
this.images = new ImagesResource(this);
|
|
62
|
-
this.newsletters = new NewslettersResource(this);
|
|
63
58
|
this.webhooks = new WebhooksResource(this);
|
|
64
59
|
this.users = new UsersResource(this);
|
|
65
60
|
this.checkout = new CheckoutResource(this);
|
|
@@ -76,18 +71,14 @@ var Pocketsflow = class {
|
|
|
76
71
|
}
|
|
77
72
|
const controller = new AbortController();
|
|
78
73
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
79
|
-
const isFormData = typeof FormData !== "undefined" && options.body instanceof FormData;
|
|
80
|
-
const headers = {
|
|
81
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
82
|
-
};
|
|
83
|
-
if (!isFormData) {
|
|
84
|
-
headers["Content-Type"] = "application/json";
|
|
85
|
-
}
|
|
86
74
|
try {
|
|
87
75
|
const response = await fetch(url.toString(), {
|
|
88
76
|
method,
|
|
89
|
-
headers
|
|
90
|
-
|
|
77
|
+
headers: {
|
|
78
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
79
|
+
"Content-Type": "application/json"
|
|
80
|
+
},
|
|
81
|
+
body: options.body ? JSON.stringify(options.body) : void 0,
|
|
91
82
|
signal: controller.signal
|
|
92
83
|
});
|
|
93
84
|
clearTimeout(timeoutId);
|
|
@@ -219,17 +210,6 @@ var DiscountsResource = class {
|
|
|
219
210
|
async delete(id) {
|
|
220
211
|
return this.client.request("DELETE", `/discounts/${id}`);
|
|
221
212
|
}
|
|
222
|
-
/** Validate a discount code against a product and get the resulting price */
|
|
223
|
-
async apply(discountCode, productId) {
|
|
224
|
-
return this.client.request(
|
|
225
|
-
"GET",
|
|
226
|
-
`/discounts/apply/${encodeURIComponent(discountCode)}/${productId}`
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
/** Check whether a product has any discounts */
|
|
230
|
-
async checkProduct(productId) {
|
|
231
|
-
return this.client.request("GET", `/discounts/check-product/${productId}`);
|
|
232
|
-
}
|
|
233
213
|
};
|
|
234
214
|
var UpsellsResource = class {
|
|
235
215
|
constructor(client) {
|
|
@@ -295,227 +275,9 @@ var SubscriptionOffersResource = class {
|
|
|
295
275
|
async get(id) {
|
|
296
276
|
return this.client.request("GET", `/subscriptions/${id}`);
|
|
297
277
|
}
|
|
298
|
-
|
|
299
|
-
var SubscribersResource = class {
|
|
300
|
-
constructor(client) {
|
|
301
|
-
this.client = client;
|
|
302
|
-
}
|
|
303
|
-
/** List subscribers */
|
|
304
|
-
async list(params = {}) {
|
|
305
|
-
return this.client.request("GET", "/subscriptions/subscribers", {
|
|
306
|
-
params
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Get a subscriber with its full payment history.
|
|
311
|
-
* Pass `live` to also fetch the authoritative membership from Whop; the
|
|
312
|
-
* lookup degrades gracefully and never fails the request.
|
|
313
|
-
*/
|
|
314
|
-
async get(id, options = {}) {
|
|
315
|
-
return this.client.request(
|
|
316
|
-
"GET",
|
|
317
|
-
`/subscriptions/subscribers/${id}`,
|
|
318
|
-
{ params: options }
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
|
-
/** Cancel a subscriber's subscription */
|
|
322
|
-
async cancel(id) {
|
|
323
|
-
return this.client.request(
|
|
324
|
-
"POST",
|
|
325
|
-
`/subscriptions/${id}/cancel`
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
/** Pause a subscriber's subscription */
|
|
329
|
-
async pause(id) {
|
|
330
|
-
return this.client.request(
|
|
331
|
-
"POST",
|
|
332
|
-
`/subscriptions/${id}/pause`
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
/** Resume a paused subscription */
|
|
336
|
-
async resume(id) {
|
|
337
|
-
return this.client.request(
|
|
338
|
-
"POST",
|
|
339
|
-
`/subscriptions/${id}/resume`
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* Read the native subscriber portal payload. The `subscriptionId` +
|
|
344
|
-
* `subscriberId` pair is itself the capability — these portal endpoints are
|
|
345
|
-
* unauthenticated, so the API key is not required to call them.
|
|
346
|
-
*/
|
|
347
|
-
async portal(subscriptionId, subscriberId) {
|
|
348
|
-
return this.client.request(
|
|
349
|
-
"GET",
|
|
350
|
-
`/subscriptions/sub/portal-data/${subscriptionId}/${subscriberId}`
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
/** Cancel a membership through the native portal */
|
|
354
|
-
async portalCancel(subscriberId) {
|
|
355
|
-
return this.client.request(
|
|
356
|
-
"POST",
|
|
357
|
-
`/subscriptions/sub/portal/${subscriberId}/cancel`
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
/** Resume a pending cancellation through the native portal */
|
|
361
|
-
async portalResume(subscriberId) {
|
|
362
|
-
return this.client.request(
|
|
363
|
-
"POST",
|
|
364
|
-
`/subscriptions/sub/portal/${subscriberId}/resume`
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
var PaymentsResource = class {
|
|
369
|
-
constructor(client) {
|
|
370
|
-
this.client = client;
|
|
371
|
-
}
|
|
372
|
-
/** List payments */
|
|
373
|
-
async list(params = {}) {
|
|
374
|
-
return this.client.request("GET", "/payments", { params });
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Get a payment by ID. Pass `live` to also fetch the authoritative payment
|
|
378
|
-
* from Whop; the lookup degrades gracefully and never fails the request.
|
|
379
|
-
*/
|
|
380
|
-
async get(id, options = {}) {
|
|
381
|
-
return this.client.request("GET", `/payments/${id}`, {
|
|
382
|
-
params: options
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
var CreatorPagesResource = class {
|
|
387
|
-
constructor(client) {
|
|
388
|
-
this.client = client;
|
|
389
|
-
}
|
|
390
|
-
/** Get your Link in Bio page */
|
|
391
|
-
async get() {
|
|
392
|
-
return this.client.request("GET", "/creator-pages");
|
|
393
|
-
}
|
|
394
|
-
/** Create your Link in Bio page. Fails if one already exists — use `update`. */
|
|
278
|
+
/** Create a subscription offer */
|
|
395
279
|
async create(params) {
|
|
396
|
-
return this.client.request("POST", "/
|
|
397
|
-
}
|
|
398
|
-
/** Update your Link in Bio page (partial) */
|
|
399
|
-
async update(params) {
|
|
400
|
-
return this.client.request("PUT", "/creator-pages", { body: params });
|
|
401
|
-
}
|
|
402
|
-
/** Delete your Link in Bio page */
|
|
403
|
-
async delete() {
|
|
404
|
-
return this.client.request("DELETE", "/creator-pages");
|
|
405
|
-
}
|
|
406
|
-
/** Check whether a username is available */
|
|
407
|
-
async checkUsername(username) {
|
|
408
|
-
return this.client.request(
|
|
409
|
-
"GET",
|
|
410
|
-
`/creator-pages/check-username/${encodeURIComponent(username)}`
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
/** Set your Link in Bio username */
|
|
414
|
-
async updateUsername(username) {
|
|
415
|
-
return this.client.request("PATCH", "/creator-pages/username", {
|
|
416
|
-
body: { username }
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
var ImagesResource = class {
|
|
421
|
-
constructor(client) {
|
|
422
|
-
this.client = client;
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Upload an image and get back its hosted URL.
|
|
426
|
-
*
|
|
427
|
-
* `file` accepts anything FormData can hold — a Blob/File, or a Buffer in
|
|
428
|
-
* Node 18+. `filename` is used when the value carries no name of its own.
|
|
429
|
-
*/
|
|
430
|
-
async upload(file, filename = "image") {
|
|
431
|
-
if (typeof FormData === "undefined") {
|
|
432
|
-
throw new PocketsflowError(
|
|
433
|
-
"FormData is not available in this runtime; image upload requires Node 18+ or a browser",
|
|
434
|
-
"UNSUPPORTED_RUNTIME"
|
|
435
|
-
);
|
|
436
|
-
}
|
|
437
|
-
const form = new FormData();
|
|
438
|
-
const value = typeof Blob !== "undefined" && file instanceof Blob ? file : new Blob([file]);
|
|
439
|
-
form.append("image", value, filename);
|
|
440
|
-
return this.client.request("POST", "/images", { body: form });
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
var NewslettersResource = class {
|
|
444
|
-
constructor(client) {
|
|
445
|
-
this.client = client;
|
|
446
|
-
this.posts = new NewsletterPostsResource(client);
|
|
447
|
-
this.subscribers = new NewsletterSubscribersResource(client);
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Send a one-off email to up to 100 recipients.
|
|
451
|
-
* Requires a verified sender email. Either `html` or `text` must be given.
|
|
452
|
-
*/
|
|
453
|
-
async send(params) {
|
|
454
|
-
return this.client.request("POST", "/newsletters/send", {
|
|
455
|
-
body: params
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
var NewsletterPostsResource = class {
|
|
460
|
-
constructor(client) {
|
|
461
|
-
this.client = client;
|
|
462
|
-
}
|
|
463
|
-
/** List all posts, newest first */
|
|
464
|
-
async list() {
|
|
465
|
-
return this.client.request("GET", "/newsletters/posts");
|
|
466
|
-
}
|
|
467
|
-
/** Get a post by ID */
|
|
468
|
-
async get(id) {
|
|
469
|
-
return this.client.request("GET", `/newsletters/posts/${id}`);
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Create a post. Leaving `draft` requires `subject`, `preview`, `fromName`
|
|
473
|
-
* and `contentHtml` to be set.
|
|
474
|
-
*/
|
|
475
|
-
async create(params) {
|
|
476
|
-
return this.client.request("POST", "/newsletters/posts", {
|
|
477
|
-
body: params
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
/** Update a post. Posts that have already been sent cannot be edited. */
|
|
481
|
-
async update(id, params) {
|
|
482
|
-
return this.client.request("POST", `/newsletters/posts/${id}`, {
|
|
483
|
-
body: params
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
/** Delete a post */
|
|
487
|
-
async delete(id) {
|
|
488
|
-
return this.client.request("DELETE", `/newsletters/posts/${id}`);
|
|
489
|
-
}
|
|
490
|
-
/** Queue a post for sending to its subscribers */
|
|
491
|
-
async send(id) {
|
|
492
|
-
return this.client.request(
|
|
493
|
-
"POST",
|
|
494
|
-
`/newsletters/posts/${id}/send`
|
|
495
|
-
);
|
|
496
|
-
}
|
|
497
|
-
};
|
|
498
|
-
var NewsletterSubscribersResource = class {
|
|
499
|
-
constructor(client) {
|
|
500
|
-
this.client = client;
|
|
501
|
-
}
|
|
502
|
-
/** List all subscribers, newest first */
|
|
503
|
-
async list() {
|
|
504
|
-
return this.client.request("GET", "/newsletters/subscribers");
|
|
505
|
-
}
|
|
506
|
-
/** Get a subscriber by ID */
|
|
507
|
-
async get(id) {
|
|
508
|
-
return this.client.request(
|
|
509
|
-
"GET",
|
|
510
|
-
`/newsletters/subscribers/${id}`
|
|
511
|
-
);
|
|
512
|
-
}
|
|
513
|
-
/** Remove a subscriber */
|
|
514
|
-
async delete(id) {
|
|
515
|
-
return this.client.request(
|
|
516
|
-
"DELETE",
|
|
517
|
-
`/newsletters/subscribers/${id}`
|
|
518
|
-
);
|
|
280
|
+
return this.client.request("POST", "/subscriptions", { body: params });
|
|
519
281
|
}
|
|
520
282
|
};
|
|
521
283
|
var WebhooksResource = class {
|
|
@@ -536,7 +298,7 @@ var WebhooksResource = class {
|
|
|
536
298
|
}
|
|
537
299
|
/** Update a webhook */
|
|
538
300
|
async update(id, params) {
|
|
539
|
-
return this.client.request("
|
|
301
|
+
return this.client.request("PUT", `/webhooks/${id}`, { body: params });
|
|
540
302
|
}
|
|
541
303
|
/** Delete a webhook */
|
|
542
304
|
async delete(id) {
|
package/dist/index.mjs
CHANGED
|
@@ -28,11 +28,6 @@ var Pocketsflow = class {
|
|
|
28
28
|
this.upsells = new UpsellsResource(this);
|
|
29
29
|
this.subscriptions = new SubscriptionsResource(this);
|
|
30
30
|
this.subscriptionOffers = new SubscriptionOffersResource(this);
|
|
31
|
-
this.subscribers = new SubscribersResource(this);
|
|
32
|
-
this.payments = new PaymentsResource(this);
|
|
33
|
-
this.creatorPages = new CreatorPagesResource(this);
|
|
34
|
-
this.images = new ImagesResource(this);
|
|
35
|
-
this.newsletters = new NewslettersResource(this);
|
|
36
31
|
this.webhooks = new WebhooksResource(this);
|
|
37
32
|
this.users = new UsersResource(this);
|
|
38
33
|
this.checkout = new CheckoutResource(this);
|
|
@@ -49,18 +44,14 @@ var Pocketsflow = class {
|
|
|
49
44
|
}
|
|
50
45
|
const controller = new AbortController();
|
|
51
46
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
52
|
-
const isFormData = typeof FormData !== "undefined" && options.body instanceof FormData;
|
|
53
|
-
const headers = {
|
|
54
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
55
|
-
};
|
|
56
|
-
if (!isFormData) {
|
|
57
|
-
headers["Content-Type"] = "application/json";
|
|
58
|
-
}
|
|
59
47
|
try {
|
|
60
48
|
const response = await fetch(url.toString(), {
|
|
61
49
|
method,
|
|
62
|
-
headers
|
|
63
|
-
|
|
50
|
+
headers: {
|
|
51
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
52
|
+
"Content-Type": "application/json"
|
|
53
|
+
},
|
|
54
|
+
body: options.body ? JSON.stringify(options.body) : void 0,
|
|
64
55
|
signal: controller.signal
|
|
65
56
|
});
|
|
66
57
|
clearTimeout(timeoutId);
|
|
@@ -192,17 +183,6 @@ var DiscountsResource = class {
|
|
|
192
183
|
async delete(id) {
|
|
193
184
|
return this.client.request("DELETE", `/discounts/${id}`);
|
|
194
185
|
}
|
|
195
|
-
/** Validate a discount code against a product and get the resulting price */
|
|
196
|
-
async apply(discountCode, productId) {
|
|
197
|
-
return this.client.request(
|
|
198
|
-
"GET",
|
|
199
|
-
`/discounts/apply/${encodeURIComponent(discountCode)}/${productId}`
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
/** Check whether a product has any discounts */
|
|
203
|
-
async checkProduct(productId) {
|
|
204
|
-
return this.client.request("GET", `/discounts/check-product/${productId}`);
|
|
205
|
-
}
|
|
206
186
|
};
|
|
207
187
|
var UpsellsResource = class {
|
|
208
188
|
constructor(client) {
|
|
@@ -268,227 +248,9 @@ var SubscriptionOffersResource = class {
|
|
|
268
248
|
async get(id) {
|
|
269
249
|
return this.client.request("GET", `/subscriptions/${id}`);
|
|
270
250
|
}
|
|
271
|
-
|
|
272
|
-
var SubscribersResource = class {
|
|
273
|
-
constructor(client) {
|
|
274
|
-
this.client = client;
|
|
275
|
-
}
|
|
276
|
-
/** List subscribers */
|
|
277
|
-
async list(params = {}) {
|
|
278
|
-
return this.client.request("GET", "/subscriptions/subscribers", {
|
|
279
|
-
params
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Get a subscriber with its full payment history.
|
|
284
|
-
* Pass `live` to also fetch the authoritative membership from Whop; the
|
|
285
|
-
* lookup degrades gracefully and never fails the request.
|
|
286
|
-
*/
|
|
287
|
-
async get(id, options = {}) {
|
|
288
|
-
return this.client.request(
|
|
289
|
-
"GET",
|
|
290
|
-
`/subscriptions/subscribers/${id}`,
|
|
291
|
-
{ params: options }
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
/** Cancel a subscriber's subscription */
|
|
295
|
-
async cancel(id) {
|
|
296
|
-
return this.client.request(
|
|
297
|
-
"POST",
|
|
298
|
-
`/subscriptions/${id}/cancel`
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
/** Pause a subscriber's subscription */
|
|
302
|
-
async pause(id) {
|
|
303
|
-
return this.client.request(
|
|
304
|
-
"POST",
|
|
305
|
-
`/subscriptions/${id}/pause`
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
/** Resume a paused subscription */
|
|
309
|
-
async resume(id) {
|
|
310
|
-
return this.client.request(
|
|
311
|
-
"POST",
|
|
312
|
-
`/subscriptions/${id}/resume`
|
|
313
|
-
);
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Read the native subscriber portal payload. The `subscriptionId` +
|
|
317
|
-
* `subscriberId` pair is itself the capability — these portal endpoints are
|
|
318
|
-
* unauthenticated, so the API key is not required to call them.
|
|
319
|
-
*/
|
|
320
|
-
async portal(subscriptionId, subscriberId) {
|
|
321
|
-
return this.client.request(
|
|
322
|
-
"GET",
|
|
323
|
-
`/subscriptions/sub/portal-data/${subscriptionId}/${subscriberId}`
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
/** Cancel a membership through the native portal */
|
|
327
|
-
async portalCancel(subscriberId) {
|
|
328
|
-
return this.client.request(
|
|
329
|
-
"POST",
|
|
330
|
-
`/subscriptions/sub/portal/${subscriberId}/cancel`
|
|
331
|
-
);
|
|
332
|
-
}
|
|
333
|
-
/** Resume a pending cancellation through the native portal */
|
|
334
|
-
async portalResume(subscriberId) {
|
|
335
|
-
return this.client.request(
|
|
336
|
-
"POST",
|
|
337
|
-
`/subscriptions/sub/portal/${subscriberId}/resume`
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
var PaymentsResource = class {
|
|
342
|
-
constructor(client) {
|
|
343
|
-
this.client = client;
|
|
344
|
-
}
|
|
345
|
-
/** List payments */
|
|
346
|
-
async list(params = {}) {
|
|
347
|
-
return this.client.request("GET", "/payments", { params });
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Get a payment by ID. Pass `live` to also fetch the authoritative payment
|
|
351
|
-
* from Whop; the lookup degrades gracefully and never fails the request.
|
|
352
|
-
*/
|
|
353
|
-
async get(id, options = {}) {
|
|
354
|
-
return this.client.request("GET", `/payments/${id}`, {
|
|
355
|
-
params: options
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
var CreatorPagesResource = class {
|
|
360
|
-
constructor(client) {
|
|
361
|
-
this.client = client;
|
|
362
|
-
}
|
|
363
|
-
/** Get your Link in Bio page */
|
|
364
|
-
async get() {
|
|
365
|
-
return this.client.request("GET", "/creator-pages");
|
|
366
|
-
}
|
|
367
|
-
/** Create your Link in Bio page. Fails if one already exists — use `update`. */
|
|
251
|
+
/** Create a subscription offer */
|
|
368
252
|
async create(params) {
|
|
369
|
-
return this.client.request("POST", "/
|
|
370
|
-
}
|
|
371
|
-
/** Update your Link in Bio page (partial) */
|
|
372
|
-
async update(params) {
|
|
373
|
-
return this.client.request("PUT", "/creator-pages", { body: params });
|
|
374
|
-
}
|
|
375
|
-
/** Delete your Link in Bio page */
|
|
376
|
-
async delete() {
|
|
377
|
-
return this.client.request("DELETE", "/creator-pages");
|
|
378
|
-
}
|
|
379
|
-
/** Check whether a username is available */
|
|
380
|
-
async checkUsername(username) {
|
|
381
|
-
return this.client.request(
|
|
382
|
-
"GET",
|
|
383
|
-
`/creator-pages/check-username/${encodeURIComponent(username)}`
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
/** Set your Link in Bio username */
|
|
387
|
-
async updateUsername(username) {
|
|
388
|
-
return this.client.request("PATCH", "/creator-pages/username", {
|
|
389
|
-
body: { username }
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
var ImagesResource = class {
|
|
394
|
-
constructor(client) {
|
|
395
|
-
this.client = client;
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Upload an image and get back its hosted URL.
|
|
399
|
-
*
|
|
400
|
-
* `file` accepts anything FormData can hold — a Blob/File, or a Buffer in
|
|
401
|
-
* Node 18+. `filename` is used when the value carries no name of its own.
|
|
402
|
-
*/
|
|
403
|
-
async upload(file, filename = "image") {
|
|
404
|
-
if (typeof FormData === "undefined") {
|
|
405
|
-
throw new PocketsflowError(
|
|
406
|
-
"FormData is not available in this runtime; image upload requires Node 18+ or a browser",
|
|
407
|
-
"UNSUPPORTED_RUNTIME"
|
|
408
|
-
);
|
|
409
|
-
}
|
|
410
|
-
const form = new FormData();
|
|
411
|
-
const value = typeof Blob !== "undefined" && file instanceof Blob ? file : new Blob([file]);
|
|
412
|
-
form.append("image", value, filename);
|
|
413
|
-
return this.client.request("POST", "/images", { body: form });
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
var NewslettersResource = class {
|
|
417
|
-
constructor(client) {
|
|
418
|
-
this.client = client;
|
|
419
|
-
this.posts = new NewsletterPostsResource(client);
|
|
420
|
-
this.subscribers = new NewsletterSubscribersResource(client);
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Send a one-off email to up to 100 recipients.
|
|
424
|
-
* Requires a verified sender email. Either `html` or `text` must be given.
|
|
425
|
-
*/
|
|
426
|
-
async send(params) {
|
|
427
|
-
return this.client.request("POST", "/newsletters/send", {
|
|
428
|
-
body: params
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
var NewsletterPostsResource = class {
|
|
433
|
-
constructor(client) {
|
|
434
|
-
this.client = client;
|
|
435
|
-
}
|
|
436
|
-
/** List all posts, newest first */
|
|
437
|
-
async list() {
|
|
438
|
-
return this.client.request("GET", "/newsletters/posts");
|
|
439
|
-
}
|
|
440
|
-
/** Get a post by ID */
|
|
441
|
-
async get(id) {
|
|
442
|
-
return this.client.request("GET", `/newsletters/posts/${id}`);
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Create a post. Leaving `draft` requires `subject`, `preview`, `fromName`
|
|
446
|
-
* and `contentHtml` to be set.
|
|
447
|
-
*/
|
|
448
|
-
async create(params) {
|
|
449
|
-
return this.client.request("POST", "/newsletters/posts", {
|
|
450
|
-
body: params
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
/** Update a post. Posts that have already been sent cannot be edited. */
|
|
454
|
-
async update(id, params) {
|
|
455
|
-
return this.client.request("POST", `/newsletters/posts/${id}`, {
|
|
456
|
-
body: params
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
/** Delete a post */
|
|
460
|
-
async delete(id) {
|
|
461
|
-
return this.client.request("DELETE", `/newsletters/posts/${id}`);
|
|
462
|
-
}
|
|
463
|
-
/** Queue a post for sending to its subscribers */
|
|
464
|
-
async send(id) {
|
|
465
|
-
return this.client.request(
|
|
466
|
-
"POST",
|
|
467
|
-
`/newsletters/posts/${id}/send`
|
|
468
|
-
);
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
var NewsletterSubscribersResource = class {
|
|
472
|
-
constructor(client) {
|
|
473
|
-
this.client = client;
|
|
474
|
-
}
|
|
475
|
-
/** List all subscribers, newest first */
|
|
476
|
-
async list() {
|
|
477
|
-
return this.client.request("GET", "/newsletters/subscribers");
|
|
478
|
-
}
|
|
479
|
-
/** Get a subscriber by ID */
|
|
480
|
-
async get(id) {
|
|
481
|
-
return this.client.request(
|
|
482
|
-
"GET",
|
|
483
|
-
`/newsletters/subscribers/${id}`
|
|
484
|
-
);
|
|
485
|
-
}
|
|
486
|
-
/** Remove a subscriber */
|
|
487
|
-
async delete(id) {
|
|
488
|
-
return this.client.request(
|
|
489
|
-
"DELETE",
|
|
490
|
-
`/newsletters/subscribers/${id}`
|
|
491
|
-
);
|
|
253
|
+
return this.client.request("POST", "/subscriptions", { body: params });
|
|
492
254
|
}
|
|
493
255
|
};
|
|
494
256
|
var WebhooksResource = class {
|
|
@@ -509,7 +271,7 @@ var WebhooksResource = class {
|
|
|
509
271
|
}
|
|
510
272
|
/** Update a webhook */
|
|
511
273
|
async update(id, params) {
|
|
512
|
-
return this.client.request("
|
|
274
|
+
return this.client.request("PUT", `/webhooks/${id}`, { body: params });
|
|
513
275
|
}
|
|
514
276
|
/** Delete a webhook */
|
|
515
277
|
async delete(id) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pocketsflow",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Official Pocketsflow SDK for Node.js and TypeScript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -35,12 +35,11 @@
|
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"repository": {
|
|
37
37
|
"type": "git",
|
|
38
|
-
"url": "
|
|
39
|
-
"directory": "packages/pocketsflow-sdk"
|
|
38
|
+
"url": "https://github.com/pocketsflow/pocketsflow-node"
|
|
40
39
|
},
|
|
41
40
|
"homepage": "https://pocketsflow.com",
|
|
42
41
|
"bugs": {
|
|
43
|
-
"url": "https://github.com/
|
|
42
|
+
"url": "https://github.com/pocketsflow/pocketsflow-node/issues"
|
|
44
43
|
},
|
|
45
44
|
"engines": {
|
|
46
45
|
"node": ">=16.0.0"
|