@suqo/sdk 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +58 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -19
- package/dist/index.d.ts +97 -19
- package/dist/index.js +58 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -48,9 +48,12 @@ declare class SuqoError extends Error {
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Construction-time configuration problems: a malformed API key, or an explicit `baseUrl`
|
|
51
|
-
* override that disagrees with the key's prefix (SDK-SPEC.md §2, §7).
|
|
52
|
-
*
|
|
53
|
-
* `
|
|
51
|
+
* override that disagrees with the key's prefix (SDK-SPEC.md §2, §7). Also reused for a call-time
|
|
52
|
+
* argument that would otherwise silently corrupt a request rather than reach the API at all — e.g.
|
|
53
|
+
* an empty `customers.retrieve(id)` (#42) — the same "never even attempted" character as a bad
|
|
54
|
+
* construction option. Thrown before any request is made — analogous to a syntax error in the
|
|
55
|
+
* integration, not an HTTP failure. Never carries `status`/`rawBody`; there was no request to map
|
|
56
|
+
* one from.
|
|
54
57
|
*/
|
|
55
58
|
declare class SuqoConfigError extends SuqoError {
|
|
56
59
|
constructor(message: string, options?: {
|
|
@@ -291,12 +294,21 @@ interface HttpPostRequestOptions<TBody = unknown> extends HttpRequestOptionsBase
|
|
|
291
294
|
/** JSON-serializable request body. Omit entirely for a bodyless write (e.g. `cancel`). */
|
|
292
295
|
body?: TBody;
|
|
293
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Options for a `PATCH` request — a partial update (`customers.update()`). Same body typing as
|
|
299
|
+
* {@link HttpPostRequestOptions}, and like every write it is never retried (SDK-SPEC.md §8).
|
|
300
|
+
*/
|
|
301
|
+
interface HttpPatchRequestOptions<TBody = unknown> extends HttpRequestOptionsBase {
|
|
302
|
+
method: "PATCH";
|
|
303
|
+
/** JSON-serializable request body — only the fields being changed. */
|
|
304
|
+
body?: TBody;
|
|
305
|
+
}
|
|
294
306
|
/**
|
|
295
307
|
* Options accepted by {@link HttpClient.request}. `HttpClient` itself is internal (not exported
|
|
296
308
|
* from `src/index.ts`); the SDK's actual typed, consumer-facing contract lives one layer up, in
|
|
297
309
|
* each resource method's own public signature.
|
|
298
310
|
*/
|
|
299
|
-
type HttpRequestOptions<TBody = unknown> = HttpGetRequestOptions | HttpPostRequestOptions<TBody>;
|
|
311
|
+
type HttpRequestOptions<TBody = unknown> = HttpGetRequestOptions | HttpPostRequestOptions<TBody> | HttpPatchRequestOptions<TBody>;
|
|
300
312
|
/** Options accepted by {@link HttpClient}'s constructor. */
|
|
301
313
|
interface HttpClientOptions {
|
|
302
314
|
/**
|
|
@@ -468,6 +480,13 @@ interface ProductVat {
|
|
|
468
480
|
/** Decimal string (e.g. `"13.00"`). Never coerced to a number — SDK-SPEC.md §5. */
|
|
469
481
|
vatPercentage: string;
|
|
470
482
|
}
|
|
483
|
+
/** One image on a {@link Product} (`openapi.yaml` `ProductImage`). */
|
|
484
|
+
interface ProductImage {
|
|
485
|
+
/** Absolute image URL. */
|
|
486
|
+
image: string;
|
|
487
|
+
/** Display position, lowest first. */
|
|
488
|
+
imageOrder: number;
|
|
489
|
+
}
|
|
471
490
|
/** A seller's product, as returned by `products.list()` (`openapi.yaml` `Product`). */
|
|
472
491
|
interface Product {
|
|
473
492
|
productId: string;
|
|
@@ -478,8 +497,11 @@ interface Product {
|
|
|
478
497
|
termsAndConditions: string;
|
|
479
498
|
featuresAndBenefits: string;
|
|
480
499
|
vat: ProductVat | null;
|
|
481
|
-
/**
|
|
482
|
-
|
|
500
|
+
/**
|
|
501
|
+
* Ordered images; blank images already excluded server-side. Each is an object, not a bare URL
|
|
502
|
+
* string — the API has always sent `{ image, image_order }`.
|
|
503
|
+
*/
|
|
504
|
+
productImage: ProductImage[];
|
|
483
505
|
plan: Plan[];
|
|
484
506
|
/** Count of active subscribers. Sent as a string on the wire — kept as one, never coerced (SDK-SPEC.md §5). */
|
|
485
507
|
totalSubscribers: string;
|
|
@@ -589,18 +611,19 @@ interface CustomerInput {
|
|
|
589
611
|
}
|
|
590
612
|
/**
|
|
591
613
|
* A seller's own customer record, as returned by `customers.list()`/`customers.retrieve()`
|
|
592
|
-
* (`openapi.yaml` `Customer
|
|
593
|
-
*
|
|
614
|
+
* (`openapi.yaml` `Customer`). Distinct from {@link SubscriptionCustomer} and {@link CustomerInput}
|
|
615
|
+
* — see this file's module doc.
|
|
594
616
|
*
|
|
595
617
|
* Uses `buyer*`-prefixed field names, not the `client.*` nesting Subscriptions uses — a genuinely
|
|
596
|
-
* different resource with its own
|
|
618
|
+
* different resource with its own convention, carried through as-is.
|
|
597
619
|
*/
|
|
598
620
|
interface Customer {
|
|
599
|
-
/**
|
|
600
|
-
id:
|
|
621
|
+
/** Opaque prefixed id, e.g. `"cus_1ce18d624"` — a string, like `pbp_...` on billing periods, not an integer. */
|
|
622
|
+
id: string;
|
|
601
623
|
buyerPhone: string | null;
|
|
602
624
|
buyerEmail: string | null;
|
|
603
625
|
fullName: string | null;
|
|
626
|
+
address: string | null;
|
|
604
627
|
createdAt: string;
|
|
605
628
|
}
|
|
606
629
|
|
|
@@ -716,6 +739,42 @@ interface UpdateBillingCycleParams {
|
|
|
716
739
|
nextBillingCycle: string;
|
|
717
740
|
}
|
|
718
741
|
|
|
742
|
+
/**
|
|
743
|
+
* Input shapes for the `customers` write methods (`specs/openapi.yaml`
|
|
744
|
+
* `CreateCustomerRequest`/`UpdateCustomerRequest`). Named `*Params`, not `*Request` — SDK Naming
|
|
745
|
+
* Map v1.1 §12, same as `subscriptionParams.ts`.
|
|
746
|
+
*
|
|
747
|
+
* Note the read/write name asymmetry on the wire: `phone`/`email` sent here read back on
|
|
748
|
+
* {@link import("./Customer.js").Customer} as `buyerPhone`/`buyerEmail`. The params keep the
|
|
749
|
+
* wire's write-side names rather than borrowing the read side's `buyer*` prefix.
|
|
750
|
+
*
|
|
751
|
+
* @packageDocumentation
|
|
752
|
+
*/
|
|
753
|
+
/** What `customers.create(params)` accepts (`openapi.yaml` `CreateCustomerRequest`, renamed). */
|
|
754
|
+
interface CreateCustomerParams {
|
|
755
|
+
/**
|
|
756
|
+
* Identifies the buyer and can't be changed later. A Nepali mobile number: 10 digits starting
|
|
757
|
+
* with 96, 97 or 98 — a `+977` country code, a leading 0, spaces and dashes are accepted and
|
|
758
|
+
* stripped server-side. Reads back as `buyerPhone`.
|
|
759
|
+
*/
|
|
760
|
+
phone: string;
|
|
761
|
+
fullName?: string;
|
|
762
|
+
/** Reads back as `buyerEmail`. */
|
|
763
|
+
email?: string;
|
|
764
|
+
address?: string;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* What `customers.update(id, params)` accepts (`openapi.yaml` `UpdateCustomerRequest`, renamed).
|
|
768
|
+
* Send only the fields you're changing; `""` clears a field. There's no `phone` — it identifies
|
|
769
|
+
* the buyer and can't be changed.
|
|
770
|
+
*/
|
|
771
|
+
interface UpdateCustomerParams {
|
|
772
|
+
fullName?: string;
|
|
773
|
+
/** Reads back as `buyerEmail`. */
|
|
774
|
+
email?: string;
|
|
775
|
+
address?: string;
|
|
776
|
+
}
|
|
777
|
+
|
|
719
778
|
/**
|
|
720
779
|
* What `subscriptions.cancel()`, `subscriptions.updateBillingCycle()`, and
|
|
721
780
|
* `subscriptions.resume()` all return (`specs/openapi.yaml` `Message`, renamed). Named
|
|
@@ -903,8 +962,8 @@ declare class SubscriptionsResource {
|
|
|
903
962
|
}
|
|
904
963
|
|
|
905
964
|
/**
|
|
906
|
-
* `client.customers` (SDK-SPEC.md §5, §6; `openapi.yaml` `listCustomers`/`retrieveCustomer
|
|
907
|
-
*
|
|
965
|
+
* `client.customers` (SDK-SPEC.md §5, §6; `openapi.yaml` `listCustomers`/`retrieveCustomer`/
|
|
966
|
+
* `createCustomer`/`updateCustomer`). No delete exists on this resource.
|
|
908
967
|
*/
|
|
909
968
|
declare class CustomersResource {
|
|
910
969
|
#private;
|
|
@@ -918,10 +977,29 @@ declare class CustomersResource {
|
|
|
918
977
|
*/
|
|
919
978
|
autoPaging(params?: PageParams): AsyncIterableIterator<Customer>;
|
|
920
979
|
/**
|
|
921
|
-
* Retrieves a single customer by id
|
|
922
|
-
*
|
|
980
|
+
* Retrieves a single customer by id — an opaque prefixed string (e.g. `"cus_1ce18d624"`), like
|
|
981
|
+
* `pbp_...` on billing periods, not an integer and not a UUID (Bug #42 corrected the previously
|
|
982
|
+
* wrong `number` type/doc claim here).
|
|
983
|
+
*/
|
|
984
|
+
retrieve(id: string): Promise<Customer>;
|
|
985
|
+
/**
|
|
986
|
+
* Records a customer on the seller's account without opening a subscription. `phone` identifies
|
|
987
|
+
* the buyer; the name, email and address are the seller's own copy and aren't shared with other
|
|
988
|
+
* sellers.
|
|
989
|
+
*
|
|
990
|
+
* A phone the seller already holds updates that existing customer instead of creating a second
|
|
991
|
+
* one (the API answers `200` rather than `201`; both resolve to the `Customer` here). That makes
|
|
992
|
+
* this call safe for the caller to retry — but, like every write, the SDK never retries it
|
|
993
|
+
* automatically (SDK-SPEC.md §8, §12).
|
|
994
|
+
*/
|
|
995
|
+
create(params: CreateCustomerParams): Promise<Customer>;
|
|
996
|
+
/**
|
|
997
|
+
* Updates the seller's copy of a customer's name, email or address. Send only the fields you're
|
|
998
|
+
* changing; `""` clears a field. The phone can't be changed.
|
|
999
|
+
*
|
|
1000
|
+
* Not auto-retryable — writes never retry until idempotency ships (SDK-SPEC.md §8, §12).
|
|
923
1001
|
*/
|
|
924
|
-
|
|
1002
|
+
update(id: string, params: UpdateCustomerParams): Promise<Customer>;
|
|
925
1003
|
}
|
|
926
1004
|
|
|
927
1005
|
/**
|
|
@@ -1016,7 +1094,7 @@ declare class SuqoClient {
|
|
|
1016
1094
|
readonly products: ProductsResource;
|
|
1017
1095
|
/** Create, list, and manage subscriptions (SDK-SPEC.md §5, §6, §7). */
|
|
1018
1096
|
readonly subscriptions: SubscriptionsResource;
|
|
1019
|
-
/** List and
|
|
1097
|
+
/** List, retrieve, create and update the seller's customers (SDK-SPEC.md §5, §6). */
|
|
1020
1098
|
readonly customers: CustomersResource;
|
|
1021
1099
|
/** Verify inbound webhook deliveries (SDK-SPEC.md §9). Makes no network call, needs no key. */
|
|
1022
1100
|
readonly webhooks: WebhooksResource;
|
|
@@ -1040,6 +1118,6 @@ declare class SuqoClient {
|
|
|
1040
1118
|
* @packageDocumentation
|
|
1041
1119
|
*/
|
|
1042
1120
|
/** SDK version, stamped into request headers (keep in sync with package.json). */
|
|
1043
|
-
declare const VERSION = "1.
|
|
1121
|
+
declare const VERSION = "1.1.0";
|
|
1044
1122
|
|
|
1045
|
-
export { type ApiKeyCreatedEvent, type ApiKeyDeletedEvent, type ApiKeyExpiredEvent, type ApiKeyExpiringSoonEvent, AuthenticationError, type BillingPeriod, type CheckoutFailedEvent, type CheckoutSucceededEvent, type CreateSubscriptionParams, type CreateSubscriptionResponse, type Customer, type CustomerInput, type CustomerInputBilling, type CustomerInputShipping, type FieldErrors, type HttpErrorInput, KycRequiredError, type KycRequiredErrorOptions, type MessageResponse, NetworkError, NotFoundError, type Page, type PageParams, type Plan, type Product, type ProductVat, RateLimitError, type RateLimitErrorOptions, ServerError, type Subscription, type SubscriptionCustomer, type SubscriptionCustomerBilling, type SubscriptionCustomerShipping, type SubscriptionPage, type SubscriptionProduct, SubscriptionStatus, type SubscriptionStatusChangedEvent, type SubscriptionStatusCounts, SuqoClient, type SuqoClientOptions, SuqoConfigError, type SuqoEnvironment, SuqoError, type SuqoErrorOptions, type UpdateBillingCycleParams, VERSION, ValidationError, type ValidationErrorOptions, type VerifyWebhookOptions, type WebhookEvent, type WebhookEventType, bridgeAutoPaging, deserializePage, listAll, mapHttpError, toPageQuery };
|
|
1123
|
+
export { type ApiKeyCreatedEvent, type ApiKeyDeletedEvent, type ApiKeyExpiredEvent, type ApiKeyExpiringSoonEvent, AuthenticationError, type BillingPeriod, type CheckoutFailedEvent, type CheckoutSucceededEvent, type CreateCustomerParams, type CreateSubscriptionParams, type CreateSubscriptionResponse, type Customer, type CustomerInput, type CustomerInputBilling, type CustomerInputShipping, type FieldErrors, type HttpErrorInput, KycRequiredError, type KycRequiredErrorOptions, type MessageResponse, NetworkError, NotFoundError, type Page, type PageParams, type Plan, type Product, type ProductImage, type ProductVat, RateLimitError, type RateLimitErrorOptions, ServerError, type Subscription, type SubscriptionCustomer, type SubscriptionCustomerBilling, type SubscriptionCustomerShipping, type SubscriptionPage, type SubscriptionProduct, SubscriptionStatus, type SubscriptionStatusChangedEvent, type SubscriptionStatusCounts, SuqoClient, type SuqoClientOptions, SuqoConfigError, type SuqoEnvironment, SuqoError, type SuqoErrorOptions, type UpdateBillingCycleParams, type UpdateCustomerParams, VERSION, ValidationError, type ValidationErrorOptions, type VerifyWebhookOptions, type WebhookEvent, type WebhookEventType, bridgeAutoPaging, deserializePage, listAll, mapHttpError, toPageQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -48,9 +48,12 @@ declare class SuqoError extends Error {
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Construction-time configuration problems: a malformed API key, or an explicit `baseUrl`
|
|
51
|
-
* override that disagrees with the key's prefix (SDK-SPEC.md §2, §7).
|
|
52
|
-
*
|
|
53
|
-
* `
|
|
51
|
+
* override that disagrees with the key's prefix (SDK-SPEC.md §2, §7). Also reused for a call-time
|
|
52
|
+
* argument that would otherwise silently corrupt a request rather than reach the API at all — e.g.
|
|
53
|
+
* an empty `customers.retrieve(id)` (#42) — the same "never even attempted" character as a bad
|
|
54
|
+
* construction option. Thrown before any request is made — analogous to a syntax error in the
|
|
55
|
+
* integration, not an HTTP failure. Never carries `status`/`rawBody`; there was no request to map
|
|
56
|
+
* one from.
|
|
54
57
|
*/
|
|
55
58
|
declare class SuqoConfigError extends SuqoError {
|
|
56
59
|
constructor(message: string, options?: {
|
|
@@ -291,12 +294,21 @@ interface HttpPostRequestOptions<TBody = unknown> extends HttpRequestOptionsBase
|
|
|
291
294
|
/** JSON-serializable request body. Omit entirely for a bodyless write (e.g. `cancel`). */
|
|
292
295
|
body?: TBody;
|
|
293
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Options for a `PATCH` request — a partial update (`customers.update()`). Same body typing as
|
|
299
|
+
* {@link HttpPostRequestOptions}, and like every write it is never retried (SDK-SPEC.md §8).
|
|
300
|
+
*/
|
|
301
|
+
interface HttpPatchRequestOptions<TBody = unknown> extends HttpRequestOptionsBase {
|
|
302
|
+
method: "PATCH";
|
|
303
|
+
/** JSON-serializable request body — only the fields being changed. */
|
|
304
|
+
body?: TBody;
|
|
305
|
+
}
|
|
294
306
|
/**
|
|
295
307
|
* Options accepted by {@link HttpClient.request}. `HttpClient` itself is internal (not exported
|
|
296
308
|
* from `src/index.ts`); the SDK's actual typed, consumer-facing contract lives one layer up, in
|
|
297
309
|
* each resource method's own public signature.
|
|
298
310
|
*/
|
|
299
|
-
type HttpRequestOptions<TBody = unknown> = HttpGetRequestOptions | HttpPostRequestOptions<TBody>;
|
|
311
|
+
type HttpRequestOptions<TBody = unknown> = HttpGetRequestOptions | HttpPostRequestOptions<TBody> | HttpPatchRequestOptions<TBody>;
|
|
300
312
|
/** Options accepted by {@link HttpClient}'s constructor. */
|
|
301
313
|
interface HttpClientOptions {
|
|
302
314
|
/**
|
|
@@ -468,6 +480,13 @@ interface ProductVat {
|
|
|
468
480
|
/** Decimal string (e.g. `"13.00"`). Never coerced to a number — SDK-SPEC.md §5. */
|
|
469
481
|
vatPercentage: string;
|
|
470
482
|
}
|
|
483
|
+
/** One image on a {@link Product} (`openapi.yaml` `ProductImage`). */
|
|
484
|
+
interface ProductImage {
|
|
485
|
+
/** Absolute image URL. */
|
|
486
|
+
image: string;
|
|
487
|
+
/** Display position, lowest first. */
|
|
488
|
+
imageOrder: number;
|
|
489
|
+
}
|
|
471
490
|
/** A seller's product, as returned by `products.list()` (`openapi.yaml` `Product`). */
|
|
472
491
|
interface Product {
|
|
473
492
|
productId: string;
|
|
@@ -478,8 +497,11 @@ interface Product {
|
|
|
478
497
|
termsAndConditions: string;
|
|
479
498
|
featuresAndBenefits: string;
|
|
480
499
|
vat: ProductVat | null;
|
|
481
|
-
/**
|
|
482
|
-
|
|
500
|
+
/**
|
|
501
|
+
* Ordered images; blank images already excluded server-side. Each is an object, not a bare URL
|
|
502
|
+
* string — the API has always sent `{ image, image_order }`.
|
|
503
|
+
*/
|
|
504
|
+
productImage: ProductImage[];
|
|
483
505
|
plan: Plan[];
|
|
484
506
|
/** Count of active subscribers. Sent as a string on the wire — kept as one, never coerced (SDK-SPEC.md §5). */
|
|
485
507
|
totalSubscribers: string;
|
|
@@ -589,18 +611,19 @@ interface CustomerInput {
|
|
|
589
611
|
}
|
|
590
612
|
/**
|
|
591
613
|
* A seller's own customer record, as returned by `customers.list()`/`customers.retrieve()`
|
|
592
|
-
* (`openapi.yaml` `Customer
|
|
593
|
-
*
|
|
614
|
+
* (`openapi.yaml` `Customer`). Distinct from {@link SubscriptionCustomer} and {@link CustomerInput}
|
|
615
|
+
* — see this file's module doc.
|
|
594
616
|
*
|
|
595
617
|
* Uses `buyer*`-prefixed field names, not the `client.*` nesting Subscriptions uses — a genuinely
|
|
596
|
-
* different resource with its own
|
|
618
|
+
* different resource with its own convention, carried through as-is.
|
|
597
619
|
*/
|
|
598
620
|
interface Customer {
|
|
599
|
-
/**
|
|
600
|
-
id:
|
|
621
|
+
/** Opaque prefixed id, e.g. `"cus_1ce18d624"` — a string, like `pbp_...` on billing periods, not an integer. */
|
|
622
|
+
id: string;
|
|
601
623
|
buyerPhone: string | null;
|
|
602
624
|
buyerEmail: string | null;
|
|
603
625
|
fullName: string | null;
|
|
626
|
+
address: string | null;
|
|
604
627
|
createdAt: string;
|
|
605
628
|
}
|
|
606
629
|
|
|
@@ -716,6 +739,42 @@ interface UpdateBillingCycleParams {
|
|
|
716
739
|
nextBillingCycle: string;
|
|
717
740
|
}
|
|
718
741
|
|
|
742
|
+
/**
|
|
743
|
+
* Input shapes for the `customers` write methods (`specs/openapi.yaml`
|
|
744
|
+
* `CreateCustomerRequest`/`UpdateCustomerRequest`). Named `*Params`, not `*Request` — SDK Naming
|
|
745
|
+
* Map v1.1 §12, same as `subscriptionParams.ts`.
|
|
746
|
+
*
|
|
747
|
+
* Note the read/write name asymmetry on the wire: `phone`/`email` sent here read back on
|
|
748
|
+
* {@link import("./Customer.js").Customer} as `buyerPhone`/`buyerEmail`. The params keep the
|
|
749
|
+
* wire's write-side names rather than borrowing the read side's `buyer*` prefix.
|
|
750
|
+
*
|
|
751
|
+
* @packageDocumentation
|
|
752
|
+
*/
|
|
753
|
+
/** What `customers.create(params)` accepts (`openapi.yaml` `CreateCustomerRequest`, renamed). */
|
|
754
|
+
interface CreateCustomerParams {
|
|
755
|
+
/**
|
|
756
|
+
* Identifies the buyer and can't be changed later. A Nepali mobile number: 10 digits starting
|
|
757
|
+
* with 96, 97 or 98 — a `+977` country code, a leading 0, spaces and dashes are accepted and
|
|
758
|
+
* stripped server-side. Reads back as `buyerPhone`.
|
|
759
|
+
*/
|
|
760
|
+
phone: string;
|
|
761
|
+
fullName?: string;
|
|
762
|
+
/** Reads back as `buyerEmail`. */
|
|
763
|
+
email?: string;
|
|
764
|
+
address?: string;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* What `customers.update(id, params)` accepts (`openapi.yaml` `UpdateCustomerRequest`, renamed).
|
|
768
|
+
* Send only the fields you're changing; `""` clears a field. There's no `phone` — it identifies
|
|
769
|
+
* the buyer and can't be changed.
|
|
770
|
+
*/
|
|
771
|
+
interface UpdateCustomerParams {
|
|
772
|
+
fullName?: string;
|
|
773
|
+
/** Reads back as `buyerEmail`. */
|
|
774
|
+
email?: string;
|
|
775
|
+
address?: string;
|
|
776
|
+
}
|
|
777
|
+
|
|
719
778
|
/**
|
|
720
779
|
* What `subscriptions.cancel()`, `subscriptions.updateBillingCycle()`, and
|
|
721
780
|
* `subscriptions.resume()` all return (`specs/openapi.yaml` `Message`, renamed). Named
|
|
@@ -903,8 +962,8 @@ declare class SubscriptionsResource {
|
|
|
903
962
|
}
|
|
904
963
|
|
|
905
964
|
/**
|
|
906
|
-
* `client.customers` (SDK-SPEC.md §5, §6; `openapi.yaml` `listCustomers`/`retrieveCustomer
|
|
907
|
-
*
|
|
965
|
+
* `client.customers` (SDK-SPEC.md §5, §6; `openapi.yaml` `listCustomers`/`retrieveCustomer`/
|
|
966
|
+
* `createCustomer`/`updateCustomer`). No delete exists on this resource.
|
|
908
967
|
*/
|
|
909
968
|
declare class CustomersResource {
|
|
910
969
|
#private;
|
|
@@ -918,10 +977,29 @@ declare class CustomersResource {
|
|
|
918
977
|
*/
|
|
919
978
|
autoPaging(params?: PageParams): AsyncIterableIterator<Customer>;
|
|
920
979
|
/**
|
|
921
|
-
* Retrieves a single customer by id
|
|
922
|
-
*
|
|
980
|
+
* Retrieves a single customer by id — an opaque prefixed string (e.g. `"cus_1ce18d624"`), like
|
|
981
|
+
* `pbp_...` on billing periods, not an integer and not a UUID (Bug #42 corrected the previously
|
|
982
|
+
* wrong `number` type/doc claim here).
|
|
983
|
+
*/
|
|
984
|
+
retrieve(id: string): Promise<Customer>;
|
|
985
|
+
/**
|
|
986
|
+
* Records a customer on the seller's account without opening a subscription. `phone` identifies
|
|
987
|
+
* the buyer; the name, email and address are the seller's own copy and aren't shared with other
|
|
988
|
+
* sellers.
|
|
989
|
+
*
|
|
990
|
+
* A phone the seller already holds updates that existing customer instead of creating a second
|
|
991
|
+
* one (the API answers `200` rather than `201`; both resolve to the `Customer` here). That makes
|
|
992
|
+
* this call safe for the caller to retry — but, like every write, the SDK never retries it
|
|
993
|
+
* automatically (SDK-SPEC.md §8, §12).
|
|
994
|
+
*/
|
|
995
|
+
create(params: CreateCustomerParams): Promise<Customer>;
|
|
996
|
+
/**
|
|
997
|
+
* Updates the seller's copy of a customer's name, email or address. Send only the fields you're
|
|
998
|
+
* changing; `""` clears a field. The phone can't be changed.
|
|
999
|
+
*
|
|
1000
|
+
* Not auto-retryable — writes never retry until idempotency ships (SDK-SPEC.md §8, §12).
|
|
923
1001
|
*/
|
|
924
|
-
|
|
1002
|
+
update(id: string, params: UpdateCustomerParams): Promise<Customer>;
|
|
925
1003
|
}
|
|
926
1004
|
|
|
927
1005
|
/**
|
|
@@ -1016,7 +1094,7 @@ declare class SuqoClient {
|
|
|
1016
1094
|
readonly products: ProductsResource;
|
|
1017
1095
|
/** Create, list, and manage subscriptions (SDK-SPEC.md §5, §6, §7). */
|
|
1018
1096
|
readonly subscriptions: SubscriptionsResource;
|
|
1019
|
-
/** List and
|
|
1097
|
+
/** List, retrieve, create and update the seller's customers (SDK-SPEC.md §5, §6). */
|
|
1020
1098
|
readonly customers: CustomersResource;
|
|
1021
1099
|
/** Verify inbound webhook deliveries (SDK-SPEC.md §9). Makes no network call, needs no key. */
|
|
1022
1100
|
readonly webhooks: WebhooksResource;
|
|
@@ -1040,6 +1118,6 @@ declare class SuqoClient {
|
|
|
1040
1118
|
* @packageDocumentation
|
|
1041
1119
|
*/
|
|
1042
1120
|
/** SDK version, stamped into request headers (keep in sync with package.json). */
|
|
1043
|
-
declare const VERSION = "1.
|
|
1121
|
+
declare const VERSION = "1.1.0";
|
|
1044
1122
|
|
|
1045
|
-
export { type ApiKeyCreatedEvent, type ApiKeyDeletedEvent, type ApiKeyExpiredEvent, type ApiKeyExpiringSoonEvent, AuthenticationError, type BillingPeriod, type CheckoutFailedEvent, type CheckoutSucceededEvent, type CreateSubscriptionParams, type CreateSubscriptionResponse, type Customer, type CustomerInput, type CustomerInputBilling, type CustomerInputShipping, type FieldErrors, type HttpErrorInput, KycRequiredError, type KycRequiredErrorOptions, type MessageResponse, NetworkError, NotFoundError, type Page, type PageParams, type Plan, type Product, type ProductVat, RateLimitError, type RateLimitErrorOptions, ServerError, type Subscription, type SubscriptionCustomer, type SubscriptionCustomerBilling, type SubscriptionCustomerShipping, type SubscriptionPage, type SubscriptionProduct, SubscriptionStatus, type SubscriptionStatusChangedEvent, type SubscriptionStatusCounts, SuqoClient, type SuqoClientOptions, SuqoConfigError, type SuqoEnvironment, SuqoError, type SuqoErrorOptions, type UpdateBillingCycleParams, VERSION, ValidationError, type ValidationErrorOptions, type VerifyWebhookOptions, type WebhookEvent, type WebhookEventType, bridgeAutoPaging, deserializePage, listAll, mapHttpError, toPageQuery };
|
|
1123
|
+
export { type ApiKeyCreatedEvent, type ApiKeyDeletedEvent, type ApiKeyExpiredEvent, type ApiKeyExpiringSoonEvent, AuthenticationError, type BillingPeriod, type CheckoutFailedEvent, type CheckoutSucceededEvent, type CreateCustomerParams, type CreateSubscriptionParams, type CreateSubscriptionResponse, type Customer, type CustomerInput, type CustomerInputBilling, type CustomerInputShipping, type FieldErrors, type HttpErrorInput, KycRequiredError, type KycRequiredErrorOptions, type MessageResponse, NetworkError, NotFoundError, type Page, type PageParams, type Plan, type Product, type ProductImage, type ProductVat, RateLimitError, type RateLimitErrorOptions, ServerError, type Subscription, type SubscriptionCustomer, type SubscriptionCustomerBilling, type SubscriptionCustomerShipping, type SubscriptionPage, type SubscriptionProduct, SubscriptionStatus, type SubscriptionStatusChangedEvent, type SubscriptionStatusCounts, SuqoClient, type SuqoClientOptions, SuqoConfigError, type SuqoEnvironment, SuqoError, type SuqoErrorOptions, type UpdateBillingCycleParams, type UpdateCustomerParams, VERSION, ValidationError, type ValidationErrorOptions, type VerifyWebhookOptions, type WebhookEvent, type WebhookEventType, bridgeAutoPaging, deserializePage, listAll, mapHttpError, toPageQuery };
|
package/dist/index.js
CHANGED
|
@@ -358,7 +358,7 @@ var HttpClient = class {
|
|
|
358
358
|
if (isWrite) {
|
|
359
359
|
headers["Content-Type"] = "application/json";
|
|
360
360
|
}
|
|
361
|
-
const body = options.method
|
|
361
|
+
const body = options.method !== "GET" ? options.body : void 0;
|
|
362
362
|
const { signal, cleanup } = combineSignals([AbortSignal.timeout(timeoutMs), options.signal]);
|
|
363
363
|
try {
|
|
364
364
|
const init = {
|
|
@@ -463,7 +463,7 @@ function deserializeProduct(wire) {
|
|
|
463
463
|
// `vat` is spec-legal, and the old `=== null` check crashed on `deserializeProductVat(undefined)`
|
|
464
464
|
// when that happened (found in review, reproduced).
|
|
465
465
|
vat: wire.vat == null ? null : deserializeProductVat(wire.vat),
|
|
466
|
-
productImage: wire.product_image,
|
|
466
|
+
productImage: (wire.product_image ?? []).map((img) => ({ image: img.image, imageOrder: img.image_order })),
|
|
467
467
|
// Same reasoning as `billingPeriods` above — `plan` being omitted entirely is spec-legal.
|
|
468
468
|
plan: (wire.plan ?? []).map(deserializePlan),
|
|
469
469
|
totalSubscribers: wire.total_subscribers,
|
|
@@ -726,12 +726,27 @@ var CUSTOMERS_PATH = "/api/v1/customers";
|
|
|
726
726
|
function deserializeCustomer(wire) {
|
|
727
727
|
return {
|
|
728
728
|
id: wire.id,
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
729
|
+
// `?? null` on all four nullable fields (not a direct pass-through, found in review): catches
|
|
730
|
+
// both an explicit `null` and an entirely omitted key — see the WireCustomer comment above.
|
|
731
|
+
buyerPhone: wire.buyer_phone ?? null,
|
|
732
|
+
buyerEmail: wire.buyer_email ?? null,
|
|
733
|
+
fullName: wire.full_name ?? null,
|
|
734
|
+
address: wire.address ?? null,
|
|
732
735
|
createdAt: wire.created_at
|
|
733
736
|
};
|
|
734
737
|
}
|
|
738
|
+
function serializeCustomerFields(params) {
|
|
739
|
+
const wire = {};
|
|
740
|
+
if (params.fullName !== void 0) wire.full_name = params.fullName;
|
|
741
|
+
if (params.email !== void 0) wire.email = params.email;
|
|
742
|
+
if (params.address !== void 0) wire.address = params.address;
|
|
743
|
+
return wire;
|
|
744
|
+
}
|
|
745
|
+
function assertCustomerId(id, method) {
|
|
746
|
+
if (!id || id === "." || id === "..") {
|
|
747
|
+
throw new SuqoConfigError(`customers.${method}() requires a non-empty id other than "." or ".."`);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
735
750
|
var CustomersResource = class {
|
|
736
751
|
#http;
|
|
737
752
|
constructor(http) {
|
|
@@ -758,16 +773,51 @@ var CustomersResource = class {
|
|
|
758
773
|
});
|
|
759
774
|
}
|
|
760
775
|
/**
|
|
761
|
-
* Retrieves a single customer by id
|
|
762
|
-
*
|
|
776
|
+
* Retrieves a single customer by id — an opaque prefixed string (e.g. `"cus_1ce18d624"`), like
|
|
777
|
+
* `pbp_...` on billing periods, not an integer and not a UUID (Bug #42 corrected the previously
|
|
778
|
+
* wrong `number` type/doc claim here).
|
|
763
779
|
*/
|
|
764
780
|
async retrieve(id) {
|
|
781
|
+
assertCustomerId(id, "retrieve");
|
|
765
782
|
const wire = await this.#http.request({
|
|
766
783
|
method: "GET",
|
|
767
784
|
path: `${CUSTOMERS_PATH}/${encodeURIComponent(id)}`
|
|
768
785
|
});
|
|
769
786
|
return deserializeCustomer(wire);
|
|
770
787
|
}
|
|
788
|
+
/**
|
|
789
|
+
* Records a customer on the seller's account without opening a subscription. `phone` identifies
|
|
790
|
+
* the buyer; the name, email and address are the seller's own copy and aren't shared with other
|
|
791
|
+
* sellers.
|
|
792
|
+
*
|
|
793
|
+
* A phone the seller already holds updates that existing customer instead of creating a second
|
|
794
|
+
* one (the API answers `200` rather than `201`; both resolve to the `Customer` here). That makes
|
|
795
|
+
* this call safe for the caller to retry — but, like every write, the SDK never retries it
|
|
796
|
+
* automatically (SDK-SPEC.md §8, §12).
|
|
797
|
+
*/
|
|
798
|
+
async create(params) {
|
|
799
|
+
const wire = await this.#http.request({
|
|
800
|
+
method: "POST",
|
|
801
|
+
path: CUSTOMERS_PATH,
|
|
802
|
+
body: { phone: params.phone, ...serializeCustomerFields(params) }
|
|
803
|
+
});
|
|
804
|
+
return deserializeCustomer(wire);
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Updates the seller's copy of a customer's name, email or address. Send only the fields you're
|
|
808
|
+
* changing; `""` clears a field. The phone can't be changed.
|
|
809
|
+
*
|
|
810
|
+
* Not auto-retryable — writes never retry until idempotency ships (SDK-SPEC.md §8, §12).
|
|
811
|
+
*/
|
|
812
|
+
async update(id, params) {
|
|
813
|
+
assertCustomerId(id, "update");
|
|
814
|
+
const wire = await this.#http.request({
|
|
815
|
+
method: "PATCH",
|
|
816
|
+
path: `${CUSTOMERS_PATH}/${encodeURIComponent(id)}`,
|
|
817
|
+
body: serializeCustomerFields(params)
|
|
818
|
+
});
|
|
819
|
+
return deserializeCustomer(wire);
|
|
820
|
+
}
|
|
771
821
|
};
|
|
772
822
|
var DEFAULT_TOLERANCE_SEC = 300;
|
|
773
823
|
var SIGNATURE_PREFIX = "sha256=";
|
|
@@ -851,7 +901,7 @@ var SuqoClient = class {
|
|
|
851
901
|
};
|
|
852
902
|
|
|
853
903
|
// src/index.ts
|
|
854
|
-
var VERSION = "1.
|
|
904
|
+
var VERSION = "1.1.0";
|
|
855
905
|
|
|
856
906
|
export { AuthenticationError, KycRequiredError, NetworkError, NotFoundError, RateLimitError, ServerError, SubscriptionStatus, SuqoClient, SuqoConfigError, SuqoError, VERSION, ValidationError, bridgeAutoPaging, deserializePage, listAll, mapHttpError, toPageQuery };
|
|
857
907
|
//# sourceMappingURL=index.js.map
|