@checkoutpage/sdk 0.1.11 → 0.1.14
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 +92 -1
- package/dist/index.d.mts +70 -28
- package/dist/index.d.ts +70 -28
- package/dist/index.js +55 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
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,47 @@ 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
|
+
|
|
177
|
+
### Bookings
|
|
178
|
+
|
|
179
|
+
#### List bookings
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
const results = await checkoutpage.bookings.list();
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### Filter by status
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
const paidBookings = await checkoutpage.bookings.list({
|
|
189
|
+
status: 'paid',
|
|
190
|
+
limit: 25,
|
|
191
|
+
});
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### Filter by page
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
const pageBookings = await checkoutpage.bookings.list({
|
|
198
|
+
pageId: '67fcbdac6a91c25ef2d3534a',
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
111
202
|
## Error Handling
|
|
112
203
|
|
|
113
204
|
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;
|
|
@@ -635,14 +635,18 @@ interface operations {
|
|
|
635
635
|
};
|
|
636
636
|
};
|
|
637
637
|
};
|
|
638
|
-
"events/bookings": {
|
|
638
|
+
"events/bookings/list": {
|
|
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 id 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 id 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 id 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 id 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;
|
|
@@ -806,7 +814,7 @@ interface operations {
|
|
|
806
814
|
};
|
|
807
815
|
content?: never;
|
|
808
816
|
};
|
|
809
|
-
/** @description Customer not found
|
|
817
|
+
/** @description Customer not found */
|
|
810
818
|
404: {
|
|
811
819
|
headers: {
|
|
812
820
|
[name: string]: unknown;
|
|
@@ -832,9 +840,14 @@ 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 id 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 id 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
|
+
/** @description Case-insensitive search matched against coupon label and code. Returns coupons where either field contains the search term. */
|
|
850
|
+
search?: string;
|
|
838
851
|
};
|
|
839
852
|
header?: never;
|
|
840
853
|
path?: never;
|
|
@@ -933,7 +946,7 @@ interface operations {
|
|
|
933
946
|
/** @description A positive float larger than 0, and smaller or equal to 100, that represents the discount the coupon will apply (required if `amount_off` is not passed). */
|
|
934
947
|
percentOff?: number;
|
|
935
948
|
/**
|
|
936
|
-
* @description
|
|
949
|
+
* @description When enabled, applies this coupon discount to the setup fee.
|
|
937
950
|
* @example true
|
|
938
951
|
*/
|
|
939
952
|
appliesToSetupFee?: boolean;
|
|
@@ -1018,11 +1031,15 @@ interface operations {
|
|
|
1018
1031
|
"subscriptions/list": {
|
|
1019
1032
|
parameters: {
|
|
1020
1033
|
query?: {
|
|
1034
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
1035
|
+
limit?: string;
|
|
1036
|
+
/** @description A cursor value specifying the id of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with `ending_before`. */
|
|
1037
|
+
starting_after?: string;
|
|
1038
|
+
/** @description A cursor value specifying the id of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with `starting_after`. */
|
|
1039
|
+
ending_before?: string;
|
|
1021
1040
|
search?: string;
|
|
1022
1041
|
pageId?: string;
|
|
1023
1042
|
status?: string;
|
|
1024
|
-
limit?: string;
|
|
1025
|
-
skip?: string;
|
|
1026
1043
|
};
|
|
1027
1044
|
header?: never;
|
|
1028
1045
|
path?: never;
|
|
@@ -1174,9 +1191,8 @@ interface operations {
|
|
|
1174
1191
|
screenWidth?: number;
|
|
1175
1192
|
visitId?: string;
|
|
1176
1193
|
queryParameters?: {
|
|
1177
|
-
key: string;
|
|
1178
|
-
|
|
1179
|
-
}[];
|
|
1194
|
+
[key: string]: string;
|
|
1195
|
+
};
|
|
1180
1196
|
stripePaymentIntentId?: string;
|
|
1181
1197
|
stripePaymentIntentClientSecret?: string;
|
|
1182
1198
|
stripeSetupIntentId?: string;
|
|
@@ -1260,11 +1276,15 @@ interface operations {
|
|
|
1260
1276
|
"payments/list": {
|
|
1261
1277
|
parameters: {
|
|
1262
1278
|
query?: {
|
|
1279
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
1280
|
+
limit?: string;
|
|
1281
|
+
/** @description A cursor value specifying the id of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with `ending_before`. */
|
|
1282
|
+
starting_after?: string;
|
|
1283
|
+
/** @description A cursor value specifying the id of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with `starting_after`. */
|
|
1284
|
+
ending_before?: string;
|
|
1263
1285
|
search?: string;
|
|
1264
1286
|
status?: "created" | "pending" | "unpaid" | "partially_paid" | "paid" | "canceled" | "failed" | "partial_refund" | "refunded" | "draft" | "draft_expired";
|
|
1265
1287
|
pageId?: string;
|
|
1266
|
-
limit?: string;
|
|
1267
|
-
skip?: string;
|
|
1268
1288
|
};
|
|
1269
1289
|
header?: never;
|
|
1270
1290
|
path?: never;
|
|
@@ -1617,9 +1637,8 @@ interface operations {
|
|
|
1617
1637
|
type Customer = operations['customers/get']['responses'][200]['content']['application/json'];
|
|
1618
1638
|
type CustomerList = operations['customers/list']['responses'][200]['content']['application/json'];
|
|
1619
1639
|
type CustomerListArgs = operations['customers/list']['parameters']['query'];
|
|
1620
|
-
type CustomerListParams = Omit<NonNullable<CustomerListArgs>, 'limit'
|
|
1640
|
+
type CustomerListParams = Omit<NonNullable<CustomerListArgs>, 'limit'> & {
|
|
1621
1641
|
limit?: number;
|
|
1622
|
-
skip?: number;
|
|
1623
1642
|
};
|
|
1624
1643
|
type Address = NonNullable<Customer['data']['address']>;
|
|
1625
1644
|
type Shipping = NonNullable<Customer['data']['shipping']>;
|
|
@@ -1627,9 +1646,8 @@ type CouponList = operations['coupons/list']['responses'][200]['content']['appli
|
|
|
1627
1646
|
type Coupon = CouponList['data'][number];
|
|
1628
1647
|
type CreateCouponResponse = operations['coupons/create']['responses']['201']['content']['application/json'];
|
|
1629
1648
|
type CouponListArgs = operations['coupons/list']['parameters']['query'];
|
|
1630
|
-
type CouponListParams = Omit<NonNullable<CouponListArgs>, 'limit'
|
|
1649
|
+
type CouponListParams = Omit<NonNullable<CouponListArgs>, 'limit'> & {
|
|
1631
1650
|
limit?: number;
|
|
1632
|
-
skip?: number;
|
|
1633
1651
|
};
|
|
1634
1652
|
type CouponCreateArgs = NonNullable<operations['coupons/create']['requestBody']>['content']['application/json'];
|
|
1635
1653
|
type NonRepeatingParams = CouponCreateArgs & {
|
|
@@ -1656,9 +1674,19 @@ type CreateCouponParams = AmountNonRepeating | AmountRepeating | PercentNonRepea
|
|
|
1656
1674
|
type PaymentList = operations['payments/list']['responses'][200]['content']['application/json'];
|
|
1657
1675
|
type Payment = PaymentList['data'][number];
|
|
1658
1676
|
type PaymentListArgs = operations['payments/list']['parameters']['query'];
|
|
1659
|
-
type PaymentListParams = Omit<NonNullable<PaymentListArgs>, 'limit'
|
|
1677
|
+
type PaymentListParams = Omit<NonNullable<PaymentListArgs>, 'limit'> & {
|
|
1678
|
+
limit?: number;
|
|
1679
|
+
};
|
|
1680
|
+
type SubscriptionList = operations['subscriptions/list']['responses'][200]['content']['application/json'];
|
|
1681
|
+
type Subscription = SubscriptionList['data'][number];
|
|
1682
|
+
type SubscriptionListArgs = operations['subscriptions/list']['parameters']['query'];
|
|
1683
|
+
type SubscriptionListParams = Omit<NonNullable<SubscriptionListArgs>, 'limit'> & {
|
|
1684
|
+
limit?: number;
|
|
1685
|
+
};
|
|
1686
|
+
type BookingList = operations['events/bookings/list']['responses'][200]['content']['application/json'];
|
|
1687
|
+
type BookingListArgs = operations['events/bookings/list']['parameters']['query'];
|
|
1688
|
+
type BookingListParams = Omit<NonNullable<BookingListArgs>, 'limit'> & {
|
|
1660
1689
|
limit?: number;
|
|
1661
|
-
skip?: number;
|
|
1662
1690
|
};
|
|
1663
1691
|
|
|
1664
1692
|
declare class CustomerResource {
|
|
@@ -1681,6 +1709,18 @@ declare class PaymentResource {
|
|
|
1681
1709
|
list(args?: PaymentListParams): Promise<PaymentList>;
|
|
1682
1710
|
}
|
|
1683
1711
|
|
|
1712
|
+
declare class SubscriptionResource {
|
|
1713
|
+
private client;
|
|
1714
|
+
constructor(client: CheckoutPageApiClient);
|
|
1715
|
+
list(args?: SubscriptionListParams): Promise<SubscriptionList>;
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
declare class BookingResource {
|
|
1719
|
+
private client;
|
|
1720
|
+
constructor(client: CheckoutPageApiClient);
|
|
1721
|
+
list(args?: BookingListParams): Promise<BookingList>;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1684
1724
|
declare class CheckoutPageError extends Error {
|
|
1685
1725
|
constructor(message: string);
|
|
1686
1726
|
}
|
|
@@ -1709,9 +1749,11 @@ declare class CheckoutPageClient {
|
|
|
1709
1749
|
readonly customers: CustomerResource;
|
|
1710
1750
|
readonly coupons: CouponResource;
|
|
1711
1751
|
readonly payments: PaymentResource;
|
|
1752
|
+
readonly subscriptions: SubscriptionResource;
|
|
1753
|
+
readonly bookings: BookingResource;
|
|
1712
1754
|
private readonly client;
|
|
1713
1755
|
constructor(options: CheckoutPageApiClientOptions);
|
|
1714
1756
|
}
|
|
1715
1757
|
declare const createCheckoutPageClient: (options: CheckoutPageApiClientOptions) => CheckoutPageClient;
|
|
1716
1758
|
|
|
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 };
|
|
1759
|
+
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;
|
|
@@ -635,14 +635,18 @@ interface operations {
|
|
|
635
635
|
};
|
|
636
636
|
};
|
|
637
637
|
};
|
|
638
|
-
"events/bookings": {
|
|
638
|
+
"events/bookings/list": {
|
|
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 id 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 id 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 id 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 id 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;
|
|
@@ -806,7 +814,7 @@ interface operations {
|
|
|
806
814
|
};
|
|
807
815
|
content?: never;
|
|
808
816
|
};
|
|
809
|
-
/** @description Customer not found
|
|
817
|
+
/** @description Customer not found */
|
|
810
818
|
404: {
|
|
811
819
|
headers: {
|
|
812
820
|
[name: string]: unknown;
|
|
@@ -832,9 +840,14 @@ 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 id 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 id 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
|
+
/** @description Case-insensitive search matched against coupon label and code. Returns coupons where either field contains the search term. */
|
|
850
|
+
search?: string;
|
|
838
851
|
};
|
|
839
852
|
header?: never;
|
|
840
853
|
path?: never;
|
|
@@ -933,7 +946,7 @@ interface operations {
|
|
|
933
946
|
/** @description A positive float larger than 0, and smaller or equal to 100, that represents the discount the coupon will apply (required if `amount_off` is not passed). */
|
|
934
947
|
percentOff?: number;
|
|
935
948
|
/**
|
|
936
|
-
* @description
|
|
949
|
+
* @description When enabled, applies this coupon discount to the setup fee.
|
|
937
950
|
* @example true
|
|
938
951
|
*/
|
|
939
952
|
appliesToSetupFee?: boolean;
|
|
@@ -1018,11 +1031,15 @@ interface operations {
|
|
|
1018
1031
|
"subscriptions/list": {
|
|
1019
1032
|
parameters: {
|
|
1020
1033
|
query?: {
|
|
1034
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
1035
|
+
limit?: string;
|
|
1036
|
+
/** @description A cursor value specifying the id of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with `ending_before`. */
|
|
1037
|
+
starting_after?: string;
|
|
1038
|
+
/** @description A cursor value specifying the id of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with `starting_after`. */
|
|
1039
|
+
ending_before?: string;
|
|
1021
1040
|
search?: string;
|
|
1022
1041
|
pageId?: string;
|
|
1023
1042
|
status?: string;
|
|
1024
|
-
limit?: string;
|
|
1025
|
-
skip?: string;
|
|
1026
1043
|
};
|
|
1027
1044
|
header?: never;
|
|
1028
1045
|
path?: never;
|
|
@@ -1174,9 +1191,8 @@ interface operations {
|
|
|
1174
1191
|
screenWidth?: number;
|
|
1175
1192
|
visitId?: string;
|
|
1176
1193
|
queryParameters?: {
|
|
1177
|
-
key: string;
|
|
1178
|
-
|
|
1179
|
-
}[];
|
|
1194
|
+
[key: string]: string;
|
|
1195
|
+
};
|
|
1180
1196
|
stripePaymentIntentId?: string;
|
|
1181
1197
|
stripePaymentIntentClientSecret?: string;
|
|
1182
1198
|
stripeSetupIntentId?: string;
|
|
@@ -1260,11 +1276,15 @@ interface operations {
|
|
|
1260
1276
|
"payments/list": {
|
|
1261
1277
|
parameters: {
|
|
1262
1278
|
query?: {
|
|
1279
|
+
/** @description The number of results per page. Minimum value is 1 and maximum is 100. Defaults to 20. */
|
|
1280
|
+
limit?: string;
|
|
1281
|
+
/** @description A cursor value specifying the id of a resource to start before. Retrieves items that appear after this cursor in the list. Cannot be used together with `ending_before`. */
|
|
1282
|
+
starting_after?: string;
|
|
1283
|
+
/** @description A cursor value specifying the id of a resource to end after. Retrieves items that appear before this cursor in the list. Cannot be used together with `starting_after`. */
|
|
1284
|
+
ending_before?: string;
|
|
1263
1285
|
search?: string;
|
|
1264
1286
|
status?: "created" | "pending" | "unpaid" | "partially_paid" | "paid" | "canceled" | "failed" | "partial_refund" | "refunded" | "draft" | "draft_expired";
|
|
1265
1287
|
pageId?: string;
|
|
1266
|
-
limit?: string;
|
|
1267
|
-
skip?: string;
|
|
1268
1288
|
};
|
|
1269
1289
|
header?: never;
|
|
1270
1290
|
path?: never;
|
|
@@ -1617,9 +1637,8 @@ interface operations {
|
|
|
1617
1637
|
type Customer = operations['customers/get']['responses'][200]['content']['application/json'];
|
|
1618
1638
|
type CustomerList = operations['customers/list']['responses'][200]['content']['application/json'];
|
|
1619
1639
|
type CustomerListArgs = operations['customers/list']['parameters']['query'];
|
|
1620
|
-
type CustomerListParams = Omit<NonNullable<CustomerListArgs>, 'limit'
|
|
1640
|
+
type CustomerListParams = Omit<NonNullable<CustomerListArgs>, 'limit'> & {
|
|
1621
1641
|
limit?: number;
|
|
1622
|
-
skip?: number;
|
|
1623
1642
|
};
|
|
1624
1643
|
type Address = NonNullable<Customer['data']['address']>;
|
|
1625
1644
|
type Shipping = NonNullable<Customer['data']['shipping']>;
|
|
@@ -1627,9 +1646,8 @@ type CouponList = operations['coupons/list']['responses'][200]['content']['appli
|
|
|
1627
1646
|
type Coupon = CouponList['data'][number];
|
|
1628
1647
|
type CreateCouponResponse = operations['coupons/create']['responses']['201']['content']['application/json'];
|
|
1629
1648
|
type CouponListArgs = operations['coupons/list']['parameters']['query'];
|
|
1630
|
-
type CouponListParams = Omit<NonNullable<CouponListArgs>, 'limit'
|
|
1649
|
+
type CouponListParams = Omit<NonNullable<CouponListArgs>, 'limit'> & {
|
|
1631
1650
|
limit?: number;
|
|
1632
|
-
skip?: number;
|
|
1633
1651
|
};
|
|
1634
1652
|
type CouponCreateArgs = NonNullable<operations['coupons/create']['requestBody']>['content']['application/json'];
|
|
1635
1653
|
type NonRepeatingParams = CouponCreateArgs & {
|
|
@@ -1656,9 +1674,19 @@ type CreateCouponParams = AmountNonRepeating | AmountRepeating | PercentNonRepea
|
|
|
1656
1674
|
type PaymentList = operations['payments/list']['responses'][200]['content']['application/json'];
|
|
1657
1675
|
type Payment = PaymentList['data'][number];
|
|
1658
1676
|
type PaymentListArgs = operations['payments/list']['parameters']['query'];
|
|
1659
|
-
type PaymentListParams = Omit<NonNullable<PaymentListArgs>, 'limit'
|
|
1677
|
+
type PaymentListParams = Omit<NonNullable<PaymentListArgs>, 'limit'> & {
|
|
1678
|
+
limit?: number;
|
|
1679
|
+
};
|
|
1680
|
+
type SubscriptionList = operations['subscriptions/list']['responses'][200]['content']['application/json'];
|
|
1681
|
+
type Subscription = SubscriptionList['data'][number];
|
|
1682
|
+
type SubscriptionListArgs = operations['subscriptions/list']['parameters']['query'];
|
|
1683
|
+
type SubscriptionListParams = Omit<NonNullable<SubscriptionListArgs>, 'limit'> & {
|
|
1684
|
+
limit?: number;
|
|
1685
|
+
};
|
|
1686
|
+
type BookingList = operations['events/bookings/list']['responses'][200]['content']['application/json'];
|
|
1687
|
+
type BookingListArgs = operations['events/bookings/list']['parameters']['query'];
|
|
1688
|
+
type BookingListParams = Omit<NonNullable<BookingListArgs>, 'limit'> & {
|
|
1660
1689
|
limit?: number;
|
|
1661
|
-
skip?: number;
|
|
1662
1690
|
};
|
|
1663
1691
|
|
|
1664
1692
|
declare class CustomerResource {
|
|
@@ -1681,6 +1709,18 @@ declare class PaymentResource {
|
|
|
1681
1709
|
list(args?: PaymentListParams): Promise<PaymentList>;
|
|
1682
1710
|
}
|
|
1683
1711
|
|
|
1712
|
+
declare class SubscriptionResource {
|
|
1713
|
+
private client;
|
|
1714
|
+
constructor(client: CheckoutPageApiClient);
|
|
1715
|
+
list(args?: SubscriptionListParams): Promise<SubscriptionList>;
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
declare class BookingResource {
|
|
1719
|
+
private client;
|
|
1720
|
+
constructor(client: CheckoutPageApiClient);
|
|
1721
|
+
list(args?: BookingListParams): Promise<BookingList>;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1684
1724
|
declare class CheckoutPageError extends Error {
|
|
1685
1725
|
constructor(message: string);
|
|
1686
1726
|
}
|
|
@@ -1709,9 +1749,11 @@ declare class CheckoutPageClient {
|
|
|
1709
1749
|
readonly customers: CustomerResource;
|
|
1710
1750
|
readonly coupons: CouponResource;
|
|
1711
1751
|
readonly payments: PaymentResource;
|
|
1752
|
+
readonly subscriptions: SubscriptionResource;
|
|
1753
|
+
readonly bookings: BookingResource;
|
|
1712
1754
|
private readonly client;
|
|
1713
1755
|
constructor(options: CheckoutPageApiClientOptions);
|
|
1714
1756
|
}
|
|
1715
1757
|
declare const createCheckoutPageClient: (options: CheckoutPageApiClientOptions) => CheckoutPageClient;
|
|
1716
1758
|
|
|
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 };
|
|
1759
|
+
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,65 @@ 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
|
+
|
|
266
|
+
// src/resources/bookings/bookings.ts
|
|
267
|
+
var BookingResource = class {
|
|
268
|
+
constructor(client) {
|
|
269
|
+
this.client = client;
|
|
270
|
+
}
|
|
271
|
+
async list(args = {}) {
|
|
272
|
+
const query = {
|
|
273
|
+
search: args.search,
|
|
274
|
+
limit: args.limit?.toString(),
|
|
275
|
+
starting_after: args.starting_after,
|
|
276
|
+
ending_before: args.ending_before,
|
|
277
|
+
status: args.status,
|
|
278
|
+
pageId: args.pageId
|
|
279
|
+
};
|
|
280
|
+
return this.client.request({
|
|
281
|
+
method: "GET",
|
|
282
|
+
query,
|
|
283
|
+
path: "/v1/bookings/"
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
|
|
241
288
|
// src/index.ts
|
|
242
289
|
var CheckoutPageClient = class {
|
|
243
290
|
customers;
|
|
244
291
|
coupons;
|
|
245
292
|
payments;
|
|
293
|
+
subscriptions;
|
|
294
|
+
bookings;
|
|
246
295
|
client;
|
|
247
296
|
constructor(options) {
|
|
248
297
|
this.client = new CheckoutPageApiClient(options);
|
|
249
298
|
this.customers = new CustomerResource(this.client);
|
|
250
299
|
this.coupons = new CouponResource(this.client);
|
|
251
300
|
this.payments = new PaymentResource(this.client);
|
|
301
|
+
this.subscriptions = new SubscriptionResource(this.client);
|
|
302
|
+
this.bookings = new BookingResource(this.client);
|
|
252
303
|
}
|
|
253
304
|
};
|
|
254
305
|
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,IAA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C;AAAA,EAEpD,MAAM,IAAA,CAAK,IAAA,GAA0B,EAAC,EAAyB;AAC7D,IAAA,MAAM,KAAA,GAA4C;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,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,QAAA;AAAS,KAC5B;AAEA,IAAA,OAAO,IAAA,CAAK,OAAO,OAAA,CAAqB;AAAA,MACtC,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,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/resources/bookings/bookings.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,MAA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AAA;AAAA,MACpB,QAAQ,IAAA,CAAK,MAAA;AAAA,MACb,QAAQ,IAAA,CAAK;AAAA,KACf;AAEA,IAAA,OAAO,IAAA,CAAK,OAAO,OAAA,CAAqB;AAAA,MACtC,MAAA,EAAQ,KAAA;AAAA,MACR,KAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF,CAAA;;;ACfO,IAAM,qBAAN,MAAyB;AAAA,EACd,SAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;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;AAC/C,IAAA,IAAA,CAAK,aAAA,GAAgB,IAAI,oBAAA,CAAqB,IAAA,CAAK,MAAM,CAAA;AACzD,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 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 type { CheckoutPageApiClient } from '../../client';\nimport type { BookingList, BookingListParams } from '../../types';\n\nexport class BookingResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async list(args: BookingListParams = {}): Promise<BookingList> {\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 status: args.status,\n pageId: args.pageId,\n };\n\n return this.client.request<BookingList>({\n method: 'GET',\n query,\n path: '/v1/bookings/',\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';\nimport { BookingResource } from './resources/bookings/bookings';\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 public readonly bookings: BookingResource;\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 this.bookings = new BookingResource(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,65 @@ 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
|
+
|
|
264
|
+
// src/resources/bookings/bookings.ts
|
|
265
|
+
var BookingResource = class {
|
|
266
|
+
constructor(client) {
|
|
267
|
+
this.client = client;
|
|
268
|
+
}
|
|
269
|
+
async list(args = {}) {
|
|
270
|
+
const query = {
|
|
271
|
+
search: args.search,
|
|
272
|
+
limit: args.limit?.toString(),
|
|
273
|
+
starting_after: args.starting_after,
|
|
274
|
+
ending_before: args.ending_before,
|
|
275
|
+
status: args.status,
|
|
276
|
+
pageId: args.pageId
|
|
277
|
+
};
|
|
278
|
+
return this.client.request({
|
|
279
|
+
method: "GET",
|
|
280
|
+
query,
|
|
281
|
+
path: "/v1/bookings/"
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
239
286
|
// src/index.ts
|
|
240
287
|
var CheckoutPageClient = class {
|
|
241
288
|
customers;
|
|
242
289
|
coupons;
|
|
243
290
|
payments;
|
|
291
|
+
subscriptions;
|
|
292
|
+
bookings;
|
|
244
293
|
client;
|
|
245
294
|
constructor(options) {
|
|
246
295
|
this.client = new CheckoutPageApiClient(options);
|
|
247
296
|
this.customers = new CustomerResource(this.client);
|
|
248
297
|
this.coupons = new CouponResource(this.client);
|
|
249
298
|
this.payments = new PaymentResource(this.client);
|
|
299
|
+
this.subscriptions = new SubscriptionResource(this.client);
|
|
300
|
+
this.bookings = new BookingResource(this.client);
|
|
250
301
|
}
|
|
251
302
|
};
|
|
252
303
|
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,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,CAAe,IAAA,EAAM,cAAA,CAAc,SAAS,CAAA;AAAA,EACrD;AACF;AAEO,IAAM,cAAA,GAAN,MAAM,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AAM,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/resources/bookings/bookings.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,IA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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 type { CheckoutPageApiClient } from '../../client';\nimport type { BookingList, BookingListParams } from '../../types';\n\nexport class BookingResource {\n constructor(private client: CheckoutPageApiClient) {}\n\n async list(args: BookingListParams = {}): Promise<BookingList> {\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 status: args.status,\n pageId: args.pageId,\n };\n\n return this.client.request<BookingList>({\n method: 'GET',\n query,\n path: '/v1/bookings/',\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';\nimport { BookingResource } from './resources/bookings/bookings';\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 public readonly bookings: BookingResource;\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 this.bookings = new BookingResource(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.14",
|
|
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",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
|
41
|
-
"url": "https://github.com/checkout-page/checkoutpage-api-sdk.git",
|
|
41
|
+
"url": "git+https://github.com/checkout-page/checkoutpage-api-sdk.git",
|
|
42
42
|
"directory": "js"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|