pocketsflow 1.0.1 → 1.1.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 +138 -8
- package/dist/index.d.mts +436 -1
- package/dist/index.d.ts +436 -1
- package/dist/index.js +262 -6
- package/dist/index.mjs +262 -6
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -54,6 +54,12 @@ var Pocketsflow = class {
|
|
|
54
54
|
this.discounts = new DiscountsResource(this);
|
|
55
55
|
this.upsells = new UpsellsResource(this);
|
|
56
56
|
this.subscriptions = new SubscriptionsResource(this);
|
|
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);
|
|
57
63
|
this.webhooks = new WebhooksResource(this);
|
|
58
64
|
this.users = new UsersResource(this);
|
|
59
65
|
this.checkout = new CheckoutResource(this);
|
|
@@ -70,14 +76,18 @@ var Pocketsflow = class {
|
|
|
70
76
|
}
|
|
71
77
|
const controller = new AbortController();
|
|
72
78
|
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
|
+
}
|
|
73
86
|
try {
|
|
74
87
|
const response = await fetch(url.toString(), {
|
|
75
88
|
method,
|
|
76
|
-
headers
|
|
77
|
-
|
|
78
|
-
"Content-Type": "application/json"
|
|
79
|
-
},
|
|
80
|
-
body: options.body ? JSON.stringify(options.body) : void 0,
|
|
89
|
+
headers,
|
|
90
|
+
body: isFormData ? options.body : options.body ? JSON.stringify(options.body) : void 0,
|
|
81
91
|
signal: controller.signal
|
|
82
92
|
});
|
|
83
93
|
clearTimeout(timeoutId);
|
|
@@ -209,6 +219,17 @@ var DiscountsResource = class {
|
|
|
209
219
|
async delete(id) {
|
|
210
220
|
return this.client.request("DELETE", `/discounts/${id}`);
|
|
211
221
|
}
|
|
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
|
+
}
|
|
212
233
|
};
|
|
213
234
|
var UpsellsResource = class {
|
|
214
235
|
constructor(client) {
|
|
@@ -262,6 +283,241 @@ var SubscriptionsResource = class {
|
|
|
262
283
|
);
|
|
263
284
|
}
|
|
264
285
|
};
|
|
286
|
+
var SubscriptionOffersResource = class {
|
|
287
|
+
constructor(client) {
|
|
288
|
+
this.client = client;
|
|
289
|
+
}
|
|
290
|
+
/** List all subscription offers */
|
|
291
|
+
async list() {
|
|
292
|
+
return this.client.request("GET", "/subscriptions");
|
|
293
|
+
}
|
|
294
|
+
/** Get a subscription offer by ID */
|
|
295
|
+
async get(id) {
|
|
296
|
+
return this.client.request("GET", `/subscriptions/${id}`);
|
|
297
|
+
}
|
|
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`. */
|
|
395
|
+
async create(params) {
|
|
396
|
+
return this.client.request("POST", "/creator-pages", { body: params });
|
|
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
|
+
);
|
|
519
|
+
}
|
|
520
|
+
};
|
|
265
521
|
var WebhooksResource = class {
|
|
266
522
|
constructor(client) {
|
|
267
523
|
this.client = client;
|
|
@@ -280,7 +536,7 @@ var WebhooksResource = class {
|
|
|
280
536
|
}
|
|
281
537
|
/** Update a webhook */
|
|
282
538
|
async update(id, params) {
|
|
283
|
-
return this.client.request("
|
|
539
|
+
return this.client.request("PATCH", `/webhooks/${id}`, { body: params });
|
|
284
540
|
}
|
|
285
541
|
/** Delete a webhook */
|
|
286
542
|
async delete(id) {
|
package/dist/index.mjs
CHANGED
|
@@ -27,6 +27,12 @@ var Pocketsflow = class {
|
|
|
27
27
|
this.discounts = new DiscountsResource(this);
|
|
28
28
|
this.upsells = new UpsellsResource(this);
|
|
29
29
|
this.subscriptions = new SubscriptionsResource(this);
|
|
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);
|
|
30
36
|
this.webhooks = new WebhooksResource(this);
|
|
31
37
|
this.users = new UsersResource(this);
|
|
32
38
|
this.checkout = new CheckoutResource(this);
|
|
@@ -43,14 +49,18 @@ var Pocketsflow = class {
|
|
|
43
49
|
}
|
|
44
50
|
const controller = new AbortController();
|
|
45
51
|
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
|
+
}
|
|
46
59
|
try {
|
|
47
60
|
const response = await fetch(url.toString(), {
|
|
48
61
|
method,
|
|
49
|
-
headers
|
|
50
|
-
|
|
51
|
-
"Content-Type": "application/json"
|
|
52
|
-
},
|
|
53
|
-
body: options.body ? JSON.stringify(options.body) : void 0,
|
|
62
|
+
headers,
|
|
63
|
+
body: isFormData ? options.body : options.body ? JSON.stringify(options.body) : void 0,
|
|
54
64
|
signal: controller.signal
|
|
55
65
|
});
|
|
56
66
|
clearTimeout(timeoutId);
|
|
@@ -182,6 +192,17 @@ var DiscountsResource = class {
|
|
|
182
192
|
async delete(id) {
|
|
183
193
|
return this.client.request("DELETE", `/discounts/${id}`);
|
|
184
194
|
}
|
|
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
|
+
}
|
|
185
206
|
};
|
|
186
207
|
var UpsellsResource = class {
|
|
187
208
|
constructor(client) {
|
|
@@ -235,6 +256,241 @@ var SubscriptionsResource = class {
|
|
|
235
256
|
);
|
|
236
257
|
}
|
|
237
258
|
};
|
|
259
|
+
var SubscriptionOffersResource = class {
|
|
260
|
+
constructor(client) {
|
|
261
|
+
this.client = client;
|
|
262
|
+
}
|
|
263
|
+
/** List all subscription offers */
|
|
264
|
+
async list() {
|
|
265
|
+
return this.client.request("GET", "/subscriptions");
|
|
266
|
+
}
|
|
267
|
+
/** Get a subscription offer by ID */
|
|
268
|
+
async get(id) {
|
|
269
|
+
return this.client.request("GET", `/subscriptions/${id}`);
|
|
270
|
+
}
|
|
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`. */
|
|
368
|
+
async create(params) {
|
|
369
|
+
return this.client.request("POST", "/creator-pages", { body: params });
|
|
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
|
+
);
|
|
492
|
+
}
|
|
493
|
+
};
|
|
238
494
|
var WebhooksResource = class {
|
|
239
495
|
constructor(client) {
|
|
240
496
|
this.client = client;
|
|
@@ -253,7 +509,7 @@ var WebhooksResource = class {
|
|
|
253
509
|
}
|
|
254
510
|
/** Update a webhook */
|
|
255
511
|
async update(id, params) {
|
|
256
|
-
return this.client.request("
|
|
512
|
+
return this.client.request("PATCH", `/webhooks/${id}`, { body: params });
|
|
257
513
|
}
|
|
258
514
|
/** Delete a webhook */
|
|
259
515
|
async delete(id) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pocketsflow",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.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,11 +35,12 @@
|
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"repository": {
|
|
37
37
|
"type": "git",
|
|
38
|
-
"url": "https://github.com/
|
|
38
|
+
"url": "git+https://github.com/Pocketsflow/pocketsflow-imperium.git",
|
|
39
|
+
"directory": "packages/pocketsflow-sdk"
|
|
39
40
|
},
|
|
40
41
|
"homepage": "https://pocketsflow.com",
|
|
41
42
|
"bugs": {
|
|
42
|
-
"url": "https://github.com/
|
|
43
|
+
"url": "https://github.com/Pocketsflow/pocketsflow-imperium/issues"
|
|
43
44
|
},
|
|
44
45
|
"engines": {
|
|
45
46
|
"node": ">=16.0.0"
|