Skip to content

Commit f5e2ee7

Browse files
committed
Usage
1 parent 90c8bd0 commit f5e2ee7

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Hand-crafted from their docs, with JSDoc when appropriate and nullability manual
66
import { Webhook } from "@puzzmo/revenue-cat-webhook-types"
77

88
const handler = (req: Webhook) => {
9-
switch (req.type) {
9+
switch (req.event.type) {
1010
case "INITIAL_PURCHASE":
1111
// req as WebhookInitialPurchase
1212
break

index.d.ts

+17-13
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@
99
*
1010
* @see https://www.revenuecat.com/docs/integrations/webhooks/event-types-and-fields
1111
*/
12-
export type Webhook =
13-
| WebhookInitialPurchase
14-
| WebhookRenewal
15-
| WebhookCancellation
16-
| WebhookUnCancellation
17-
| WebhookNonRenewingPurchase
18-
| WebhookExpiration
19-
| WebhookSubscriptionPaused
20-
| WebhookBillingIssue
21-
| WebhookProductChange
22-
| WebhookSubscriptionExtended
23-
| WebhookTemporaryEntitlementGrant
12+
export type Webhook = {
13+
api_version: string
14+
event:
15+
| WebhookInitialPurchase
16+
| WebhookRenewal
17+
| WebhookCancellation
18+
| WebhookUnCancellation
19+
| WebhookNonRenewingPurchase
20+
| WebhookExpiration
21+
| WebhookSubscriptionPaused
22+
| WebhookBillingIssue
23+
| WebhookProductChange
24+
| WebhookSubscriptionExtended
25+
| WebhookTemporaryEntitlementGrant
26+
}
2427

2528
// Initially based on the samples from https://www.revenuecat.com/docs/integrations/webhooks/sample-events
2629
// There is generally a base object which most webhooks use, and then have a unique type and one-or-more unique fields.
@@ -48,6 +51,7 @@ interface WebhookBase {
4851
currency: string
4952
price: number
5053
price_in_purchased_currency: number
54+
renewal_number: null | number
5155
subscriber_attributes: Attributes
5256
store: Store
5357
takehome_percentage?: number
@@ -126,7 +130,7 @@ export interface WebhookBillingIssue extends WebhookBase {
126130
*/
127131
export interface WebhookProductChange extends WebhookBase {
128132
type: "PRODUCT_CHANGE"
129-
new_product_id: string
133+
new_product_id?: string
130134
}
131135

132136
/**

package.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
{
22
"name": "@puzzmo/revenue-cat-webhook-types",
3-
"version": "0.1.0",
3+
"version": "0.3.0",
44
"description": "TypeScript types for RevenueCat Webhooks. Hand-crafted from their docs, with JSDoc when appropriate and nullability manually added.",
55
"repository": {
66
"url": "https://github.com/puzzmo-com/revenue-cat-webhook-types"
77
},
8-
"license": "MIT",
9-
"publishConfig": {
10-
"provenance": true
11-
}
8+
"license": "MIT"
129
}

0 commit comments

Comments
 (0)