pocketsflow 1.0.0 → 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 CHANGED
@@ -168,6 +168,10 @@ const updated = await pocketsflow.discounts.update('discount_id', {
168
168
 
169
169
  // Delete a discount
170
170
  await pocketsflow.discounts.delete('discount_id');
171
+
172
+ // Validate a code against a product, and check whether a product has any
173
+ const applied = await pocketsflow.discounts.apply('SAVE20', 'product_id');
174
+ const has = await pocketsflow.discounts.checkProduct('product_id');
171
175
  ```
172
176
 
173
177
  ### Upsells
@@ -200,25 +204,151 @@ const updated = await pocketsflow.upsells.update('upsell_id', {
200
204
  await pocketsflow.upsells.delete('upsell_id');
201
205
  ```
202
206
 
203
- ### Subscriptions
207
+ ### Subscription Offers
208
+
209
+ Your subscription **offers** — the recurring products you sell.
210
+
211
+ ```typescript
212
+ // List all subscription offers
213
+ const offers = await pocketsflow.subscriptionOffers.list();
214
+
215
+ // Get one offer
216
+ const offer = await pocketsflow.subscriptionOffers.get('offer_id');
217
+ ```
218
+
219
+ ### Subscribers
220
+
221
+ Your **buyers** — people with a membership in one of your offers. `id` accepts
222
+ either the subscriber's `_id` or its Whop membership id.
204
223
 
205
224
  ```typescript
206
- // List subscription customers
207
- const subscriptions = await pocketsflow.subscriptions.list({
225
+ // List subscribers
226
+ const { subscribers, pagination } = await pocketsflow.subscribers.list({
227
+ status: 'active',
208
228
  page: 1,
209
229
  pageSize: 20,
210
230
  });
211
231
 
212
- // Get a subscription
213
- const subscription = await pocketsflow.subscriptions.get('subscription_id');
232
+ // Get a subscriber with full payment history
233
+ const detail = await pocketsflow.subscribers.get('subscriber_id');
234
+ console.log(detail.payments); // initial charge + every renewal
214
235
 
215
- // Cancel a subscription
216
- await pocketsflow.subscriptions.cancel('stripe_subscription_id');
236
+ // Pass `live` to also fetch the authoritative membership from Whop.
237
+ // The lookup degrades gracefully and never fails the request.
238
+ const live = await pocketsflow.subscribers.get('subscriber_id', { live: true });
239
+
240
+ // Manage a membership
241
+ await pocketsflow.subscribers.cancel('subscriber_id');
242
+ await pocketsflow.subscribers.pause('subscriber_id');
243
+ await pocketsflow.subscribers.resume('subscriber_id');
244
+ ```
245
+
246
+ The native subscriber portal is driven by the `subscriptionId` + `subscriberId`
247
+ pair, which is itself the capability — these endpoints need no API key:
248
+
249
+ ```typescript
250
+ const data = await pocketsflow.subscribers.portal('offer_id', 'subscriber_id');
251
+ await pocketsflow.subscribers.portalCancel('subscriber_id');
252
+ await pocketsflow.subscribers.portalResume('subscriber_id');
253
+ ```
254
+
255
+ ### Payments
256
+
257
+ The unified ledger — one-time purchases **and** subscription payments (the
258
+ initial charge plus every renewal).
259
+
260
+ ```typescript
261
+ // List payments
262
+ const { payments, pagination } = await pocketsflow.payments.list({
263
+ type: 'subscription', // 'one_time' | 'subscription' | 'all' (default)
264
+ startDate: '2026-01-01',
265
+ pageSize: 50,
266
+ });
267
+
268
+ // Get one payment, with its product or offer, customer, and Whop payload
269
+ const payment = await pocketsflow.payments.get('payment_id');
270
+ ```
271
+
272
+ ### Subscriptions (legacy)
217
273
 
218
- // Refund a subscription
274
+ Kept for v1 compatibility. Prefer `subscribers` and `subscriptionOffers` above —
275
+ they cover pause/resume and filtering, which these do not. Note `cancel` and
276
+ `refund` here key off the **Stripe** subscription id.
277
+
278
+ ```typescript
279
+ const subscriptions = await pocketsflow.subscriptions.list({ page: 1 });
280
+ const subscription = await pocketsflow.subscriptions.get('subscription_id');
281
+ await pocketsflow.subscriptions.cancel('stripe_subscription_id');
219
282
  await pocketsflow.subscriptions.refund('stripe_subscription_id');
220
283
  ```
221
284
 
285
+ ### Link in Bio
286
+
287
+ ```typescript
288
+ // Get your page
289
+ const page = await pocketsflow.creatorPages.get();
290
+
291
+ // Create one (fails if you already have a page — use update)
292
+ const created = await pocketsflow.creatorPages.create({
293
+ creatorName: 'Jane',
294
+ creatorBio: 'I make things',
295
+ regularLinks: [{ title: 'My site', url: 'https://example.com', order: 0 }],
296
+ });
297
+
298
+ // Partial update
299
+ const updated = await pocketsflow.creatorPages.update({ creatorBio: 'Updated' });
300
+
301
+ // Usernames
302
+ await pocketsflow.creatorPages.checkUsername('jane');
303
+ await pocketsflow.creatorPages.updateUsername('jane');
304
+
305
+ await pocketsflow.creatorPages.delete();
306
+ ```
307
+
308
+ ### Images
309
+
310
+ ```typescript
311
+ import { readFile } from 'node:fs/promises';
312
+
313
+ const { imageUrl } = await pocketsflow.images.upload(
314
+ await readFile('./cover.png'),
315
+ 'cover.png'
316
+ );
317
+ ```
318
+
319
+ ### Newsletters
320
+
321
+ ```typescript
322
+ // Send a one-off email to up to 100 recipients (requires a verified sender)
323
+ const result = await pocketsflow.newsletters.send({
324
+ to: ['a@example.com', 'b@example.com'],
325
+ subject: 'Hello',
326
+ html: '<h1>Hi there</h1>',
327
+ });
328
+ console.log(result.id, result.accepted);
329
+
330
+ // Posts
331
+ const posts = await pocketsflow.newsletters.posts.list();
332
+ const post = await pocketsflow.newsletters.posts.create({
333
+ name: 'March update',
334
+ subject: 'What shipped in March',
335
+ preview: 'New features inside',
336
+ fromName: 'Jane',
337
+ contentHtml: '<p>...</p>',
338
+ });
339
+ await pocketsflow.newsletters.posts.update(post._id, { subject: 'Revised' });
340
+ await pocketsflow.newsletters.posts.send(post._id);
341
+ await pocketsflow.newsletters.posts.delete(post._id);
342
+
343
+ // Subscribers
344
+ const subs = await pocketsflow.newsletters.subscribers.list();
345
+ await pocketsflow.newsletters.subscribers.get('subscriber_id');
346
+ await pocketsflow.newsletters.subscribers.delete('subscriber_id');
347
+ ```
348
+
349
+ A post needs `subject`, `preview`, `fromName` and `contentHtml` before it can
350
+ leave `draft`. Posts that have already been sent cannot be edited.
351
+
222
352
  ### Webhooks
223
353
 
224
354
  ```typescript