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 CHANGED
@@ -168,10 +168,6 @@ 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');
175
171
  ```
176
172
 
177
173
  ### Upsells
@@ -204,151 +200,42 @@ const updated = await pocketsflow.upsells.update('upsell_id', {
204
200
  await pocketsflow.upsells.delete('upsell_id');
205
201
  ```
206
202
 
207
- ### Subscription Offers
203
+ ### Subscriptions
208
204
 
209
- Your subscription **offers** — the recurring products you sell.
205
+ The `subscriptions` namespace manages buyer subscriptions. Subscription offers
206
+ (the recurring products you sell) use `subscriptionOffers`:
210
207
 
211
208
  ```typescript
212
- // List all subscription offers
213
- const offers = await pocketsflow.subscriptionOffers.list();
209
+ // Create a subscription offer
210
+ const newOffer = await pocketsflow.subscriptionOffers.create({
211
+ name: 'Pro Membership',
212
+ price: 29,
213
+ frequency: 'monthly',
214
+ trialPeriod: 7,
215
+ });
214
216
 
215
- // Get one offer
216
- const offer = await pocketsflow.subscriptionOffers.get('offer_id');
217
+ // List and get subscription offers
218
+ const offers = await pocketsflow.subscriptionOffers.list();
219
+ const offer = await pocketsflow.subscriptionOffers.get(newOffer._id);
217
220
  ```
218
221
 
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.
223
-
224
222
  ```typescript
225
- // List subscribers
226
- const { subscribers, pagination } = await pocketsflow.subscribers.list({
227
- status: 'active',
223
+ // List subscription customers
224
+ const subscriptions = await pocketsflow.subscriptions.list({
228
225
  page: 1,
229
226
  pageSize: 20,
230
227
  });
231
228
 
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
235
-
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)
273
-
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 });
229
+ // Get a subscription
280
230
  const subscription = await pocketsflow.subscriptions.get('subscription_id');
281
- await pocketsflow.subscriptions.cancel('stripe_subscription_id');
282
- await pocketsflow.subscriptions.refund('stripe_subscription_id');
283
- ```
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
231
 
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
232
+ // Cancel a subscription
233
+ await pocketsflow.subscriptions.cancel('stripe_subscription_id');
320
234
 
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');
235
+ // Refund a subscription
236
+ await pocketsflow.subscriptions.refund('stripe_subscription_id');
347
237
  ```
348
238
 
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
-
352
239
  ### Webhooks
353
240
 
354
241
  ```typescript