@garuhq/node 1.1.0 → 2.0.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/CHANGELOG.md CHANGED
@@ -3,6 +3,51 @@
3
3
  All notable changes to `@garuhq/node` are documented in this file. Format:
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versioning: [SemVer](https://semver.org/).
5
5
 
6
+ ## [2.0.0] — 2026-08-22
7
+
8
+ **Breaking:** `customers` now targets the versioned public API `/api/v1/customers`,
9
+ keyed on `uuid`. If you use `garu.customers.*`, read the migration below.
10
+
11
+ ### Breaking
12
+
13
+ - **`customers` moved to `/api/v1/customers`** and a customer is keyed by
14
+ **`uuid`**, not a numeric `id`.
15
+ - `customers.get(id: number)` → **`customers.get(uuid: string)`** (name
16
+ unchanged, param type changed).
17
+ - `customers.update(id, params)` — same signature shape, but the id
18
+ argument is now the `uuid`, and the request now goes out as `PATCH`
19
+ (was `PUT`).
20
+ - `customers.setBillingEmailOverride(id, params)` / `customers.delete(id)`
21
+ — same, `id` → `uuid`.
22
+ - `CustomerRecord.id` is **removed**; there is no numeric id in the public
23
+ shape. Use `CustomerRecord.uuid` everywhere.
24
+ - **`customers.delete()` now resolves `{ removed: boolean }`** (was `void`).
25
+ - **`customers.list()` returns `{ data, count, totalCount, totalPages }`**
26
+ (was `{ data, meta }`).
27
+ - `installmentPlans.create` and `scheduledCharges.create` are **not**
28
+ migrated yet — they still take a numeric `customerId`. Fetch that id from
29
+ the dashboard or the internal `/api/customers` endpoint until those two
30
+ resources move to `/api/v1` too (tracked in `SPEC-public-api-v1.md` §9
31
+ Phase 4 on the `gateway` repo).
32
+
33
+ ### Migration
34
+
35
+ ```ts
36
+ // before (1.x)
37
+ const c = await garu.customers.create({ name, email, document, phone, personType });
38
+ c.id; // number
39
+ const one = await garu.customers.get(c.id);
40
+ await garu.customers.update(c.id, { name: 'Maria Santos' });
41
+ await garu.customers.delete(c.id);
42
+
43
+ // after (2.0.0)
44
+ const c = await garu.customers.create({ name, email, document, phone, personType });
45
+ c.uuid; // string
46
+ const one = await garu.customers.get(c.uuid);
47
+ await garu.customers.update(c.uuid, { name: 'Maria Santos' });
48
+ const { removed } = await garu.customers.delete(c.uuid);
49
+ ```
50
+
6
51
  ## [1.1.0] — 2026-08-15
7
52
 
8
53
 
package/README.md CHANGED
@@ -84,13 +84,13 @@ const garu = new Garu({
84
84
 
85
85
  ## Charges
86
86
 
87
- | Method | Description |
88
- | ----------------------- | --------------------------------------------- |
89
- | `create(params)` | Create a PIX, credit-card, or boleto charge. |
90
- | `retrieve(uuid)` | Fetch a single charge by uuid. |
91
- | `list(params?)` | List charges with pagination and filters. |
92
- | `refund(uuid, params?)` | Refund a charge fully or partially (reais). |
93
- | `cancel(uuid)` | Cancel an unpaid charge. |
87
+ | Method | Description |
88
+ | ----------------------- | -------------------------------------------- |
89
+ | `create(params)` | Create a PIX, credit-card, or boleto charge. |
90
+ | `retrieve(uuid)` | Fetch a single charge by uuid. |
91
+ | `list(params?)` | List charges with pagination and filters. |
92
+ | `refund(uuid, params?)` | Refund a charge fully or partially (reais). |
93
+ | `cancel(uuid)` | Cancel an unpaid charge. |
94
94
 
95
95
  ### Create a PIX charge
96
96
 
@@ -146,13 +146,20 @@ await garu.charges.refund('6f1c9b2e-…', { amount: 10.0 }); // partial refund (
146
146
 
147
147
  ## Customers
148
148
 
149
- | Method | Description |
150
- | -------------------- | ------------------------------------------ |
151
- | `create(params)` | Create a new customer. |
152
- | `list(params?)` | List customers with pagination and search. |
153
- | `get(id)` | Fetch a single customer by ID. |
154
- | `update(id, params)` | Update a customer's profile. |
155
- | `delete(id)` | Delete a customer. |
149
+ Backed by `/api/v1/customers`, keyed on `uuid` — there is no numeric id in
150
+ this shape. `installmentPlans.create` and `scheduledCharges.create` still
151
+ link customers by the internal numeric id (unmigrated resources); fetch that
152
+ id from the dashboard or the internal `/api/customers` endpoint until they
153
+ move to `/api/v1` too.
154
+
155
+ | Method | Description |
156
+ | --------------------------------------- | ----------------------------------------------- |
157
+ | `create(params)` | Register a customer for the current seller. |
158
+ | `list(params?)` | List customers with pagination and search. |
159
+ | `get(uuid)` | Fetch a single customer by uuid. |
160
+ | `update(uuid, params)` | Partially update a customer's profile. |
161
+ | `setBillingEmailOverride(uuid, params)` | Set or clear the sticky billing-email override. |
162
+ | `delete(uuid)` | Remove a customer from the current seller. |
156
163
 
157
164
  ```ts
158
165
  const customer = await garu.customers.create({
@@ -163,7 +170,7 @@ const customer = await garu.customers.create({
163
170
  personType: 'fisica'
164
171
  });
165
172
 
166
- const { data, meta } = await garu.customers.list({ search: 'maria', limit: 10 });
173
+ const { data, totalCount } = await garu.customers.list({ search: 'maria', limit: 10 });
167
174
  ```
168
175
 
169
176
  ## Products
package/dist/index.cjs CHANGED
@@ -633,10 +633,11 @@ var Customers = class {
633
633
  * phone: '11987654321',
634
634
  * personType: 'fisica'
635
635
  * });
636
+ * customer.uuid;
636
637
  */
637
638
  async create(params) {
638
639
  return this.http.call(
639
- (signal) => this.http.client.POST("/api/customers", {
640
+ (signal) => this.http.client.POST("/api/v1/customers", {
640
641
  body: params,
641
642
  signal
642
643
  }).then((r) => r)
@@ -646,7 +647,11 @@ var Customers = class {
646
647
  * List customers for the authenticated seller, with pagination and search.
647
648
  *
648
649
  * @example
649
- * const { data, meta } = await garu.customers.list({ search: 'maria', limit: 10 });
650
+ * const { data, totalCount } = await garu.customers.list({ search: 'maria', limit: 10 });
651
+ *
652
+ * @example
653
+ * // Customers with at least one overdue scheduled charge (carnê included).
654
+ * const atRisk = await garu.customers.list({ status: 'overdue' });
650
655
  */
651
656
  async list(params = {}) {
652
657
  const query = {};
@@ -655,7 +660,7 @@ var Customers = class {
655
660
  if (params.search) query.search = params.search;
656
661
  if (params.status) query.status = params.status;
657
662
  const qs = new URLSearchParams(query).toString();
658
- const url = `/api/customers${qs ? `?${qs}` : ""}`;
663
+ const url = `/api/v1/customers${qs ? `?${qs}` : ""}`;
659
664
  return this.http.call(
660
665
  (signal) => this.http.client.GET(url, { signal }).then(
661
666
  (r) => r
@@ -663,27 +668,28 @@ var Customers = class {
663
668
  );
664
669
  }
665
670
  /**
666
- * Fetch a single customer by numeric ID.
671
+ * Fetch a single customer by uuid.
667
672
  *
668
673
  * @example
669
- * const customer = await garu.customers.get(42);
674
+ * const customer = await garu.customers.get('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
670
675
  */
671
- async get(id) {
676
+ async get(uuid) {
672
677
  return this.http.call(
673
- (signal) => this.http.client.GET(`/api/customers/${id}`, { signal }).then(
678
+ (signal) => this.http.client.GET(`/api/v1/customers/${uuid}`, { signal }).then(
674
679
  (r) => r
675
680
  )
676
681
  );
677
682
  }
678
683
  /**
679
- * Update a customer's profile for the current seller.
684
+ * Update a customer's profile for the current seller. Partial — only the
685
+ * fields you pass change.
680
686
  *
681
687
  * @example
682
- * const updated = await garu.customers.update(42, { name: 'Maria Santos' });
688
+ * const updated = await garu.customers.update('a1b2c3d4-...', { name: 'Maria Santos' });
683
689
  */
684
- async update(id, params) {
690
+ async update(uuid, params) {
685
691
  return this.http.call(
686
- (signal) => this.http.client.PUT(`/api/customers/${id}`, {
692
+ (signal) => this.http.client.PATCH(`/api/v1/customers/${uuid}`, {
687
693
  body: params,
688
694
  signal
689
695
  }).then((r) => r)
@@ -698,30 +704,31 @@ var Customers = class {
698
704
  *
699
705
  * @example
700
706
  * // Set
701
- * await garu.customers.setBillingEmailOverride(42, {
707
+ * await garu.customers.setBillingEmailOverride('a1b2c3d4-...', {
702
708
  * billingEmailOverride: 'cobrancas@empresa.com.br'
703
709
  * });
704
710
  *
705
711
  * // Clear and fall back to the last-used email
706
- * await garu.customers.setBillingEmailOverride(42, { billingEmailOverride: null });
712
+ * await garu.customers.setBillingEmailOverride('a1b2c3d4-...', { billingEmailOverride: null });
707
713
  */
708
- async setBillingEmailOverride(id, params) {
714
+ async setBillingEmailOverride(uuid, params) {
709
715
  return this.http.call(
710
- (signal) => this.http.client.PATCH(`/api/customers/${id}/billing-email-override`, {
716
+ (signal) => this.http.client.PATCH(`/api/v1/customers/${uuid}/billing-email-override`, {
711
717
  body: params,
712
718
  signal
713
719
  }).then((r) => r)
714
720
  );
715
721
  }
716
722
  /**
717
- * Remove a customer from the current seller.
723
+ * Remove a customer from the current seller (unlinks your profile — the
724
+ * global customer and other sellers' profiles are untouched).
718
725
  *
719
726
  * @example
720
- * await garu.customers.delete(42);
727
+ * await garu.customers.delete('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
721
728
  */
722
- async delete(id) {
723
- await this.http.call(
724
- (signal) => this.http.client.DELETE(`/api/customers/${id}`, {
729
+ async delete(uuid) {
730
+ return this.http.call(
731
+ (signal) => this.http.client.DELETE(`/api/v1/customers/${uuid}`, {
725
732
  body: {},
726
733
  signal
727
734
  }).then((r) => r)
package/dist/index.d.cts CHANGED
@@ -261,8 +261,15 @@ interface ChargeList {
261
261
  interface CancelChargeResult {
262
262
  canceled: boolean;
263
263
  }
264
+ /**
265
+ * Public API v1 customer representation. Keyed on `uuid` — there is no
266
+ * numeric id in this shape. `installmentPlans.create` and
267
+ * `scheduledCharges.create` still link customers by the internal numeric id
268
+ * (unmigrated resources); fetch that id from the dashboard or the internal
269
+ * `/api/customers` endpoint until they move to `/api/v1` too.
270
+ */
264
271
  interface CustomerRecord {
265
- id: number;
272
+ uuid: string;
266
273
  name: string;
267
274
  email: string;
268
275
  document: string;
@@ -281,10 +288,9 @@ interface CustomerRecord {
281
288
  * Resolved billing email used for outbound seller→customer emails:
282
289
  * `billingEmailOverride ?? per-seller email ?? customer.email`.
283
290
  */
284
- billingEmail?: string;
291
+ billingEmail: string;
285
292
  /** True when a sticky `billingEmailOverride` is set for this seller. */
286
- hasBillingEmailOverride?: boolean;
287
- [key: string]: unknown;
293
+ hasBillingEmailOverride: boolean;
288
294
  }
289
295
  interface SetBillingEmailOverrideParams {
290
296
  /**
@@ -293,7 +299,14 @@ interface SetBillingEmailOverrideParams {
293
299
  */
294
300
  billingEmailOverride: string | null;
295
301
  }
296
- type CustomerList = PaginatedList<CustomerRecord>;
302
+ interface CustomerList {
303
+ data: CustomerRecord[];
304
+ /** Items on this page. */
305
+ count: number;
306
+ /** Total matches across all pages. */
307
+ totalCount: number;
308
+ totalPages: number;
309
+ }
297
310
  interface CreateCustomerParams {
298
311
  name: string;
299
312
  email: string;
@@ -1315,9 +1328,11 @@ declare class RefundRequests {
1315
1328
  /**
1316
1329
  * Customers — manage your customer base.
1317
1330
  *
1318
- * Customers are scoped to the seller identified by the API key. The backend
1319
- * uses a junction table (`customer_seller_profile`) so the same person can
1320
- * exist across multiple sellers without duplication.
1331
+ * Backed by `/api/v1/customers`, keyed on `uuid`. Customers are scoped to the
1332
+ * seller identified by the API key. The backend uses a junction table
1333
+ * (`customer_seller_profile`) so the same person can exist across multiple
1334
+ * sellers without duplication — creating a customer whose `document` already
1335
+ * exists globally attaches your own profile to it instead of erroring.
1321
1336
  */
1322
1337
  declare class Customers {
1323
1338
  private readonly http;
@@ -1333,29 +1348,35 @@ declare class Customers {
1333
1348
  * phone: '11987654321',
1334
1349
  * personType: 'fisica'
1335
1350
  * });
1351
+ * customer.uuid;
1336
1352
  */
1337
1353
  create(params: CreateCustomerParams): Promise<CustomerRecord>;
1338
1354
  /**
1339
1355
  * List customers for the authenticated seller, with pagination and search.
1340
1356
  *
1341
1357
  * @example
1342
- * const { data, meta } = await garu.customers.list({ search: 'maria', limit: 10 });
1358
+ * const { data, totalCount } = await garu.customers.list({ search: 'maria', limit: 10 });
1359
+ *
1360
+ * @example
1361
+ * // Customers with at least one overdue scheduled charge (carnê included).
1362
+ * const atRisk = await garu.customers.list({ status: 'overdue' });
1343
1363
  */
1344
1364
  list(params?: ListCustomersParams): Promise<CustomerList>;
1345
1365
  /**
1346
- * Fetch a single customer by numeric ID.
1366
+ * Fetch a single customer by uuid.
1347
1367
  *
1348
1368
  * @example
1349
- * const customer = await garu.customers.get(42);
1369
+ * const customer = await garu.customers.get('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
1350
1370
  */
1351
- get(id: number): Promise<CustomerRecord>;
1371
+ get(uuid: string): Promise<CustomerRecord>;
1352
1372
  /**
1353
- * Update a customer's profile for the current seller.
1373
+ * Update a customer's profile for the current seller. Partial — only the
1374
+ * fields you pass change.
1354
1375
  *
1355
1376
  * @example
1356
- * const updated = await garu.customers.update(42, { name: 'Maria Santos' });
1377
+ * const updated = await garu.customers.update('a1b2c3d4-...', { name: 'Maria Santos' });
1357
1378
  */
1358
- update(id: number, params: UpdateCustomerParams): Promise<CustomerRecord>;
1379
+ update(uuid: string, params: UpdateCustomerParams): Promise<CustomerRecord>;
1359
1380
  /**
1360
1381
  * Set or clear the per-seller billing email override.
1361
1382
  *
@@ -1365,21 +1386,24 @@ declare class Customers {
1365
1386
  *
1366
1387
  * @example
1367
1388
  * // Set
1368
- * await garu.customers.setBillingEmailOverride(42, {
1389
+ * await garu.customers.setBillingEmailOverride('a1b2c3d4-...', {
1369
1390
  * billingEmailOverride: 'cobrancas@empresa.com.br'
1370
1391
  * });
1371
1392
  *
1372
1393
  * // Clear and fall back to the last-used email
1373
- * await garu.customers.setBillingEmailOverride(42, { billingEmailOverride: null });
1394
+ * await garu.customers.setBillingEmailOverride('a1b2c3d4-...', { billingEmailOverride: null });
1374
1395
  */
1375
- setBillingEmailOverride(id: number, params: SetBillingEmailOverrideParams): Promise<CustomerRecord>;
1396
+ setBillingEmailOverride(uuid: string, params: SetBillingEmailOverrideParams): Promise<CustomerRecord>;
1376
1397
  /**
1377
- * Remove a customer from the current seller.
1398
+ * Remove a customer from the current seller (unlinks your profile — the
1399
+ * global customer and other sellers' profiles are untouched).
1378
1400
  *
1379
1401
  * @example
1380
- * await garu.customers.delete(42);
1402
+ * await garu.customers.delete('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
1381
1403
  */
1382
- delete(id: number): Promise<void>;
1404
+ delete(uuid: string): Promise<{
1405
+ removed: boolean;
1406
+ }>;
1383
1407
  }
1384
1408
 
1385
1409
  /**
@@ -1929,4 +1953,4 @@ declare class GaruServerError extends GaruAPIError {
1929
1953
  constructor(message: string, status: number, requestId: string | null, body: unknown);
1930
1954
  }
1931
1955
 
1932
- export { type CancelAtPeriodEndScheduledChargeParams, type CancelChargeResult, type CancelInstallmentPlanParams, type CancelRecurrenceScheduledChargeParams, type CardInput, type ChangePaymentMethodScheduledChargeParams, type Charge, type ChargeList, type ChargeNowOutcome, type ChargeNowReason, type ChargeNowResult, type ChargePaymentMethod, type ChargeStatus, type CreateChargeParams, type CreateCustomerParams, type CreateInstallmentPlanParams, type CreateProductParams, type CreateScheduledChargeParams, type Customer, type CustomerList, type CustomerRecord, type FailurePayload, Garu, GaruAPIError, GaruAuthenticationError, GaruConnectionError, GaruError, type GaruErrorCode, type GaruFailureCode, GaruNotFoundError, type GaruOptions, GaruPermissionError, GaruRateLimitError, GaruServerError, GaruSignatureVerificationError, GaruValidationError, type Installment, type InstallmentPlan, type InstallmentPlanList, type InstallmentPlanStatus, type InstallmentStatus, type ListChargesParams, type ListCustomersParams, type ListInstallmentPlansParams, type ListProductsParams, type ListRefundRequestsParams, type ListScheduledChargeAttemptsParams, type ListScheduledChargesParams, type ListWebhookEventsParams, type MarkPaidScheduledChargeParams, type MetaFeatures, type MetaResponse, type PaginatedList, type PauseScheduledChargeParams, type PaymentMethodExpiredPayload, type PaymentMethodExpiringPayload, type PostponeInstallmentParams, type PostponeScheduledChargeParams, type Product, type ProductList, type ProductPortalConfig, type RecurrenceConfig, type RecurrenceInterval, type RefundChargeParams, type RefundRequest, type RefundRequestList, type RefundRequestStatus, type ReissueInstallmentResult, type RequestPlanRefundParams, type ResendWebhookEventParams, type ResolveRefundRequestParams, type ScheduledChargeActor, type ScheduledChargeAttempt, type ScheduledChargeAttemptList, type ScheduledChargeAttemptSource, type ScheduledChargeAttemptStatus, type ScheduledChargeDetail, type ScheduledChargeEvent, type ScheduledChargeEventType, type ScheduledChargeLinkedTransaction, type ScheduledChargeList, type ScheduledChargeRecord, type ScheduledChargeStatus, type ScheduledChargeType, type ScheduledPaymentMethod, type SetProductPortalConfigParams, type UpdateCustomerParams, type UpdateProductParams, type VerifiedWebhook, type VerifyWebhookParams, type WebhookEvent, type WebhookEventEndpoint, type WebhookEventList, type WebhookEventStatus, webhooks };
1956
+ export { type CancelAtPeriodEndScheduledChargeParams, type CancelChargeResult, type CancelInstallmentPlanParams, type CancelRecurrenceScheduledChargeParams, type CardInput, type ChangePaymentMethodScheduledChargeParams, type Charge, type ChargeList, type ChargeNowOutcome, type ChargeNowReason, type ChargeNowResult, type ChargePaymentMethod, type ChargeStatus, type CreateChargeParams, type CreateCustomerParams, type CreateInstallmentPlanParams, type CreateProductParams, type CreateScheduledChargeParams, type Customer, type CustomerList, type CustomerRecord, type FailurePayload, Garu, GaruAPIError, GaruAuthenticationError, GaruConnectionError, GaruError, type GaruErrorCode, type GaruFailureCode, GaruNotFoundError, type GaruOptions, GaruPermissionError, GaruRateLimitError, GaruServerError, GaruSignatureVerificationError, GaruValidationError, type Installment, type InstallmentPlan, type InstallmentPlanList, type InstallmentPlanStatus, type InstallmentStatus, type ListChargesParams, type ListCustomersParams, type ListInstallmentPlansParams, type ListProductsParams, type ListRefundRequestsParams, type ListScheduledChargeAttemptsParams, type ListScheduledChargesParams, type ListWebhookEventsParams, type MarkPaidScheduledChargeParams, type MetaFeatures, type MetaResponse, type PaginatedList, type PauseScheduledChargeParams, type PaymentMethodExpiredPayload, type PaymentMethodExpiringPayload, type PostponeInstallmentParams, type PostponeScheduledChargeParams, type Product, type ProductList, type ProductPortalConfig, type RecurrenceConfig, type RecurrenceInterval, type RefundChargeParams, type RefundRequest, type RefundRequestList, type RefundRequestStatus, type ReissueInstallmentResult, type RequestPlanRefundParams, type ResendWebhookEventParams, type ResolveRefundRequestParams, type ScheduledChargeActor, type ScheduledChargeAttempt, type ScheduledChargeAttemptList, type ScheduledChargeAttemptSource, type ScheduledChargeAttemptStatus, type ScheduledChargeDetail, type ScheduledChargeEvent, type ScheduledChargeEventType, type ScheduledChargeLinkedTransaction, type ScheduledChargeList, type ScheduledChargeRecord, type ScheduledChargeStatus, type ScheduledChargeType, type ScheduledPaymentMethod, type SetBillingEmailOverrideParams, type SetProductPortalConfigParams, type UpdateCustomerParams, type UpdateProductParams, type VerifiedWebhook, type VerifyWebhookParams, type WebhookEvent, type WebhookEventEndpoint, type WebhookEventList, type WebhookEventStatus, webhooks };
package/dist/index.d.ts CHANGED
@@ -261,8 +261,15 @@ interface ChargeList {
261
261
  interface CancelChargeResult {
262
262
  canceled: boolean;
263
263
  }
264
+ /**
265
+ * Public API v1 customer representation. Keyed on `uuid` — there is no
266
+ * numeric id in this shape. `installmentPlans.create` and
267
+ * `scheduledCharges.create` still link customers by the internal numeric id
268
+ * (unmigrated resources); fetch that id from the dashboard or the internal
269
+ * `/api/customers` endpoint until they move to `/api/v1` too.
270
+ */
264
271
  interface CustomerRecord {
265
- id: number;
272
+ uuid: string;
266
273
  name: string;
267
274
  email: string;
268
275
  document: string;
@@ -281,10 +288,9 @@ interface CustomerRecord {
281
288
  * Resolved billing email used for outbound seller→customer emails:
282
289
  * `billingEmailOverride ?? per-seller email ?? customer.email`.
283
290
  */
284
- billingEmail?: string;
291
+ billingEmail: string;
285
292
  /** True when a sticky `billingEmailOverride` is set for this seller. */
286
- hasBillingEmailOverride?: boolean;
287
- [key: string]: unknown;
293
+ hasBillingEmailOverride: boolean;
288
294
  }
289
295
  interface SetBillingEmailOverrideParams {
290
296
  /**
@@ -293,7 +299,14 @@ interface SetBillingEmailOverrideParams {
293
299
  */
294
300
  billingEmailOverride: string | null;
295
301
  }
296
- type CustomerList = PaginatedList<CustomerRecord>;
302
+ interface CustomerList {
303
+ data: CustomerRecord[];
304
+ /** Items on this page. */
305
+ count: number;
306
+ /** Total matches across all pages. */
307
+ totalCount: number;
308
+ totalPages: number;
309
+ }
297
310
  interface CreateCustomerParams {
298
311
  name: string;
299
312
  email: string;
@@ -1315,9 +1328,11 @@ declare class RefundRequests {
1315
1328
  /**
1316
1329
  * Customers — manage your customer base.
1317
1330
  *
1318
- * Customers are scoped to the seller identified by the API key. The backend
1319
- * uses a junction table (`customer_seller_profile`) so the same person can
1320
- * exist across multiple sellers without duplication.
1331
+ * Backed by `/api/v1/customers`, keyed on `uuid`. Customers are scoped to the
1332
+ * seller identified by the API key. The backend uses a junction table
1333
+ * (`customer_seller_profile`) so the same person can exist across multiple
1334
+ * sellers without duplication — creating a customer whose `document` already
1335
+ * exists globally attaches your own profile to it instead of erroring.
1321
1336
  */
1322
1337
  declare class Customers {
1323
1338
  private readonly http;
@@ -1333,29 +1348,35 @@ declare class Customers {
1333
1348
  * phone: '11987654321',
1334
1349
  * personType: 'fisica'
1335
1350
  * });
1351
+ * customer.uuid;
1336
1352
  */
1337
1353
  create(params: CreateCustomerParams): Promise<CustomerRecord>;
1338
1354
  /**
1339
1355
  * List customers for the authenticated seller, with pagination and search.
1340
1356
  *
1341
1357
  * @example
1342
- * const { data, meta } = await garu.customers.list({ search: 'maria', limit: 10 });
1358
+ * const { data, totalCount } = await garu.customers.list({ search: 'maria', limit: 10 });
1359
+ *
1360
+ * @example
1361
+ * // Customers with at least one overdue scheduled charge (carnê included).
1362
+ * const atRisk = await garu.customers.list({ status: 'overdue' });
1343
1363
  */
1344
1364
  list(params?: ListCustomersParams): Promise<CustomerList>;
1345
1365
  /**
1346
- * Fetch a single customer by numeric ID.
1366
+ * Fetch a single customer by uuid.
1347
1367
  *
1348
1368
  * @example
1349
- * const customer = await garu.customers.get(42);
1369
+ * const customer = await garu.customers.get('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
1350
1370
  */
1351
- get(id: number): Promise<CustomerRecord>;
1371
+ get(uuid: string): Promise<CustomerRecord>;
1352
1372
  /**
1353
- * Update a customer's profile for the current seller.
1373
+ * Update a customer's profile for the current seller. Partial — only the
1374
+ * fields you pass change.
1354
1375
  *
1355
1376
  * @example
1356
- * const updated = await garu.customers.update(42, { name: 'Maria Santos' });
1377
+ * const updated = await garu.customers.update('a1b2c3d4-...', { name: 'Maria Santos' });
1357
1378
  */
1358
- update(id: number, params: UpdateCustomerParams): Promise<CustomerRecord>;
1379
+ update(uuid: string, params: UpdateCustomerParams): Promise<CustomerRecord>;
1359
1380
  /**
1360
1381
  * Set or clear the per-seller billing email override.
1361
1382
  *
@@ -1365,21 +1386,24 @@ declare class Customers {
1365
1386
  *
1366
1387
  * @example
1367
1388
  * // Set
1368
- * await garu.customers.setBillingEmailOverride(42, {
1389
+ * await garu.customers.setBillingEmailOverride('a1b2c3d4-...', {
1369
1390
  * billingEmailOverride: 'cobrancas@empresa.com.br'
1370
1391
  * });
1371
1392
  *
1372
1393
  * // Clear and fall back to the last-used email
1373
- * await garu.customers.setBillingEmailOverride(42, { billingEmailOverride: null });
1394
+ * await garu.customers.setBillingEmailOverride('a1b2c3d4-...', { billingEmailOverride: null });
1374
1395
  */
1375
- setBillingEmailOverride(id: number, params: SetBillingEmailOverrideParams): Promise<CustomerRecord>;
1396
+ setBillingEmailOverride(uuid: string, params: SetBillingEmailOverrideParams): Promise<CustomerRecord>;
1376
1397
  /**
1377
- * Remove a customer from the current seller.
1398
+ * Remove a customer from the current seller (unlinks your profile — the
1399
+ * global customer and other sellers' profiles are untouched).
1378
1400
  *
1379
1401
  * @example
1380
- * await garu.customers.delete(42);
1402
+ * await garu.customers.delete('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
1381
1403
  */
1382
- delete(id: number): Promise<void>;
1404
+ delete(uuid: string): Promise<{
1405
+ removed: boolean;
1406
+ }>;
1383
1407
  }
1384
1408
 
1385
1409
  /**
@@ -1929,4 +1953,4 @@ declare class GaruServerError extends GaruAPIError {
1929
1953
  constructor(message: string, status: number, requestId: string | null, body: unknown);
1930
1954
  }
1931
1955
 
1932
- export { type CancelAtPeriodEndScheduledChargeParams, type CancelChargeResult, type CancelInstallmentPlanParams, type CancelRecurrenceScheduledChargeParams, type CardInput, type ChangePaymentMethodScheduledChargeParams, type Charge, type ChargeList, type ChargeNowOutcome, type ChargeNowReason, type ChargeNowResult, type ChargePaymentMethod, type ChargeStatus, type CreateChargeParams, type CreateCustomerParams, type CreateInstallmentPlanParams, type CreateProductParams, type CreateScheduledChargeParams, type Customer, type CustomerList, type CustomerRecord, type FailurePayload, Garu, GaruAPIError, GaruAuthenticationError, GaruConnectionError, GaruError, type GaruErrorCode, type GaruFailureCode, GaruNotFoundError, type GaruOptions, GaruPermissionError, GaruRateLimitError, GaruServerError, GaruSignatureVerificationError, GaruValidationError, type Installment, type InstallmentPlan, type InstallmentPlanList, type InstallmentPlanStatus, type InstallmentStatus, type ListChargesParams, type ListCustomersParams, type ListInstallmentPlansParams, type ListProductsParams, type ListRefundRequestsParams, type ListScheduledChargeAttemptsParams, type ListScheduledChargesParams, type ListWebhookEventsParams, type MarkPaidScheduledChargeParams, type MetaFeatures, type MetaResponse, type PaginatedList, type PauseScheduledChargeParams, type PaymentMethodExpiredPayload, type PaymentMethodExpiringPayload, type PostponeInstallmentParams, type PostponeScheduledChargeParams, type Product, type ProductList, type ProductPortalConfig, type RecurrenceConfig, type RecurrenceInterval, type RefundChargeParams, type RefundRequest, type RefundRequestList, type RefundRequestStatus, type ReissueInstallmentResult, type RequestPlanRefundParams, type ResendWebhookEventParams, type ResolveRefundRequestParams, type ScheduledChargeActor, type ScheduledChargeAttempt, type ScheduledChargeAttemptList, type ScheduledChargeAttemptSource, type ScheduledChargeAttemptStatus, type ScheduledChargeDetail, type ScheduledChargeEvent, type ScheduledChargeEventType, type ScheduledChargeLinkedTransaction, type ScheduledChargeList, type ScheduledChargeRecord, type ScheduledChargeStatus, type ScheduledChargeType, type ScheduledPaymentMethod, type SetProductPortalConfigParams, type UpdateCustomerParams, type UpdateProductParams, type VerifiedWebhook, type VerifyWebhookParams, type WebhookEvent, type WebhookEventEndpoint, type WebhookEventList, type WebhookEventStatus, webhooks };
1956
+ export { type CancelAtPeriodEndScheduledChargeParams, type CancelChargeResult, type CancelInstallmentPlanParams, type CancelRecurrenceScheduledChargeParams, type CardInput, type ChangePaymentMethodScheduledChargeParams, type Charge, type ChargeList, type ChargeNowOutcome, type ChargeNowReason, type ChargeNowResult, type ChargePaymentMethod, type ChargeStatus, type CreateChargeParams, type CreateCustomerParams, type CreateInstallmentPlanParams, type CreateProductParams, type CreateScheduledChargeParams, type Customer, type CustomerList, type CustomerRecord, type FailurePayload, Garu, GaruAPIError, GaruAuthenticationError, GaruConnectionError, GaruError, type GaruErrorCode, type GaruFailureCode, GaruNotFoundError, type GaruOptions, GaruPermissionError, GaruRateLimitError, GaruServerError, GaruSignatureVerificationError, GaruValidationError, type Installment, type InstallmentPlan, type InstallmentPlanList, type InstallmentPlanStatus, type InstallmentStatus, type ListChargesParams, type ListCustomersParams, type ListInstallmentPlansParams, type ListProductsParams, type ListRefundRequestsParams, type ListScheduledChargeAttemptsParams, type ListScheduledChargesParams, type ListWebhookEventsParams, type MarkPaidScheduledChargeParams, type MetaFeatures, type MetaResponse, type PaginatedList, type PauseScheduledChargeParams, type PaymentMethodExpiredPayload, type PaymentMethodExpiringPayload, type PostponeInstallmentParams, type PostponeScheduledChargeParams, type Product, type ProductList, type ProductPortalConfig, type RecurrenceConfig, type RecurrenceInterval, type RefundChargeParams, type RefundRequest, type RefundRequestList, type RefundRequestStatus, type ReissueInstallmentResult, type RequestPlanRefundParams, type ResendWebhookEventParams, type ResolveRefundRequestParams, type ScheduledChargeActor, type ScheduledChargeAttempt, type ScheduledChargeAttemptList, type ScheduledChargeAttemptSource, type ScheduledChargeAttemptStatus, type ScheduledChargeDetail, type ScheduledChargeEvent, type ScheduledChargeEventType, type ScheduledChargeLinkedTransaction, type ScheduledChargeList, type ScheduledChargeRecord, type ScheduledChargeStatus, type ScheduledChargeType, type ScheduledPaymentMethod, type SetBillingEmailOverrideParams, type SetProductPortalConfigParams, type UpdateCustomerParams, type UpdateProductParams, type VerifiedWebhook, type VerifyWebhookParams, type WebhookEvent, type WebhookEventEndpoint, type WebhookEventList, type WebhookEventStatus, webhooks };
package/dist/index.js CHANGED
@@ -627,10 +627,11 @@ var Customers = class {
627
627
  * phone: '11987654321',
628
628
  * personType: 'fisica'
629
629
  * });
630
+ * customer.uuid;
630
631
  */
631
632
  async create(params) {
632
633
  return this.http.call(
633
- (signal) => this.http.client.POST("/api/customers", {
634
+ (signal) => this.http.client.POST("/api/v1/customers", {
634
635
  body: params,
635
636
  signal
636
637
  }).then((r) => r)
@@ -640,7 +641,11 @@ var Customers = class {
640
641
  * List customers for the authenticated seller, with pagination and search.
641
642
  *
642
643
  * @example
643
- * const { data, meta } = await garu.customers.list({ search: 'maria', limit: 10 });
644
+ * const { data, totalCount } = await garu.customers.list({ search: 'maria', limit: 10 });
645
+ *
646
+ * @example
647
+ * // Customers with at least one overdue scheduled charge (carnê included).
648
+ * const atRisk = await garu.customers.list({ status: 'overdue' });
644
649
  */
645
650
  async list(params = {}) {
646
651
  const query = {};
@@ -649,7 +654,7 @@ var Customers = class {
649
654
  if (params.search) query.search = params.search;
650
655
  if (params.status) query.status = params.status;
651
656
  const qs = new URLSearchParams(query).toString();
652
- const url = `/api/customers${qs ? `?${qs}` : ""}`;
657
+ const url = `/api/v1/customers${qs ? `?${qs}` : ""}`;
653
658
  return this.http.call(
654
659
  (signal) => this.http.client.GET(url, { signal }).then(
655
660
  (r) => r
@@ -657,27 +662,28 @@ var Customers = class {
657
662
  );
658
663
  }
659
664
  /**
660
- * Fetch a single customer by numeric ID.
665
+ * Fetch a single customer by uuid.
661
666
  *
662
667
  * @example
663
- * const customer = await garu.customers.get(42);
668
+ * const customer = await garu.customers.get('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
664
669
  */
665
- async get(id) {
670
+ async get(uuid) {
666
671
  return this.http.call(
667
- (signal) => this.http.client.GET(`/api/customers/${id}`, { signal }).then(
672
+ (signal) => this.http.client.GET(`/api/v1/customers/${uuid}`, { signal }).then(
668
673
  (r) => r
669
674
  )
670
675
  );
671
676
  }
672
677
  /**
673
- * Update a customer's profile for the current seller.
678
+ * Update a customer's profile for the current seller. Partial — only the
679
+ * fields you pass change.
674
680
  *
675
681
  * @example
676
- * const updated = await garu.customers.update(42, { name: 'Maria Santos' });
682
+ * const updated = await garu.customers.update('a1b2c3d4-...', { name: 'Maria Santos' });
677
683
  */
678
- async update(id, params) {
684
+ async update(uuid, params) {
679
685
  return this.http.call(
680
- (signal) => this.http.client.PUT(`/api/customers/${id}`, {
686
+ (signal) => this.http.client.PATCH(`/api/v1/customers/${uuid}`, {
681
687
  body: params,
682
688
  signal
683
689
  }).then((r) => r)
@@ -692,30 +698,31 @@ var Customers = class {
692
698
  *
693
699
  * @example
694
700
  * // Set
695
- * await garu.customers.setBillingEmailOverride(42, {
701
+ * await garu.customers.setBillingEmailOverride('a1b2c3d4-...', {
696
702
  * billingEmailOverride: 'cobrancas@empresa.com.br'
697
703
  * });
698
704
  *
699
705
  * // Clear and fall back to the last-used email
700
- * await garu.customers.setBillingEmailOverride(42, { billingEmailOverride: null });
706
+ * await garu.customers.setBillingEmailOverride('a1b2c3d4-...', { billingEmailOverride: null });
701
707
  */
702
- async setBillingEmailOverride(id, params) {
708
+ async setBillingEmailOverride(uuid, params) {
703
709
  return this.http.call(
704
- (signal) => this.http.client.PATCH(`/api/customers/${id}/billing-email-override`, {
710
+ (signal) => this.http.client.PATCH(`/api/v1/customers/${uuid}/billing-email-override`, {
705
711
  body: params,
706
712
  signal
707
713
  }).then((r) => r)
708
714
  );
709
715
  }
710
716
  /**
711
- * Remove a customer from the current seller.
717
+ * Remove a customer from the current seller (unlinks your profile — the
718
+ * global customer and other sellers' profiles are untouched).
712
719
  *
713
720
  * @example
714
- * await garu.customers.delete(42);
721
+ * await garu.customers.delete('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
715
722
  */
716
- async delete(id) {
717
- await this.http.call(
718
- (signal) => this.http.client.DELETE(`/api/customers/${id}`, {
723
+ async delete(uuid) {
724
+ return this.http.call(
725
+ (signal) => this.http.client.DELETE(`/api/v1/customers/${uuid}`, {
719
726
  body: {},
720
727
  signal
721
728
  }).then((r) => r)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@garuhq/node",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "Official Node.js / TypeScript SDK for the Garu payment gateway.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://garu.com.br",