@checkoutpage/sdk 0.1.11 → 0.1.12
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 +67 -1
- package/dist/index.d.mts +54 -25
- package/dist/index.d.ts +54 -25
- package/dist/index.js +31 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -83,7 +83,22 @@ With pagination and filtering:
|
|
|
83
83
|
const results = await checkoutpage.coupons.list({
|
|
84
84
|
search: '10off',
|
|
85
85
|
limit: 50,
|
|
86
|
-
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
With cursor-based pagination:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
const firstPage = await checkoutpage.coupons.list({ limit: 50 });
|
|
93
|
+
|
|
94
|
+
const nextPage = await checkoutpage.coupons.list({
|
|
95
|
+
limit: 50,
|
|
96
|
+
starting_after: firstPage.data[firstPage.data.length - 1].id,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const previousPage = await checkoutpage.coupons.list({
|
|
100
|
+
limit: 50,
|
|
101
|
+
ending_before: nextPage.data[0].id,
|
|
87
102
|
});
|
|
88
103
|
```
|
|
89
104
|
|
|
@@ -100,6 +115,41 @@ const results = await checkoutpage.coupons.create({
|
|
|
100
115
|
});
|
|
101
116
|
```
|
|
102
117
|
|
|
118
|
+
### Subscriptions
|
|
119
|
+
|
|
120
|
+
#### List subscriptions
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
const results = await checkoutpage.subscriptions.list();
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
With pagination and filtering:
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
const results = await checkoutpage.subscriptions.list({
|
|
130
|
+
search: 'customer@example.com',
|
|
131
|
+
status: 'active',
|
|
132
|
+
pageId: '67fcbdac6a91c25ef2d3534a',
|
|
133
|
+
limit: 50,
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
With cursor-based pagination:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
const firstPage = await checkoutpage.subscriptions.list({ limit: 50 });
|
|
141
|
+
|
|
142
|
+
const nextPage = await checkoutpage.subscriptions.list({
|
|
143
|
+
limit: 50,
|
|
144
|
+
starting_after: firstPage.data[firstPage.data.length - 1].id,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const previousPage = await checkoutpage.subscriptions.list({
|
|
148
|
+
limit: 50,
|
|
149
|
+
ending_before: nextPage.data[0].id,
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
103
153
|
### Payments
|
|
104
154
|
|
|
105
155
|
#### List payments
|
|
@@ -108,6 +158,22 @@ const results = await checkoutpage.coupons.create({
|
|
|
108
158
|
const results = await checkoutpage.payments.list();
|
|
109
159
|
```
|
|
110
160
|
|
|
161
|
+
With cursor-based pagination:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
const firstPage = await checkoutpage.payments.list({ limit: 50 });
|
|
165
|
+
|
|
166
|
+
const nextPage = await checkoutpage.payments.list({
|
|
167
|
+
limit: 50,
|
|
168
|
+
starting_after: firstPage.data[firstPage.data.length - 1].id,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const previousPage = await checkoutpage.payments.list({
|
|
172
|
+
limit: 50,
|
|
173
|
+
ending_before: firstPage.data[0].id,
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
111
177
|
## Error Handling
|
|
112
178
|
|
|
113
179
|
The SDK provides typed error classes for different error scenarios:
|
package/dist/index.d.mts
CHANGED
|
@@ -575,16 +575,16 @@ interface operations {
|
|
|
575
575
|
metadata?: {
|
|
576
576
|
key: string;
|
|
577
577
|
value: string;
|
|
578
|
-
/** Format: date */
|
|
578
|
+
/** Format: date-time */
|
|
579
579
|
addedAt: string;
|
|
580
580
|
}[];
|
|
581
|
-
/** Format: date */
|
|
581
|
+
/** Format: date-time */
|
|
582
582
|
orderedAt: string;
|
|
583
|
-
/** Format: date */
|
|
583
|
+
/** Format: date-time */
|
|
584
584
|
canceledAt?: string;
|
|
585
|
-
/** Format: date */
|
|
585
|
+
/** Format: date-time */
|
|
586
586
|
createdAt: string;
|
|
587
|
-
/** Format: date */
|
|
587
|
+
/** Format: date-time */
|
|
588
588
|
updatedAt: string;
|
|
589
589
|
};
|
|
590
590
|
message?: string;
|
|
@@ -638,11 +638,15 @@ interface operations {
|
|
|
638
638
|
"events/bookings": {
|
|
639
639
|
parameters: {
|
|
640
640
|
query?: {
|
|
641
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
642
|
+
limit?: string;
|
|
643
|
+
/** @description A cursor value specifying the ObjectId of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with ending_before. */
|
|
644
|
+
starting_after?: string;
|
|
645
|
+
/** @description A cursor value specifying the ObjectId of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with starting_after. */
|
|
646
|
+
ending_before?: string;
|
|
641
647
|
search?: string;
|
|
642
648
|
status?: "created" | "pending" | "unpaid" | "partially_paid" | "paid" | "canceled" | "failed" | "partial_refund" | "refunded" | "draft" | "draft_expired";
|
|
643
649
|
pageId?: string;
|
|
644
|
-
limit?: string;
|
|
645
|
-
skip?: string;
|
|
646
650
|
};
|
|
647
651
|
header?: never;
|
|
648
652
|
path?: never;
|
|
@@ -703,9 +707,13 @@ interface operations {
|
|
|
703
707
|
"customers/list": {
|
|
704
708
|
parameters: {
|
|
705
709
|
query?: {
|
|
706
|
-
|
|
710
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
707
711
|
limit?: string;
|
|
708
|
-
|
|
712
|
+
/** @description A cursor value specifying the ObjectId of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with ending_before. */
|
|
713
|
+
starting_after?: string;
|
|
714
|
+
/** @description A cursor value specifying the ObjectId of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with starting_after. */
|
|
715
|
+
ending_before?: string;
|
|
716
|
+
search?: string;
|
|
709
717
|
};
|
|
710
718
|
header?: never;
|
|
711
719
|
path?: never;
|
|
@@ -832,9 +840,13 @@ interface operations {
|
|
|
832
840
|
"coupons/list": {
|
|
833
841
|
parameters: {
|
|
834
842
|
query?: {
|
|
835
|
-
|
|
843
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
836
844
|
limit?: string;
|
|
837
|
-
|
|
845
|
+
/** @description A cursor value specifying the ObjectId of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with ending_before. */
|
|
846
|
+
starting_after?: string;
|
|
847
|
+
/** @description A cursor value specifying the ObjectId of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with starting_after. */
|
|
848
|
+
ending_before?: string;
|
|
849
|
+
search?: string;
|
|
838
850
|
};
|
|
839
851
|
header?: never;
|
|
840
852
|
path?: never;
|
|
@@ -1018,11 +1030,15 @@ interface operations {
|
|
|
1018
1030
|
"subscriptions/list": {
|
|
1019
1031
|
parameters: {
|
|
1020
1032
|
query?: {
|
|
1033
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
1034
|
+
limit?: string;
|
|
1035
|
+
/** @description A cursor value specifying the ObjectId of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with ending_before. */
|
|
1036
|
+
starting_after?: string;
|
|
1037
|
+
/** @description A cursor value specifying the ObjectId of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with starting_after. */
|
|
1038
|
+
ending_before?: string;
|
|
1021
1039
|
search?: string;
|
|
1022
1040
|
pageId?: string;
|
|
1023
1041
|
status?: string;
|
|
1024
|
-
limit?: string;
|
|
1025
|
-
skip?: string;
|
|
1026
1042
|
};
|
|
1027
1043
|
header?: never;
|
|
1028
1044
|
path?: never;
|
|
@@ -1174,9 +1190,8 @@ interface operations {
|
|
|
1174
1190
|
screenWidth?: number;
|
|
1175
1191
|
visitId?: string;
|
|
1176
1192
|
queryParameters?: {
|
|
1177
|
-
key: string;
|
|
1178
|
-
|
|
1179
|
-
}[];
|
|
1193
|
+
[key: string]: string;
|
|
1194
|
+
};
|
|
1180
1195
|
stripePaymentIntentId?: string;
|
|
1181
1196
|
stripePaymentIntentClientSecret?: string;
|
|
1182
1197
|
stripeSetupIntentId?: string;
|
|
@@ -1260,11 +1275,15 @@ interface operations {
|
|
|
1260
1275
|
"payments/list": {
|
|
1261
1276
|
parameters: {
|
|
1262
1277
|
query?: {
|
|
1278
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
1279
|
+
limit?: string;
|
|
1280
|
+
/** @description A cursor value specifying the ObjectId of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with ending_before. */
|
|
1281
|
+
starting_after?: string;
|
|
1282
|
+
/** @description A cursor value specifying the ObjectId of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with starting_after. */
|
|
1283
|
+
ending_before?: string;
|
|
1263
1284
|
search?: string;
|
|
1264
1285
|
status?: "created" | "pending" | "unpaid" | "partially_paid" | "paid" | "canceled" | "failed" | "partial_refund" | "refunded" | "draft" | "draft_expired";
|
|
1265
1286
|
pageId?: string;
|
|
1266
|
-
limit?: string;
|
|
1267
|
-
skip?: string;
|
|
1268
1287
|
};
|
|
1269
1288
|
header?: never;
|
|
1270
1289
|
path?: never;
|
|
@@ -1617,9 +1636,8 @@ interface operations {
|
|
|
1617
1636
|
type Customer = operations['customers/get']['responses'][200]['content']['application/json'];
|
|
1618
1637
|
type CustomerList = operations['customers/list']['responses'][200]['content']['application/json'];
|
|
1619
1638
|
type CustomerListArgs = operations['customers/list']['parameters']['query'];
|
|
1620
|
-
type CustomerListParams = Omit<NonNullable<CustomerListArgs>, 'limit'
|
|
1639
|
+
type CustomerListParams = Omit<NonNullable<CustomerListArgs>, 'limit'> & {
|
|
1621
1640
|
limit?: number;
|
|
1622
|
-
skip?: number;
|
|
1623
1641
|
};
|
|
1624
1642
|
type Address = NonNullable<Customer['data']['address']>;
|
|
1625
1643
|
type Shipping = NonNullable<Customer['data']['shipping']>;
|
|
@@ -1627,9 +1645,8 @@ type CouponList = operations['coupons/list']['responses'][200]['content']['appli
|
|
|
1627
1645
|
type Coupon = CouponList['data'][number];
|
|
1628
1646
|
type CreateCouponResponse = operations['coupons/create']['responses']['201']['content']['application/json'];
|
|
1629
1647
|
type CouponListArgs = operations['coupons/list']['parameters']['query'];
|
|
1630
|
-
type CouponListParams = Omit<NonNullable<CouponListArgs>, 'limit'
|
|
1648
|
+
type CouponListParams = Omit<NonNullable<CouponListArgs>, 'limit'> & {
|
|
1631
1649
|
limit?: number;
|
|
1632
|
-
skip?: number;
|
|
1633
1650
|
};
|
|
1634
1651
|
type CouponCreateArgs = NonNullable<operations['coupons/create']['requestBody']>['content']['application/json'];
|
|
1635
1652
|
type NonRepeatingParams = CouponCreateArgs & {
|
|
@@ -1656,9 +1673,14 @@ type CreateCouponParams = AmountNonRepeating | AmountRepeating | PercentNonRepea
|
|
|
1656
1673
|
type PaymentList = operations['payments/list']['responses'][200]['content']['application/json'];
|
|
1657
1674
|
type Payment = PaymentList['data'][number];
|
|
1658
1675
|
type PaymentListArgs = operations['payments/list']['parameters']['query'];
|
|
1659
|
-
type PaymentListParams = Omit<NonNullable<PaymentListArgs>, 'limit'
|
|
1676
|
+
type PaymentListParams = Omit<NonNullable<PaymentListArgs>, 'limit'> & {
|
|
1677
|
+
limit?: number;
|
|
1678
|
+
};
|
|
1679
|
+
type SubscriptionList = operations['subscriptions/list']['responses'][200]['content']['application/json'];
|
|
1680
|
+
type Subscription = SubscriptionList['data'][number];
|
|
1681
|
+
type SubscriptionListArgs = operations['subscriptions/list']['parameters']['query'];
|
|
1682
|
+
type SubscriptionListParams = Omit<NonNullable<SubscriptionListArgs>, 'limit'> & {
|
|
1660
1683
|
limit?: number;
|
|
1661
|
-
skip?: number;
|
|
1662
1684
|
};
|
|
1663
1685
|
|
|
1664
1686
|
declare class CustomerResource {
|
|
@@ -1681,6 +1703,12 @@ declare class PaymentResource {
|
|
|
1681
1703
|
list(args?: PaymentListParams): Promise<PaymentList>;
|
|
1682
1704
|
}
|
|
1683
1705
|
|
|
1706
|
+
declare class SubscriptionResource {
|
|
1707
|
+
private client;
|
|
1708
|
+
constructor(client: CheckoutPageApiClient);
|
|
1709
|
+
list(args?: SubscriptionListParams): Promise<SubscriptionList>;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1684
1712
|
declare class CheckoutPageError extends Error {
|
|
1685
1713
|
constructor(message: string);
|
|
1686
1714
|
}
|
|
@@ -1709,9 +1737,10 @@ declare class CheckoutPageClient {
|
|
|
1709
1737
|
readonly customers: CustomerResource;
|
|
1710
1738
|
readonly coupons: CouponResource;
|
|
1711
1739
|
readonly payments: PaymentResource;
|
|
1740
|
+
readonly subscriptions: SubscriptionResource;
|
|
1712
1741
|
private readonly client;
|
|
1713
1742
|
constructor(options: CheckoutPageApiClientOptions);
|
|
1714
1743
|
}
|
|
1715
1744
|
declare const createCheckoutPageClient: (options: CheckoutPageApiClientOptions) => CheckoutPageClient;
|
|
1716
1745
|
|
|
1717
|
-
export { APIError, type Address, AuthenticationError, type CheckoutPageApiClientOptions, CheckoutPageClient, CheckoutPageError, ConflictError, type Coupon, type CouponList, type Customer, NotFoundError, type Payment, type PaymentList, RateLimitError, type Shipping, ValidationError, createCheckoutPageClient };
|
|
1746
|
+
export { APIError, type Address, AuthenticationError, type CheckoutPageApiClientOptions, CheckoutPageClient, CheckoutPageError, ConflictError, type Coupon, type CouponList, type Customer, NotFoundError, type Payment, type PaymentList, RateLimitError, type Shipping, type Subscription, type SubscriptionList, ValidationError, createCheckoutPageClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -575,16 +575,16 @@ interface operations {
|
|
|
575
575
|
metadata?: {
|
|
576
576
|
key: string;
|
|
577
577
|
value: string;
|
|
578
|
-
/** Format: date */
|
|
578
|
+
/** Format: date-time */
|
|
579
579
|
addedAt: string;
|
|
580
580
|
}[];
|
|
581
|
-
/** Format: date */
|
|
581
|
+
/** Format: date-time */
|
|
582
582
|
orderedAt: string;
|
|
583
|
-
/** Format: date */
|
|
583
|
+
/** Format: date-time */
|
|
584
584
|
canceledAt?: string;
|
|
585
|
-
/** Format: date */
|
|
585
|
+
/** Format: date-time */
|
|
586
586
|
createdAt: string;
|
|
587
|
-
/** Format: date */
|
|
587
|
+
/** Format: date-time */
|
|
588
588
|
updatedAt: string;
|
|
589
589
|
};
|
|
590
590
|
message?: string;
|
|
@@ -638,11 +638,15 @@ interface operations {
|
|
|
638
638
|
"events/bookings": {
|
|
639
639
|
parameters: {
|
|
640
640
|
query?: {
|
|
641
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
642
|
+
limit?: string;
|
|
643
|
+
/** @description A cursor value specifying the ObjectId of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with ending_before. */
|
|
644
|
+
starting_after?: string;
|
|
645
|
+
/** @description A cursor value specifying the ObjectId of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with starting_after. */
|
|
646
|
+
ending_before?: string;
|
|
641
647
|
search?: string;
|
|
642
648
|
status?: "created" | "pending" | "unpaid" | "partially_paid" | "paid" | "canceled" | "failed" | "partial_refund" | "refunded" | "draft" | "draft_expired";
|
|
643
649
|
pageId?: string;
|
|
644
|
-
limit?: string;
|
|
645
|
-
skip?: string;
|
|
646
650
|
};
|
|
647
651
|
header?: never;
|
|
648
652
|
path?: never;
|
|
@@ -703,9 +707,13 @@ interface operations {
|
|
|
703
707
|
"customers/list": {
|
|
704
708
|
parameters: {
|
|
705
709
|
query?: {
|
|
706
|
-
|
|
710
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
707
711
|
limit?: string;
|
|
708
|
-
|
|
712
|
+
/** @description A cursor value specifying the ObjectId of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with ending_before. */
|
|
713
|
+
starting_after?: string;
|
|
714
|
+
/** @description A cursor value specifying the ObjectId of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with starting_after. */
|
|
715
|
+
ending_before?: string;
|
|
716
|
+
search?: string;
|
|
709
717
|
};
|
|
710
718
|
header?: never;
|
|
711
719
|
path?: never;
|
|
@@ -832,9 +840,13 @@ interface operations {
|
|
|
832
840
|
"coupons/list": {
|
|
833
841
|
parameters: {
|
|
834
842
|
query?: {
|
|
835
|
-
|
|
843
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
836
844
|
limit?: string;
|
|
837
|
-
|
|
845
|
+
/** @description A cursor value specifying the ObjectId of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with ending_before. */
|
|
846
|
+
starting_after?: string;
|
|
847
|
+
/** @description A cursor value specifying the ObjectId of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with starting_after. */
|
|
848
|
+
ending_before?: string;
|
|
849
|
+
search?: string;
|
|
838
850
|
};
|
|
839
851
|
header?: never;
|
|
840
852
|
path?: never;
|
|
@@ -1018,11 +1030,15 @@ interface operations {
|
|
|
1018
1030
|
"subscriptions/list": {
|
|
1019
1031
|
parameters: {
|
|
1020
1032
|
query?: {
|
|
1033
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
1034
|
+
limit?: string;
|
|
1035
|
+
/** @description A cursor value specifying the ObjectId of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with ending_before. */
|
|
1036
|
+
starting_after?: string;
|
|
1037
|
+
/** @description A cursor value specifying the ObjectId of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with starting_after. */
|
|
1038
|
+
ending_before?: string;
|
|
1021
1039
|
search?: string;
|
|
1022
1040
|
pageId?: string;
|
|
1023
1041
|
status?: string;
|
|
1024
|
-
limit?: string;
|
|
1025
|
-
skip?: string;
|
|
1026
1042
|
};
|
|
1027
1043
|
header?: never;
|
|
1028
1044
|
path?: never;
|
|
@@ -1174,9 +1190,8 @@ interface operations {
|
|
|
1174
1190
|
screenWidth?: number;
|
|
1175
1191
|
visitId?: string;
|
|
1176
1192
|
queryParameters?: {
|
|
1177
|
-
key: string;
|
|
1178
|
-
|
|
1179
|
-
}[];
|
|
1193
|
+
[key: string]: string;
|
|
1194
|
+
};
|
|
1180
1195
|
stripePaymentIntentId?: string;
|
|
1181
1196
|
stripePaymentIntentClientSecret?: string;
|
|
1182
1197
|
stripeSetupIntentId?: string;
|
|
@@ -1260,11 +1275,15 @@ interface operations {
|
|
|
1260
1275
|
"payments/list": {
|
|
1261
1276
|
parameters: {
|
|
1262
1277
|
query?: {
|
|
1278
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
1279
|
+
limit?: string;
|
|
1280
|
+
/** @description A cursor value specifying the ObjectId of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with ending_before. */
|
|
1281
|
+
starting_after?: string;
|
|
1282
|
+
/** @description A cursor value specifying the ObjectId of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with starting_after. */
|
|
1283
|
+
ending_before?: string;
|
|
1263
1284
|
search?: string;
|
|
1264
1285
|
status?: "created" | "pending" | "unpaid" | "partially_paid" | "paid" | "canceled" | "failed" | "partial_refund" | "refunded" | "draft" | "draft_expired";
|
|
1265
1286
|
pageId?: string;
|
|
1266
|
-
limit?: string;
|
|
1267
|
-
skip?: string;
|
|
1268
1287
|
};
|
|
1269
1288
|
header?: never;
|
|
1270
1289
|
path?: never;
|
|
@@ -1617,9 +1636,8 @@ interface operations {
|
|
|
1617
1636
|
type Customer = operations['customers/get']['responses'][200]['content']['application/json'];
|
|
1618
1637
|
type CustomerList = operations['customers/list']['responses'][200]['content']['application/json'];
|
|
1619
1638
|
type CustomerListArgs = operations['customers/list']['parameters']['query'];
|
|
1620
|
-
type CustomerListParams = Omit<NonNullable<CustomerListArgs>, 'limit'
|
|
1639
|
+
type CustomerListParams = Omit<NonNullable<CustomerListArgs>, 'limit'> & {
|
|
1621
1640
|
limit?: number;
|
|
1622
|
-
skip?: number;
|
|
1623
1641
|
};
|
|
1624
1642
|
type Address = NonNullable<Customer['data']['address']>;
|
|
1625
1643
|
type Shipping = NonNullable<Customer['data']['shipping']>;
|
|
@@ -1627,9 +1645,8 @@ type CouponList = operations['coupons/list']['responses'][200]['content']['appli
|
|
|
1627
1645
|
type Coupon = CouponList['data'][number];
|
|
1628
1646
|
type CreateCouponResponse = operations['coupons/create']['responses']['201']['content']['application/json'];
|
|
1629
1647
|
type CouponListArgs = operations['coupons/list']['parameters']['query'];
|
|
1630
|
-
type CouponListParams = Omit<NonNullable<CouponListArgs>, 'limit'
|
|
1648
|
+
type CouponListParams = Omit<NonNullable<CouponListArgs>, 'limit'> & {
|
|
1631
1649
|
limit?: number;
|
|
1632
|
-
skip?: number;
|
|
1633
1650
|
};
|
|
1634
1651
|
type CouponCreateArgs = NonNullable<operations['coupons/create']['requestBody']>['content']['application/json'];
|
|
1635
1652
|
type NonRepeatingParams = CouponCreateArgs & {
|
|
@@ -1656,9 +1673,14 @@ type CreateCouponParams = AmountNonRepeating | AmountRepeating | PercentNonRepea
|
|
|
1656
1673
|
type PaymentList = operations['payments/list']['responses'][200]['content']['application/json'];
|
|
1657
1674
|
type Payment = PaymentList['data'][number];
|
|
1658
1675
|
type PaymentListArgs = operations['payments/list']['parameters']['query'];
|
|
1659
|
-
type PaymentListParams = Omit<NonNullable<PaymentListArgs>, 'limit'
|
|
1676
|
+
type PaymentListParams = Omit<NonNullable<PaymentListArgs>, 'limit'> & {
|
|
1677
|
+
limit?: number;
|
|
1678
|
+
};
|
|
1679
|
+
type SubscriptionList = operations['subscriptions/list']['responses'][200]['content']['application/json'];
|
|
1680
|
+
type Subscription = SubscriptionList['data'][number];
|
|
1681
|
+
type SubscriptionListArgs = operations['subscriptions/list']['parameters']['query'];
|
|
1682
|
+
type SubscriptionListParams = Omit<NonNullable<SubscriptionListArgs>, 'limit'> & {
|
|
1660
1683
|
limit?: number;
|
|
1661
|
-
skip?: number;
|
|
1662
1684
|
};
|
|
1663
1685
|
|
|
1664
1686
|
declare class CustomerResource {
|
|
@@ -1681,6 +1703,12 @@ declare class PaymentResource {
|
|
|
1681
1703
|
list(args?: PaymentListParams): Promise<PaymentList>;
|
|
1682
1704
|
}
|
|
1683
1705
|
|
|
1706
|
+
declare class SubscriptionResource {
|
|
1707
|
+
private client;
|
|
1708
|
+
constructor(client: CheckoutPageApiClient);
|
|
1709
|
+
list(args?: SubscriptionListParams): Promise<SubscriptionList>;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1684
1712
|
declare class CheckoutPageError extends Error {
|
|
1685
1713
|
constructor(message: string);
|
|
1686
1714
|
}
|
|
@@ -1709,9 +1737,10 @@ declare class CheckoutPageClient {
|
|
|
1709
1737
|
readonly customers: CustomerResource;
|
|
1710
1738
|
readonly coupons: CouponResource;
|
|
1711
1739
|
readonly payments: PaymentResource;
|
|
1740
|
+
readonly subscriptions: SubscriptionResource;
|
|
1712
1741
|
private readonly client;
|
|
1713
1742
|
constructor(options: CheckoutPageApiClientOptions);
|
|
1714
1743
|
}
|
|
1715
1744
|
declare const createCheckoutPageClient: (options: CheckoutPageApiClientOptions) => CheckoutPageClient;
|
|
1716
1745
|
|
|
1717
|
-
export { APIError, type Address, AuthenticationError, type CheckoutPageApiClientOptions, CheckoutPageClient, CheckoutPageError, ConflictError, type Coupon, type CouponList, type Customer, NotFoundError, type Payment, type PaymentList, RateLimitError, type Shipping, ValidationError, createCheckoutPageClient };
|
|
1746
|
+
export { APIError, type Address, AuthenticationError, type CheckoutPageApiClientOptions, CheckoutPageClient, CheckoutPageError, ConflictError, type Coupon, type CouponList, type Customer, NotFoundError, type Payment, type PaymentList, RateLimitError, type Shipping, type Subscription, type SubscriptionList, ValidationError, createCheckoutPageClient };
|
package/dist/index.js
CHANGED
|
@@ -153,9 +153,10 @@ var CustomerResource = class {
|
|
|
153
153
|
}
|
|
154
154
|
async list(args = {}) {
|
|
155
155
|
const query = {
|
|
156
|
-
|
|
156
|
+
search: args.search,
|
|
157
157
|
limit: args.limit?.toString(),
|
|
158
|
-
|
|
158
|
+
starting_after: args.starting_after,
|
|
159
|
+
ending_before: args.ending_before
|
|
159
160
|
};
|
|
160
161
|
return this.client.request({
|
|
161
162
|
method: "GET",
|
|
@@ -174,7 +175,8 @@ var CouponResource = class {
|
|
|
174
175
|
const query = {
|
|
175
176
|
search: args.search,
|
|
176
177
|
limit: args.limit?.toString(),
|
|
177
|
-
|
|
178
|
+
starting_after: args.starting_after,
|
|
179
|
+
ending_before: args.ending_before
|
|
178
180
|
};
|
|
179
181
|
return this.client.request({
|
|
180
182
|
method: "GET",
|
|
@@ -228,7 +230,8 @@ var PaymentResource = class {
|
|
|
228
230
|
status: args.status,
|
|
229
231
|
pageId: args.pageId,
|
|
230
232
|
limit: args.limit?.toString(),
|
|
231
|
-
|
|
233
|
+
starting_after: args.starting_after,
|
|
234
|
+
ending_before: args.ending_before
|
|
232
235
|
};
|
|
233
236
|
return this.client.request({
|
|
234
237
|
method: "GET",
|
|
@@ -238,17 +241,41 @@ var PaymentResource = class {
|
|
|
238
241
|
}
|
|
239
242
|
};
|
|
240
243
|
|
|
244
|
+
// src/resources/subscriptions/subscriptions.ts
|
|
245
|
+
var SubscriptionResource = class {
|
|
246
|
+
constructor(client) {
|
|
247
|
+
this.client = client;
|
|
248
|
+
}
|
|
249
|
+
async list(args = {}) {
|
|
250
|
+
const query = {
|
|
251
|
+
search: args.search,
|
|
252
|
+
pageId: args.pageId,
|
|
253
|
+
status: args.status,
|
|
254
|
+
limit: args.limit?.toString(),
|
|
255
|
+
starting_after: args.starting_after,
|
|
256
|
+
ending_before: args.ending_before
|
|
257
|
+
};
|
|
258
|
+
return this.client.request({
|
|
259
|
+
method: "GET",
|
|
260
|
+
query,
|
|
261
|
+
path: "/v1/subscriptions/"
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
241
266
|
// src/index.ts
|
|
242
267
|
var CheckoutPageClient = class {
|
|
243
268
|
customers;
|
|
244
269
|
coupons;
|
|
245
270
|
payments;
|
|
271
|
+
subscriptions;
|
|
246
272
|
client;
|
|
247
273
|
constructor(options) {
|
|
248
274
|
this.client = new CheckoutPageApiClient(options);
|
|
249
275
|
this.customers = new CustomerResource(this.client);
|
|
250
276
|
this.coupons = new CouponResource(this.client);
|
|
251
277
|
this.payments = new PaymentResource(this.client);
|
|
278
|
+
this.subscriptions = new SubscriptionResource(this.client);
|
|
252
279
|
}
|
|
253
280
|
};
|
|
254
281
|
var createCheckoutPageClient = (options) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/resources/customers/customers.ts","../src/resources/coupons/coupons.ts","../src/resources/payments/payments.ts","../src/index.ts"],"names":[],"mappings":";;;AAAO,IAAM,iBAAA,GAAN,MAAM,kBAAA,SAA0B,KAAA,CAAM;AAAA,EAC3C,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,mBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,kBAAA,CAAkB,SAAS,CAAA;AAAA,EACzD;AACF;AAEO,IAAM,mBAAA,GAAN,MAAM,oBAAA,SAA4B,iBAAA,CAAkB;AAAA,EACzD,WAAA,CAAY,UAAU,mDAAA,EAAqD;AACzE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,qBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,oBAAA,CAAoB,SAAS,CAAA;AAAA,EAC3D;AACF;AAEO,IAAM,aAAA,GAAN,MAAM,cAAA,SAA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AAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF,CAAA;;;AChBO,IAAM,qBAAN,MAAyB;AAAA,EACd,SAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACC,MAAA;AAAA,EAEjB,YAAY,OAAA,EAAuC;AACjD,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,qBAAA,CAAsB,OAAO,CAAA;AAC/C,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,gBAAA,CAAiB,IAAA,CAAK,MAAM,CAAA;AACjD,IAAA,IAAA,CAAK,OAAA,GAAU,IAAI,cAAA,CAAe,IAAA,CAAK,MAAM,CAAA;AAC7C,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,eAAA,CAAgB,IAAA,CAAK,MAAM,CAAA;AAAA,EACjD;AACF;AAEO,IAAM,wBAAA,GAA2B,CAAC,OAAA,KAA0C;AACjF,EAAA,OAAO,IAAI,mBAAmB,OAAO,CAAA;AACvC","file":"index.js","sourcesContent":["export class CheckoutPageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'CheckoutPageError';\n Object.setPrototypeOf(this, CheckoutPageError.prototype);\n }\n}\n\nexport class AuthenticationError extends CheckoutPageError {\n constructor(message = 'Authentication failed. Please check your API key.') {\n super(message);\n this.name = 'AuthenticationError';\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\nexport class NotFoundError extends CheckoutPageError {\n constructor(message = 'The requested resource was not found.') {\n super(message);\n this.name = 'NotFoundError';\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n\nexport class ConflictError extends CheckoutPageError {\n constructor(message = 'Conflict - the created resource already exists.') {\n super(message);\n this.name = 'ConflictError';\n Object.setPrototypeOf(this, ConflictError.prototype);\n }\n}\n\nexport class RateLimitError extends CheckoutPageError {\n constructor(message = 'Rate limit exceeded. Please try again later.') {\n super(message);\n this.name = 'RateLimitError';\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\nexport class ValidationError extends CheckoutPageError {\n constructor(message = 'Validation failed.') {\n super(message);\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class APIError extends CheckoutPageError {\n public readonly statusCode: number;\n public readonly response?: unknown;\n\n constructor(message: string, statusCode: number, response?: unknown) {\n super(message);\n this.name = 'APIError';\n this.statusCode = statusCode;\n this.response = response;\n Object.setPrototypeOf(this, APIError.prototype);\n }\n}\n","import {\n APIError,\n AuthenticationError,\n ConflictError,\n NotFoundError,\n RateLimitError,\n ValidationError,\n} from './errors';\n\nexport interface CheckoutPageApiClientOptions {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport interface RequestOptions {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n path: string;\n body?: unknown;\n query?: Record<string, string | number | boolean | undefined>;\n}\n\nexport class CheckoutPageApiClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n\n constructor(options: CheckoutPageApiClientOptions) {\n if (!options.apiKey) {\n throw new Error('API key is required');\n }\n\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl || 'https://api.checkoutpage.com';\n }\n\n async request<T>(options: RequestOptions): Promise<T> {\n const url = this.buildUrl(options.path, options.query);\n\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@checkoutpage/sdk/0.1.0',\n };\n\n const fetchOptions: RequestInit = {\n method: options.method,\n headers,\n };\n\n if (options.body) {\n fetchOptions.body = JSON.stringify(options.body);\n }\n\n const response = await fetch(url, fetchOptions);\n return await this.handleResponse<T>(response);\n }\n\n private buildUrl(\n path: string,\n query?: Record<string, string | number | boolean | undefined>\n ): string {\n const url = new URL(path, this.baseUrl);\n\n if (query) {\n Object.entries(query).forEach(([key, value]) => {\n if (value !== undefined) {\n url.searchParams.append(key, String(value));\n }\n });\n }\n\n return url.toString();\n }\n\n private async handleResponse<T>(response: Response): Promise<T> {\n const contentType = response.headers.get('content-type');\n const isJson = contentType?.includes('application/json');\n\n let data: unknown;\n try {\n data = isJson ? await response.json() : await response.text();\n } catch {\n data = null;\n }\n\n if (!response.ok) {\n const message = this.extractErrorMessage(data);\n\n switch (response.status) {\n case 401:\n case 403:\n throw new AuthenticationError(message);\n case 404:\n throw new NotFoundError(message);\n case 409:\n throw new ConflictError(message);\n case 400:\n case 422:\n throw new ValidationError(message);\n case 429:\n throw new RateLimitError(message);\n default:\n throw new APIError(message, response.status, data);\n }\n }\n\n return data as T;\n }\n\n private extractErrorMessage(data: unknown): string {\n if (typeof data === 'object' && data !== null) {\n if ('message' in data && typeof data.message === 'string') {\n return data.message;\n }\n if ('error' in data && typeof data.error === 'string') {\n return data.error;\n }\n }\n return 'An unexpected error occurred';\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport type { Customer, CustomerList, CustomerListParams } from '../../types';\n\nexport class CustomerResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async get(customerId: string): Promise<Customer> {\n if (!customerId) {\n throw new Error('Customer ID is required');\n }\n\n return this.client.request<Customer>({\n method: 'GET',\n path: `/v1/customers/${customerId}`,\n });\n }\n\n async list(args: CustomerListParams = {}): Promise<CustomerList> {\n const query: Record<string, string | undefined> = {\n ...args,\n limit: args.limit?.toString(),\n skip: args.skip?.toString(),\n };\n\n return this.client.request<CustomerList>({\n method: 'GET',\n query,\n path: '/v1/customers/',\n });\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport {\n CouponList,\n CouponListParams,\n CreateCouponParams,\n CreateCouponResponse,\n} from '../../types';\n\nexport class CouponResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async list(args: CouponListParams = {}): Promise<CouponList> {\n const query: Record<string, string | undefined> = {\n search: args.search,\n limit: args.limit?.toString(),\n skip: args.skip?.toString(),\n };\n\n return this.client.request<CouponList>({\n method: 'GET',\n query,\n path: '/v1/coupons/',\n });\n }\n\n async create(params: CreateCouponParams): Promise<CreateCouponResponse> {\n const body: Record<string, unknown> = {\n label: params.label,\n code: params.code,\n duration: params.duration,\n };\n\n if (params.duration === 'repeating') {\n body.durationInMonths = (params as any).durationInMonths;\n }\n\n if (params.appliesToSetupFee !== undefined) {\n body.appliesToSetupFee = params.appliesToSetupFee;\n }\n if (params.pageIds !== undefined) {\n body.pageIds = params.pageIds;\n }\n if (params.maxRedemptions !== undefined) {\n body.maxRedemptions = params.maxRedemptions;\n }\n if (params.redeemBy !== undefined) {\n body.redeemBy = params.redeemBy;\n }\n\n if (params.type === 'amount') {\n body.amountOff = params.amountOff;\n body.currency = params.currency;\n } else {\n body.percentOff = params.percentOff;\n }\n\n return this.client.request<CreateCouponResponse>({\n method: 'POST',\n path: '/v1/coupons/',\n body,\n });\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport type { PaymentList, PaymentListParams } from '../../types';\n\nexport class PaymentResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async list(args: PaymentListParams = {}): Promise<PaymentList> {\n const query: Record<string, string | undefined> = {\n search: args.search,\n status: args.status,\n pageId: args.pageId,\n limit: args.limit?.toString(),\n skip: args.skip?.toString(),\n };\n\n return this.client.request<PaymentList>({\n method: 'GET',\n query,\n path: '/v1/payments/',\n });\n }\n}\n","import { CheckoutPageApiClient, CheckoutPageApiClientOptions } from './client';\nimport { CustomerResource } from './resources/customers/customers';\nimport { CouponResource } from './resources/coupons/coupons';\nimport { PaymentResource } from './resources/payments/payments';\n\nexport class CheckoutPageClient {\n public readonly customers: CustomerResource;\n public readonly coupons: CouponResource;\n public readonly payments: PaymentResource;\n private readonly client: CheckoutPageApiClient;\n\n constructor(options: CheckoutPageApiClientOptions) {\n this.client = new CheckoutPageApiClient(options);\n this.customers = new CustomerResource(this.client);\n this.coupons = new CouponResource(this.client);\n this.payments = new PaymentResource(this.client);\n }\n}\n\nexport const createCheckoutPageClient = (options: CheckoutPageApiClientOptions) => {\n return new CheckoutPageClient(options);\n};\n\n// Export types and errors for convenience\nexport type { CheckoutPageApiClientOptions } from './client';\nexport type {\n Customer,\n Address,\n Shipping,\n Coupon,\n CouponList,\n Payment,\n PaymentList,\n} from './types';\nexport {\n CheckoutPageError,\n AuthenticationError,\n NotFoundError,\n ConflictError,\n RateLimitError,\n ValidationError,\n APIError,\n} from './errors';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/resources/customers/customers.ts","../src/resources/coupons/coupons.ts","../src/resources/payments/payments.ts","../src/resources/subscriptions/subscriptions.ts","../src/index.ts"],"names":[],"mappings":";;;AAAO,IAAM,iBAAA,GAAN,MAAM,kBAAA,SAA0B,KAAA,CAAM;AAAA,EAC3C,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,mBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,kBAAA,CAAkB,SAAS,CAAA;AAAA,EACzD;AACF;AAEO,IAAM,mBAAA,GAAN,MAAM,oBAAA,SAA4B,iBAAA,CAAkB;AAAA,EACzD,WAAA,CAAY,UAAU,mDAAA,EAAqD;AACzE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,qBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,oBAAA,CAAoB,SAAS,CAAA;AAAA,EAC3D;AACF;AAEO,IAAM,aAAA,GAAN,MAAM,cAAA,SAAsB,iBAAA,CAAkB;AAAA,EACnD,WAAA,CAAY,UAAU,uCAAA,EAAyC;AAC7D,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,cAAA,CAAc,SAAS,CAAA;AAAA,EACrD;AACF;AAEO,IAAM,aAAA,GAAN,MAAM,cAAA,SAAsB,iBAAA,CAAkB;AAAA,EACnD,WAAA,CAAY,UAAU,iDAAA,E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;AAAA,MAChD,QAAQ,IAAA,CAAK,MAAA;AAAA,MACb,QAAQ,IAAA,CAAK,MAAA;AAAA,MACb,QAAQ,IAAA,CAAK,MAAA;AAAA,MACb,KAAA,EAAO,IAAA,CAAK,KAAA,EAAO,QAAA,EAAS;AAAA,MAC5B,gBAAgB,IAAA,CAAK,cAAA;AAAA,MACrB,eAAe,IAAA,CAAK;AAAA,KACtB;AAEA,IAAA,OAAO,IAAA,CAAK,OAAO,OAAA,CAA0B;AAAA,MAC3C,MAAA,EAAQ,KAAA;AAAA,MACR,KAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF,CAAA;;;AChBO,IAAM,qBAAN,MAAyB;AAAA,EACd,SAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;AAAA,EACC,MAAA;AAAA,EAEjB,YAAY,OAAA,EAAuC;AACjD,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,qBAAA,CAAsB,OAAO,CAAA;AAC/C,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,gBAAA,CAAiB,IAAA,CAAK,MAAM,CAAA;AACjD,IAAA,IAAA,CAAK,OAAA,GAAU,IAAI,cAAA,CAAe,IAAA,CAAK,MAAM,CAAA;AAC7C,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,eAAA,CAAgB,IAAA,CAAK,MAAM,CAAA;AAC/C,IAAA,IAAA,CAAK,aAAA,GAAgB,IAAI,oBAAA,CAAqB,IAAA,CAAK,MAAM,CAAA;AAAA,EAC3D;AACF;AAEO,IAAM,wBAAA,GAA2B,CAAC,OAAA,KAA0C;AACjF,EAAA,OAAO,IAAI,mBAAmB,OAAO,CAAA;AACvC","file":"index.js","sourcesContent":["export class CheckoutPageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'CheckoutPageError';\n Object.setPrototypeOf(this, CheckoutPageError.prototype);\n }\n}\n\nexport class AuthenticationError extends CheckoutPageError {\n constructor(message = 'Authentication failed. Please check your API key.') {\n super(message);\n this.name = 'AuthenticationError';\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\nexport class NotFoundError extends CheckoutPageError {\n constructor(message = 'The requested resource was not found.') {\n super(message);\n this.name = 'NotFoundError';\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n\nexport class ConflictError extends CheckoutPageError {\n constructor(message = 'Conflict - the created resource already exists.') {\n super(message);\n this.name = 'ConflictError';\n Object.setPrototypeOf(this, ConflictError.prototype);\n }\n}\n\nexport class RateLimitError extends CheckoutPageError {\n constructor(message = 'Rate limit exceeded. Please try again later.') {\n super(message);\n this.name = 'RateLimitError';\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\nexport class ValidationError extends CheckoutPageError {\n constructor(message = 'Validation failed.') {\n super(message);\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class APIError extends CheckoutPageError {\n public readonly statusCode: number;\n public readonly response?: unknown;\n\n constructor(message: string, statusCode: number, response?: unknown) {\n super(message);\n this.name = 'APIError';\n this.statusCode = statusCode;\n this.response = response;\n Object.setPrototypeOf(this, APIError.prototype);\n }\n}\n","import {\n APIError,\n AuthenticationError,\n ConflictError,\n NotFoundError,\n RateLimitError,\n ValidationError,\n} from './errors';\n\nexport interface CheckoutPageApiClientOptions {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport interface RequestOptions {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n path: string;\n body?: unknown;\n query?: Record<string, string | number | boolean | undefined>;\n}\n\nexport class CheckoutPageApiClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n\n constructor(options: CheckoutPageApiClientOptions) {\n if (!options.apiKey) {\n throw new Error('API key is required');\n }\n\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl || 'https://api.checkoutpage.com';\n }\n\n async request<T>(options: RequestOptions): Promise<T> {\n const url = this.buildUrl(options.path, options.query);\n\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@checkoutpage/sdk/0.1.0',\n };\n\n const fetchOptions: RequestInit = {\n method: options.method,\n headers,\n };\n\n if (options.body) {\n fetchOptions.body = JSON.stringify(options.body);\n }\n\n const response = await fetch(url, fetchOptions);\n return await this.handleResponse<T>(response);\n }\n\n private buildUrl(\n path: string,\n query?: Record<string, string | number | boolean | undefined>\n ): string {\n const url = new URL(path, this.baseUrl);\n\n if (query) {\n Object.entries(query).forEach(([key, value]) => {\n if (value !== undefined) {\n url.searchParams.append(key, String(value));\n }\n });\n }\n\n return url.toString();\n }\n\n private async handleResponse<T>(response: Response): Promise<T> {\n const contentType = response.headers.get('content-type');\n const isJson = contentType?.includes('application/json');\n\n let data: unknown;\n try {\n data = isJson ? await response.json() : await response.text();\n } catch {\n data = null;\n }\n\n if (!response.ok) {\n const message = this.extractErrorMessage(data);\n\n switch (response.status) {\n case 401:\n case 403:\n throw new AuthenticationError(message);\n case 404:\n throw new NotFoundError(message);\n case 409:\n throw new ConflictError(message);\n case 400:\n case 422:\n throw new ValidationError(message);\n case 429:\n throw new RateLimitError(message);\n default:\n throw new APIError(message, response.status, data);\n }\n }\n\n return data as T;\n }\n\n private extractErrorMessage(data: unknown): string {\n if (typeof data === 'object' && data !== null) {\n if ('message' in data && typeof data.message === 'string') {\n return data.message;\n }\n if ('error' in data && typeof data.error === 'string') {\n return data.error;\n }\n }\n return 'An unexpected error occurred';\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport type { Customer, CustomerList, CustomerListParams } from '../../types';\n\nexport class CustomerResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async get(customerId: string): Promise<Customer> {\n if (!customerId) {\n throw new Error('Customer ID is required');\n }\n\n return this.client.request<Customer>({\n method: 'GET',\n path: `/v1/customers/${customerId}`,\n });\n }\n\n async list(args: CustomerListParams = {}): Promise<CustomerList> {\n const query: Record<string, string | undefined> = {\n search: args.search,\n limit: args.limit?.toString(),\n starting_after: args.starting_after,\n ending_before: args.ending_before,\n };\n\n return this.client.request<CustomerList>({\n method: 'GET',\n query,\n path: '/v1/customers/',\n });\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport {\n CouponList,\n CouponListParams,\n CreateCouponParams,\n CreateCouponResponse,\n} from '../../types';\n\nexport class CouponResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async list(args: CouponListParams = {}): Promise<CouponList> {\n const query: Record<string, string | undefined> = {\n search: args.search,\n limit: args.limit?.toString(),\n starting_after: args.starting_after,\n ending_before: args.ending_before,\n };\n\n return this.client.request<CouponList>({\n method: 'GET',\n query,\n path: '/v1/coupons/',\n });\n }\n\n async create(params: CreateCouponParams): Promise<CreateCouponResponse> {\n const body: Record<string, unknown> = {\n label: params.label,\n code: params.code,\n duration: params.duration,\n };\n\n if (params.duration === 'repeating') {\n body.durationInMonths = (params as any).durationInMonths;\n }\n\n if (params.appliesToSetupFee !== undefined) {\n body.appliesToSetupFee = params.appliesToSetupFee;\n }\n if (params.pageIds !== undefined) {\n body.pageIds = params.pageIds;\n }\n if (params.maxRedemptions !== undefined) {\n body.maxRedemptions = params.maxRedemptions;\n }\n if (params.redeemBy !== undefined) {\n body.redeemBy = params.redeemBy;\n }\n\n if (params.type === 'amount') {\n body.amountOff = params.amountOff;\n body.currency = params.currency;\n } else {\n body.percentOff = params.percentOff;\n }\n\n return this.client.request<CreateCouponResponse>({\n method: 'POST',\n path: '/v1/coupons/',\n body,\n });\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport type { PaymentList, PaymentListParams } from '../../types';\n\nexport class PaymentResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async list(args: PaymentListParams = {}): Promise<PaymentList> {\n const query: Record<string, string | undefined> = {\n search: args.search,\n status: args.status,\n pageId: args.pageId,\n limit: args.limit?.toString(),\n starting_after: args.starting_after,\n ending_before: args.ending_before,\n };\n\n return this.client.request<PaymentList>({\n method: 'GET',\n query,\n path: '/v1/payments/',\n });\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport type { SubscriptionList, SubscriptionListParams } from '../../types';\n\nexport class SubscriptionResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async list(args: SubscriptionListParams = {}): Promise<SubscriptionList> {\n const query: Record<string, string | undefined> = {\n search: args.search,\n pageId: args.pageId,\n status: args.status,\n limit: args.limit?.toString(),\n starting_after: args.starting_after,\n ending_before: args.ending_before,\n };\n\n return this.client.request<SubscriptionList>({\n method: 'GET',\n query,\n path: '/v1/subscriptions/',\n });\n }\n}\n","import { CheckoutPageApiClient, CheckoutPageApiClientOptions } from './client';\nimport { CustomerResource } from './resources/customers/customers';\nimport { CouponResource } from './resources/coupons/coupons';\nimport { PaymentResource } from './resources/payments/payments';\nimport { SubscriptionResource } from './resources/subscriptions/subscriptions';\n\nexport class CheckoutPageClient {\n public readonly customers: CustomerResource;\n public readonly coupons: CouponResource;\n public readonly payments: PaymentResource;\n public readonly subscriptions: SubscriptionResource;\n private readonly client: CheckoutPageApiClient;\n\n constructor(options: CheckoutPageApiClientOptions) {\n this.client = new CheckoutPageApiClient(options);\n this.customers = new CustomerResource(this.client);\n this.coupons = new CouponResource(this.client);\n this.payments = new PaymentResource(this.client);\n this.subscriptions = new SubscriptionResource(this.client);\n }\n}\n\nexport const createCheckoutPageClient = (options: CheckoutPageApiClientOptions) => {\n return new CheckoutPageClient(options);\n};\n\n// Export types and errors for convenience\nexport type { CheckoutPageApiClientOptions } from './client';\nexport type {\n Customer,\n Address,\n Shipping,\n Coupon,\n CouponList,\n Payment,\n PaymentList,\n Subscription,\n SubscriptionList,\n} from './types';\nexport {\n CheckoutPageError,\n AuthenticationError,\n NotFoundError,\n ConflictError,\n RateLimitError,\n ValidationError,\n APIError,\n} from './errors';\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -151,9 +151,10 @@ var CustomerResource = class {
|
|
|
151
151
|
}
|
|
152
152
|
async list(args = {}) {
|
|
153
153
|
const query = {
|
|
154
|
-
|
|
154
|
+
search: args.search,
|
|
155
155
|
limit: args.limit?.toString(),
|
|
156
|
-
|
|
156
|
+
starting_after: args.starting_after,
|
|
157
|
+
ending_before: args.ending_before
|
|
157
158
|
};
|
|
158
159
|
return this.client.request({
|
|
159
160
|
method: "GET",
|
|
@@ -172,7 +173,8 @@ var CouponResource = class {
|
|
|
172
173
|
const query = {
|
|
173
174
|
search: args.search,
|
|
174
175
|
limit: args.limit?.toString(),
|
|
175
|
-
|
|
176
|
+
starting_after: args.starting_after,
|
|
177
|
+
ending_before: args.ending_before
|
|
176
178
|
};
|
|
177
179
|
return this.client.request({
|
|
178
180
|
method: "GET",
|
|
@@ -226,7 +228,8 @@ var PaymentResource = class {
|
|
|
226
228
|
status: args.status,
|
|
227
229
|
pageId: args.pageId,
|
|
228
230
|
limit: args.limit?.toString(),
|
|
229
|
-
|
|
231
|
+
starting_after: args.starting_after,
|
|
232
|
+
ending_before: args.ending_before
|
|
230
233
|
};
|
|
231
234
|
return this.client.request({
|
|
232
235
|
method: "GET",
|
|
@@ -236,17 +239,41 @@ var PaymentResource = class {
|
|
|
236
239
|
}
|
|
237
240
|
};
|
|
238
241
|
|
|
242
|
+
// src/resources/subscriptions/subscriptions.ts
|
|
243
|
+
var SubscriptionResource = class {
|
|
244
|
+
constructor(client) {
|
|
245
|
+
this.client = client;
|
|
246
|
+
}
|
|
247
|
+
async list(args = {}) {
|
|
248
|
+
const query = {
|
|
249
|
+
search: args.search,
|
|
250
|
+
pageId: args.pageId,
|
|
251
|
+
status: args.status,
|
|
252
|
+
limit: args.limit?.toString(),
|
|
253
|
+
starting_after: args.starting_after,
|
|
254
|
+
ending_before: args.ending_before
|
|
255
|
+
};
|
|
256
|
+
return this.client.request({
|
|
257
|
+
method: "GET",
|
|
258
|
+
query,
|
|
259
|
+
path: "/v1/subscriptions/"
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
|
|
239
264
|
// src/index.ts
|
|
240
265
|
var CheckoutPageClient = class {
|
|
241
266
|
customers;
|
|
242
267
|
coupons;
|
|
243
268
|
payments;
|
|
269
|
+
subscriptions;
|
|
244
270
|
client;
|
|
245
271
|
constructor(options) {
|
|
246
272
|
this.client = new CheckoutPageApiClient(options);
|
|
247
273
|
this.customers = new CustomerResource(this.client);
|
|
248
274
|
this.coupons = new CouponResource(this.client);
|
|
249
275
|
this.payments = new PaymentResource(this.client);
|
|
276
|
+
this.subscriptions = new SubscriptionResource(this.client);
|
|
250
277
|
}
|
|
251
278
|
};
|
|
252
279
|
var createCheckoutPageClient = (options) => {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/resources/customers/customers.ts","../src/resources/coupons/coupons.ts","../src/resources/payments/payments.ts","../src/index.ts"],"names":[],"mappings":";AAAO,IAAM,iBAAA,GAAN,MAAM,kBAAA,SAA0B,KAAA,CAAM;AAAA,EAC3C,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,mBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,kBAAA,CAAkB,SAAS,CAAA;AAAA,EACzD;AACF;AAEO,IAAM,mBAAA,GAAN,MAAM,oBAAA,SAA4B,iBAAA,CAAkB;AAAA,EACzD,WAAA,CAAY,UAAU,mDAAA,EAAqD;AACzE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,qBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,oBAAA,CAAoB,SAAS,CAAA;AAAA,EAC3D;AACF;AAEO,IAAM,aAAA,GAAN,MAAM,cAAA,SAAsB,iBAAA,CAAkB;AAAA,EACnD,WAAA,CAAY,UAAU,uCAAA,EAAyC;AAC7D,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAA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AA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACC,MAAA;AAAA,EAEjB,YAAY,OAAA,EAAuC;AACjD,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,qBAAA,CAAsB,OAAO,CAAA;AAC/C,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,gBAAA,CAAiB,IAAA,CAAK,MAAM,CAAA;AACjD,IAAA,IAAA,CAAK,OAAA,GAAU,IAAI,cAAA,CAAe,IAAA,CAAK,MAAM,CAAA;AAC7C,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,eAAA,CAAgB,IAAA,CAAK,MAAM,CAAA;AAAA,EACjD;AACF;AAEO,IAAM,wBAAA,GAA2B,CAAC,OAAA,KAA0C;AACjF,EAAA,OAAO,IAAI,mBAAmB,OAAO,CAAA;AACvC","file":"index.mjs","sourcesContent":["export class CheckoutPageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'CheckoutPageError';\n Object.setPrototypeOf(this, CheckoutPageError.prototype);\n }\n}\n\nexport class AuthenticationError extends CheckoutPageError {\n constructor(message = 'Authentication failed. Please check your API key.') {\n super(message);\n this.name = 'AuthenticationError';\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\nexport class NotFoundError extends CheckoutPageError {\n constructor(message = 'The requested resource was not found.') {\n super(message);\n this.name = 'NotFoundError';\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n\nexport class ConflictError extends CheckoutPageError {\n constructor(message = 'Conflict - the created resource already exists.') {\n super(message);\n this.name = 'ConflictError';\n Object.setPrototypeOf(this, ConflictError.prototype);\n }\n}\n\nexport class RateLimitError extends CheckoutPageError {\n constructor(message = 'Rate limit exceeded. Please try again later.') {\n super(message);\n this.name = 'RateLimitError';\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\nexport class ValidationError extends CheckoutPageError {\n constructor(message = 'Validation failed.') {\n super(message);\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class APIError extends CheckoutPageError {\n public readonly statusCode: number;\n public readonly response?: unknown;\n\n constructor(message: string, statusCode: number, response?: unknown) {\n super(message);\n this.name = 'APIError';\n this.statusCode = statusCode;\n this.response = response;\n Object.setPrototypeOf(this, APIError.prototype);\n }\n}\n","import {\n APIError,\n AuthenticationError,\n ConflictError,\n NotFoundError,\n RateLimitError,\n ValidationError,\n} from './errors';\n\nexport interface CheckoutPageApiClientOptions {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport interface RequestOptions {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n path: string;\n body?: unknown;\n query?: Record<string, string | number | boolean | undefined>;\n}\n\nexport class CheckoutPageApiClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n\n constructor(options: CheckoutPageApiClientOptions) {\n if (!options.apiKey) {\n throw new Error('API key is required');\n }\n\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl || 'https://api.checkoutpage.com';\n }\n\n async request<T>(options: RequestOptions): Promise<T> {\n const url = this.buildUrl(options.path, options.query);\n\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@checkoutpage/sdk/0.1.0',\n };\n\n const fetchOptions: RequestInit = {\n method: options.method,\n headers,\n };\n\n if (options.body) {\n fetchOptions.body = JSON.stringify(options.body);\n }\n\n const response = await fetch(url, fetchOptions);\n return await this.handleResponse<T>(response);\n }\n\n private buildUrl(\n path: string,\n query?: Record<string, string | number | boolean | undefined>\n ): string {\n const url = new URL(path, this.baseUrl);\n\n if (query) {\n Object.entries(query).forEach(([key, value]) => {\n if (value !== undefined) {\n url.searchParams.append(key, String(value));\n }\n });\n }\n\n return url.toString();\n }\n\n private async handleResponse<T>(response: Response): Promise<T> {\n const contentType = response.headers.get('content-type');\n const isJson = contentType?.includes('application/json');\n\n let data: unknown;\n try {\n data = isJson ? await response.json() : await response.text();\n } catch {\n data = null;\n }\n\n if (!response.ok) {\n const message = this.extractErrorMessage(data);\n\n switch (response.status) {\n case 401:\n case 403:\n throw new AuthenticationError(message);\n case 404:\n throw new NotFoundError(message);\n case 409:\n throw new ConflictError(message);\n case 400:\n case 422:\n throw new ValidationError(message);\n case 429:\n throw new RateLimitError(message);\n default:\n throw new APIError(message, response.status, data);\n }\n }\n\n return data as T;\n }\n\n private extractErrorMessage(data: unknown): string {\n if (typeof data === 'object' && data !== null) {\n if ('message' in data && typeof data.message === 'string') {\n return data.message;\n }\n if ('error' in data && typeof data.error === 'string') {\n return data.error;\n }\n }\n return 'An unexpected error occurred';\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport type { Customer, CustomerList, CustomerListParams } from '../../types';\n\nexport class CustomerResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async get(customerId: string): Promise<Customer> {\n if (!customerId) {\n throw new Error('Customer ID is required');\n }\n\n return this.client.request<Customer>({\n method: 'GET',\n path: `/v1/customers/${customerId}`,\n });\n }\n\n async list(args: CustomerListParams = {}): Promise<CustomerList> {\n const query: Record<string, string | undefined> = {\n ...args,\n limit: args.limit?.toString(),\n skip: args.skip?.toString(),\n };\n\n return this.client.request<CustomerList>({\n method: 'GET',\n query,\n path: '/v1/customers/',\n });\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport {\n CouponList,\n CouponListParams,\n CreateCouponParams,\n CreateCouponResponse,\n} from '../../types';\n\nexport class CouponResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async list(args: CouponListParams = {}): Promise<CouponList> {\n const query: Record<string, string | undefined> = {\n search: args.search,\n limit: args.limit?.toString(),\n skip: args.skip?.toString(),\n };\n\n return this.client.request<CouponList>({\n method: 'GET',\n query,\n path: '/v1/coupons/',\n });\n }\n\n async create(params: CreateCouponParams): Promise<CreateCouponResponse> {\n const body: Record<string, unknown> = {\n label: params.label,\n code: params.code,\n duration: params.duration,\n };\n\n if (params.duration === 'repeating') {\n body.durationInMonths = (params as any).durationInMonths;\n }\n\n if (params.appliesToSetupFee !== undefined) {\n body.appliesToSetupFee = params.appliesToSetupFee;\n }\n if (params.pageIds !== undefined) {\n body.pageIds = params.pageIds;\n }\n if (params.maxRedemptions !== undefined) {\n body.maxRedemptions = params.maxRedemptions;\n }\n if (params.redeemBy !== undefined) {\n body.redeemBy = params.redeemBy;\n }\n\n if (params.type === 'amount') {\n body.amountOff = params.amountOff;\n body.currency = params.currency;\n } else {\n body.percentOff = params.percentOff;\n }\n\n return this.client.request<CreateCouponResponse>({\n method: 'POST',\n path: '/v1/coupons/',\n body,\n });\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport type { PaymentList, PaymentListParams } from '../../types';\n\nexport class PaymentResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async list(args: PaymentListParams = {}): Promise<PaymentList> {\n const query: Record<string, string | undefined> = {\n search: args.search,\n status: args.status,\n pageId: args.pageId,\n limit: args.limit?.toString(),\n skip: args.skip?.toString(),\n };\n\n return this.client.request<PaymentList>({\n method: 'GET',\n query,\n path: '/v1/payments/',\n });\n }\n}\n","import { CheckoutPageApiClient, CheckoutPageApiClientOptions } from './client';\nimport { CustomerResource } from './resources/customers/customers';\nimport { CouponResource } from './resources/coupons/coupons';\nimport { PaymentResource } from './resources/payments/payments';\n\nexport class CheckoutPageClient {\n public readonly customers: CustomerResource;\n public readonly coupons: CouponResource;\n public readonly payments: PaymentResource;\n private readonly client: CheckoutPageApiClient;\n\n constructor(options: CheckoutPageApiClientOptions) {\n this.client = new CheckoutPageApiClient(options);\n this.customers = new CustomerResource(this.client);\n this.coupons = new CouponResource(this.client);\n this.payments = new PaymentResource(this.client);\n }\n}\n\nexport const createCheckoutPageClient = (options: CheckoutPageApiClientOptions) => {\n return new CheckoutPageClient(options);\n};\n\n// Export types and errors for convenience\nexport type { CheckoutPageApiClientOptions } from './client';\nexport type {\n Customer,\n Address,\n Shipping,\n Coupon,\n CouponList,\n Payment,\n PaymentList,\n} from './types';\nexport {\n CheckoutPageError,\n AuthenticationError,\n NotFoundError,\n ConflictError,\n RateLimitError,\n ValidationError,\n APIError,\n} from './errors';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/resources/customers/customers.ts","../src/resources/coupons/coupons.ts","../src/resources/payments/payments.ts","../src/resources/subscriptions/subscriptions.ts","../src/index.ts"],"names":[],"mappings":";AAAO,IAAM,iBAAA,GAAN,MAAM,kBAAA,SAA0B,KAAA,CAAM;AAAA,EAC3C,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,mBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,kBAAA,CAAkB,SAAS,CAAA;AAAA,EACzD;AACF;AAEO,IAAM,mBAAA,GAAN,MAAM,oBAAA,SAA4B,iBAAA,CAAkB;AAAA,EACzD,WAAA,CAAY,UAAU,mDAAA,EAAqD;AACzE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,qBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,oBAAA,CAAoB,SAAS,CAAA;AAAA,EAC3D;AACF;AAEO,IAAM,aAAA,GAAN,MAAM,cAAA,SAAsB,iBAAA,CAAkB;AAAA,EACnD,WAAA,CAAY,UAAU,uCAAA,EAAyC;AAC7D,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,cAAA,CAAc,SAAS,CAAA;AAAA,EACrD;AACF;AAEO,IAAM,aAAA,GAAN,MAAM,cAAA,SAAsB,iBAAA,CAAkB;AAAA,EACnD,WAAA,CAAY,UAAU,iDAAA,EAAmD;AACvE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AACZ,IAAA,MAAA,CAAO,cAAA,C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A,MACb,KAAA,EAAO,IAAA,CAAK,KAAA,EAAO,QAAA,EAAS;AAAA,MAC5B,gBAAgB,IAAA,CAAK,cAAA;AAAA,MACrB,eAAe,IAAA,CAAK;AAAA,KACtB;AAEA,IAAA,OAAO,IAAA,CAAK,OAAO,OAAA,CAA0B;AAAA,MAC3C,MAAA,EAAQ,KAAA;AAAA,MACR,KAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF,CAAA;;;AChBO,IAAM,qBAAN,MAAyB;AAAA,EACd,SAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;AAAA,EACC,MAAA;AAAA,EAEjB,YAAY,OAAA,EAAuC;AACjD,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,qBAAA,CAAsB,OAAO,CAAA;AAC/C,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,gBAAA,CAAiB,IAAA,CAAK,MAAM,CAAA;AACjD,IAAA,IAAA,CAAK,OAAA,GAAU,IAAI,cAAA,CAAe,IAAA,CAAK,MAAM,CAAA;AAC7C,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,eAAA,CAAgB,IAAA,CAAK,MAAM,CAAA;AAC/C,IAAA,IAAA,CAAK,aAAA,GAAgB,IAAI,oBAAA,CAAqB,IAAA,CAAK,MAAM,CAAA;AAAA,EAC3D;AACF;AAEO,IAAM,wBAAA,GAA2B,CAAC,OAAA,KAA0C;AACjF,EAAA,OAAO,IAAI,mBAAmB,OAAO,CAAA;AACvC","file":"index.mjs","sourcesContent":["export class CheckoutPageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'CheckoutPageError';\n Object.setPrototypeOf(this, CheckoutPageError.prototype);\n }\n}\n\nexport class AuthenticationError extends CheckoutPageError {\n constructor(message = 'Authentication failed. Please check your API key.') {\n super(message);\n this.name = 'AuthenticationError';\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\nexport class NotFoundError extends CheckoutPageError {\n constructor(message = 'The requested resource was not found.') {\n super(message);\n this.name = 'NotFoundError';\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n\nexport class ConflictError extends CheckoutPageError {\n constructor(message = 'Conflict - the created resource already exists.') {\n super(message);\n this.name = 'ConflictError';\n Object.setPrototypeOf(this, ConflictError.prototype);\n }\n}\n\nexport class RateLimitError extends CheckoutPageError {\n constructor(message = 'Rate limit exceeded. Please try again later.') {\n super(message);\n this.name = 'RateLimitError';\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\nexport class ValidationError extends CheckoutPageError {\n constructor(message = 'Validation failed.') {\n super(message);\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class APIError extends CheckoutPageError {\n public readonly statusCode: number;\n public readonly response?: unknown;\n\n constructor(message: string, statusCode: number, response?: unknown) {\n super(message);\n this.name = 'APIError';\n this.statusCode = statusCode;\n this.response = response;\n Object.setPrototypeOf(this, APIError.prototype);\n }\n}\n","import {\n APIError,\n AuthenticationError,\n ConflictError,\n NotFoundError,\n RateLimitError,\n ValidationError,\n} from './errors';\n\nexport interface CheckoutPageApiClientOptions {\n apiKey: string;\n baseUrl?: string;\n}\n\nexport interface RequestOptions {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n path: string;\n body?: unknown;\n query?: Record<string, string | number | boolean | undefined>;\n}\n\nexport class CheckoutPageApiClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n\n constructor(options: CheckoutPageApiClientOptions) {\n if (!options.apiKey) {\n throw new Error('API key is required');\n }\n\n this.apiKey = options.apiKey;\n this.baseUrl = options.baseUrl || 'https://api.checkoutpage.com';\n }\n\n async request<T>(options: RequestOptions): Promise<T> {\n const url = this.buildUrl(options.path, options.query);\n\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@checkoutpage/sdk/0.1.0',\n };\n\n const fetchOptions: RequestInit = {\n method: options.method,\n headers,\n };\n\n if (options.body) {\n fetchOptions.body = JSON.stringify(options.body);\n }\n\n const response = await fetch(url, fetchOptions);\n return await this.handleResponse<T>(response);\n }\n\n private buildUrl(\n path: string,\n query?: Record<string, string | number | boolean | undefined>\n ): string {\n const url = new URL(path, this.baseUrl);\n\n if (query) {\n Object.entries(query).forEach(([key, value]) => {\n if (value !== undefined) {\n url.searchParams.append(key, String(value));\n }\n });\n }\n\n return url.toString();\n }\n\n private async handleResponse<T>(response: Response): Promise<T> {\n const contentType = response.headers.get('content-type');\n const isJson = contentType?.includes('application/json');\n\n let data: unknown;\n try {\n data = isJson ? await response.json() : await response.text();\n } catch {\n data = null;\n }\n\n if (!response.ok) {\n const message = this.extractErrorMessage(data);\n\n switch (response.status) {\n case 401:\n case 403:\n throw new AuthenticationError(message);\n case 404:\n throw new NotFoundError(message);\n case 409:\n throw new ConflictError(message);\n case 400:\n case 422:\n throw new ValidationError(message);\n case 429:\n throw new RateLimitError(message);\n default:\n throw new APIError(message, response.status, data);\n }\n }\n\n return data as T;\n }\n\n private extractErrorMessage(data: unknown): string {\n if (typeof data === 'object' && data !== null) {\n if ('message' in data && typeof data.message === 'string') {\n return data.message;\n }\n if ('error' in data && typeof data.error === 'string') {\n return data.error;\n }\n }\n return 'An unexpected error occurred';\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport type { Customer, CustomerList, CustomerListParams } from '../../types';\n\nexport class CustomerResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async get(customerId: string): Promise<Customer> {\n if (!customerId) {\n throw new Error('Customer ID is required');\n }\n\n return this.client.request<Customer>({\n method: 'GET',\n path: `/v1/customers/${customerId}`,\n });\n }\n\n async list(args: CustomerListParams = {}): Promise<CustomerList> {\n const query: Record<string, string | undefined> = {\n search: args.search,\n limit: args.limit?.toString(),\n starting_after: args.starting_after,\n ending_before: args.ending_before,\n };\n\n return this.client.request<CustomerList>({\n method: 'GET',\n query,\n path: '/v1/customers/',\n });\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport {\n CouponList,\n CouponListParams,\n CreateCouponParams,\n CreateCouponResponse,\n} from '../../types';\n\nexport class CouponResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async list(args: CouponListParams = {}): Promise<CouponList> {\n const query: Record<string, string | undefined> = {\n search: args.search,\n limit: args.limit?.toString(),\n starting_after: args.starting_after,\n ending_before: args.ending_before,\n };\n\n return this.client.request<CouponList>({\n method: 'GET',\n query,\n path: '/v1/coupons/',\n });\n }\n\n async create(params: CreateCouponParams): Promise<CreateCouponResponse> {\n const body: Record<string, unknown> = {\n label: params.label,\n code: params.code,\n duration: params.duration,\n };\n\n if (params.duration === 'repeating') {\n body.durationInMonths = (params as any).durationInMonths;\n }\n\n if (params.appliesToSetupFee !== undefined) {\n body.appliesToSetupFee = params.appliesToSetupFee;\n }\n if (params.pageIds !== undefined) {\n body.pageIds = params.pageIds;\n }\n if (params.maxRedemptions !== undefined) {\n body.maxRedemptions = params.maxRedemptions;\n }\n if (params.redeemBy !== undefined) {\n body.redeemBy = params.redeemBy;\n }\n\n if (params.type === 'amount') {\n body.amountOff = params.amountOff;\n body.currency = params.currency;\n } else {\n body.percentOff = params.percentOff;\n }\n\n return this.client.request<CreateCouponResponse>({\n method: 'POST',\n path: '/v1/coupons/',\n body,\n });\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport type { PaymentList, PaymentListParams } from '../../types';\n\nexport class PaymentResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async list(args: PaymentListParams = {}): Promise<PaymentList> {\n const query: Record<string, string | undefined> = {\n search: args.search,\n status: args.status,\n pageId: args.pageId,\n limit: args.limit?.toString(),\n starting_after: args.starting_after,\n ending_before: args.ending_before,\n };\n\n return this.client.request<PaymentList>({\n method: 'GET',\n query,\n path: '/v1/payments/',\n });\n }\n}\n","import type { CheckoutPageApiClient } from '../../client';\nimport type { SubscriptionList, SubscriptionListParams } from '../../types';\n\nexport class SubscriptionResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async list(args: SubscriptionListParams = {}): Promise<SubscriptionList> {\n const query: Record<string, string | undefined> = {\n search: args.search,\n pageId: args.pageId,\n status: args.status,\n limit: args.limit?.toString(),\n starting_after: args.starting_after,\n ending_before: args.ending_before,\n };\n\n return this.client.request<SubscriptionList>({\n method: 'GET',\n query,\n path: '/v1/subscriptions/',\n });\n }\n}\n","import { CheckoutPageApiClient, CheckoutPageApiClientOptions } from './client';\nimport { CustomerResource } from './resources/customers/customers';\nimport { CouponResource } from './resources/coupons/coupons';\nimport { PaymentResource } from './resources/payments/payments';\nimport { SubscriptionResource } from './resources/subscriptions/subscriptions';\n\nexport class CheckoutPageClient {\n public readonly customers: CustomerResource;\n public readonly coupons: CouponResource;\n public readonly payments: PaymentResource;\n public readonly subscriptions: SubscriptionResource;\n private readonly client: CheckoutPageApiClient;\n\n constructor(options: CheckoutPageApiClientOptions) {\n this.client = new CheckoutPageApiClient(options);\n this.customers = new CustomerResource(this.client);\n this.coupons = new CouponResource(this.client);\n this.payments = new PaymentResource(this.client);\n this.subscriptions = new SubscriptionResource(this.client);\n }\n}\n\nexport const createCheckoutPageClient = (options: CheckoutPageApiClientOptions) => {\n return new CheckoutPageClient(options);\n};\n\n// Export types and errors for convenience\nexport type { CheckoutPageApiClientOptions } from './client';\nexport type {\n Customer,\n Address,\n Shipping,\n Coupon,\n CouponList,\n Payment,\n PaymentList,\n Subscription,\n SubscriptionList,\n} from './types';\nexport {\n CheckoutPageError,\n AuthenticationError,\n NotFoundError,\n ConflictError,\n RateLimitError,\n ValidationError,\n APIError,\n} from './errors';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkoutpage/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Official JavaScript SDK for the Checkout Page API",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"test": "vitest run --exclude '**/*.integration.test.ts'",
|
|
21
21
|
"test:unit": "vitest run --exclude '**/*.integration.test.ts'",
|
|
22
22
|
"test:integration": "NODE_OPTIONS='--use-system-ca' vitest run src/resources/**/*.integration.test.ts",
|
|
23
|
-
"test:integration:
|
|
23
|
+
"test:integration:custom": "NODE_OPTIONS='--use-system-ca' vitest run",
|
|
24
24
|
"test:all": "NODE_OPTIONS='--use-system-ca' vitest run",
|
|
25
25
|
"test:watch": "vitest --exclude '**/*.integration.test.ts'",
|
|
26
26
|
"lint": "eslint src --ext .ts",
|