@garuhq/node 0.8.0 → 0.10.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/README.md +7 -3
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +14 -10
- package/dist/index.d.ts +14 -10
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -167,7 +167,9 @@ const { data, meta } = await garu.customers.list({ search: 'maria', limit: 10 })
|
|
|
167
167
|
|
|
168
168
|
## Products
|
|
169
169
|
|
|
170
|
-
Discover products and customize the per-product portal experience (B2B2C
|
|
170
|
+
Discover products and customize the per-product portal experience (B2B2C).
|
|
171
|
+
|
|
172
|
+
`portalConfig.*` methods accept `productId` as either the product UUID (preferred — same identifier returned by `list()` and webhook payloads) or the legacy numeric id (Garu v0.10.0+).
|
|
171
173
|
|
|
172
174
|
| Method | Description |
|
|
173
175
|
| ----------------------------------- | ----------------------------------------------------------------- |
|
|
@@ -180,14 +182,16 @@ Discover products and customize the per-product portal experience (B2B2C, v0.8.0
|
|
|
180
182
|
|
|
181
183
|
```ts
|
|
182
184
|
// SaaS de coaching: per-coach branding under one Seller account
|
|
183
|
-
await garu.products.portalConfig.set(
|
|
185
|
+
await garu.products.portalConfig.set('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f', {
|
|
184
186
|
businessName: 'Coach Maria — Corrida & Trilha',
|
|
185
187
|
primaryColor: '#257264',
|
|
186
188
|
logoUrl: 'https://cdn.exemplo.com/coaches/maria.png',
|
|
187
189
|
});
|
|
188
190
|
|
|
189
191
|
// Pass `null` on a field to inherit from the seller-level config
|
|
190
|
-
await garu.products.portalConfig.patch(
|
|
192
|
+
await garu.products.portalConfig.patch('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f', {
|
|
193
|
+
primaryColor: null,
|
|
194
|
+
});
|
|
191
195
|
```
|
|
192
196
|
|
|
193
197
|
## Scheduled charges
|
package/dist/index.cjs
CHANGED
|
@@ -475,11 +475,11 @@ var ProductPortalConfigResource = class {
|
|
|
475
475
|
* portal config).
|
|
476
476
|
*
|
|
477
477
|
* @example
|
|
478
|
-
* const cfg = await garu.products.portalConfig.get(
|
|
478
|
+
* const cfg = await garu.products.portalConfig.get('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f');
|
|
479
479
|
*/
|
|
480
480
|
async get(productId) {
|
|
481
481
|
return this.http.call(
|
|
482
|
-
(signal) => this.http.client.GET(`/api/products/${productId}/portal-config`, {
|
|
482
|
+
(signal) => this.http.client.GET(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
|
|
483
483
|
signal
|
|
484
484
|
}).then((r) => r)
|
|
485
485
|
);
|
|
@@ -491,7 +491,7 @@ var ProductPortalConfigResource = class {
|
|
|
491
491
|
* value. Use `clear` to reset everything.
|
|
492
492
|
*
|
|
493
493
|
* @example
|
|
494
|
-
* await garu.products.portalConfig.set(
|
|
494
|
+
* await garu.products.portalConfig.set('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f', {
|
|
495
495
|
* businessName: 'Coach Maria — Corrida & Trilha',
|
|
496
496
|
* primaryColor: '#257264',
|
|
497
497
|
* logoUrl: 'https://cdn.atletia.com.br/coaches/maria.png'
|
|
@@ -499,7 +499,7 @@ var ProductPortalConfigResource = class {
|
|
|
499
499
|
*/
|
|
500
500
|
async set(productId, params) {
|
|
501
501
|
return this.http.call(
|
|
502
|
-
(signal) => this.http.client.POST(`/api/products/${productId}/portal-config`, {
|
|
502
|
+
(signal) => this.http.client.POST(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
|
|
503
503
|
body: params,
|
|
504
504
|
signal
|
|
505
505
|
}).then((r) => r)
|
|
@@ -508,7 +508,7 @@ var ProductPortalConfigResource = class {
|
|
|
508
508
|
/** Same merge semantics as `set` — alias for HTTP-PATCH-prefering callers. */
|
|
509
509
|
async patch(productId, params) {
|
|
510
510
|
return this.http.call(
|
|
511
|
-
(signal) => this.http.client.PATCH(`/api/products/${productId}/portal-config`, {
|
|
511
|
+
(signal) => this.http.client.PATCH(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
|
|
512
512
|
body: params,
|
|
513
513
|
signal
|
|
514
514
|
}).then((r) => r)
|
|
@@ -520,11 +520,11 @@ var ProductPortalConfigResource = class {
|
|
|
520
520
|
* deleted, `{ removed: false }` when there was nothing to remove.
|
|
521
521
|
*
|
|
522
522
|
* @example
|
|
523
|
-
* await garu.products.portalConfig.clear(
|
|
523
|
+
* await garu.products.portalConfig.clear('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f');
|
|
524
524
|
*/
|
|
525
525
|
async clear(productId) {
|
|
526
526
|
return this.http.call(
|
|
527
|
-
(signal) => this.http.client.DELETE(`/api/products/${productId}/portal-config`, {
|
|
527
|
+
(signal) => this.http.client.DELETE(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
|
|
528
528
|
signal
|
|
529
529
|
}).then((r) => r)
|
|
530
530
|
);
|
package/dist/index.d.cts
CHANGED
|
@@ -776,9 +776,13 @@ declare class Meta {
|
|
|
776
776
|
}
|
|
777
777
|
|
|
778
778
|
/**
|
|
779
|
-
* Per-product portal customization
|
|
780
|
-
*
|
|
781
|
-
*
|
|
779
|
+
* Per-product portal customization. Used by B2B2C platforms that model
|
|
780
|
+
* their professionals/coaches as Products under a single seller and want
|
|
781
|
+
* per-product branding on the customer payment + portal pages.
|
|
782
|
+
*
|
|
783
|
+
* `productId` accepts either the product UUID (preferred — same identifier
|
|
784
|
+
* returned by `garu.products.list()` and webhook payloads) or the legacy
|
|
785
|
+
* numeric id. UUID support added in Garu v0.10.0.
|
|
782
786
|
*/
|
|
783
787
|
declare class ProductPortalConfigResource {
|
|
784
788
|
private readonly http;
|
|
@@ -789,9 +793,9 @@ declare class ProductPortalConfigResource {
|
|
|
789
793
|
* portal config).
|
|
790
794
|
*
|
|
791
795
|
* @example
|
|
792
|
-
* const cfg = await garu.products.portalConfig.get(
|
|
796
|
+
* const cfg = await garu.products.portalConfig.get('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f');
|
|
793
797
|
*/
|
|
794
|
-
get(productId: number): Promise<ProductPortalConfig | null>;
|
|
798
|
+
get(productId: string | number): Promise<ProductPortalConfig | null>;
|
|
795
799
|
/**
|
|
796
800
|
* Create or merge the portal customization (idempotent upsert). Both
|
|
797
801
|
* `set` and `patch` have the same merge semantics — only fields present
|
|
@@ -799,24 +803,24 @@ declare class ProductPortalConfigResource {
|
|
|
799
803
|
* value. Use `clear` to reset everything.
|
|
800
804
|
*
|
|
801
805
|
* @example
|
|
802
|
-
* await garu.products.portalConfig.set(
|
|
806
|
+
* await garu.products.portalConfig.set('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f', {
|
|
803
807
|
* businessName: 'Coach Maria — Corrida & Trilha',
|
|
804
808
|
* primaryColor: '#257264',
|
|
805
809
|
* logoUrl: 'https://cdn.atletia.com.br/coaches/maria.png'
|
|
806
810
|
* });
|
|
807
811
|
*/
|
|
808
|
-
set(productId: number, params: SetProductPortalConfigParams): Promise<ProductPortalConfig>;
|
|
812
|
+
set(productId: string | number, params: SetProductPortalConfigParams): Promise<ProductPortalConfig>;
|
|
809
813
|
/** Same merge semantics as `set` — alias for HTTP-PATCH-prefering callers. */
|
|
810
|
-
patch(productId: number, params: SetProductPortalConfigParams): Promise<ProductPortalConfig>;
|
|
814
|
+
patch(productId: string | number, params: SetProductPortalConfigParams): Promise<ProductPortalConfig>;
|
|
811
815
|
/**
|
|
812
816
|
* Remove the per-product config. The product falls back to the
|
|
813
817
|
* seller-level portal config. Returns `{ removed: true }` when a row was
|
|
814
818
|
* deleted, `{ removed: false }` when there was nothing to remove.
|
|
815
819
|
*
|
|
816
820
|
* @example
|
|
817
|
-
* await garu.products.portalConfig.clear(
|
|
821
|
+
* await garu.products.portalConfig.clear('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f');
|
|
818
822
|
*/
|
|
819
|
-
clear(productId: number): Promise<{
|
|
823
|
+
clear(productId: string | number): Promise<{
|
|
820
824
|
removed: boolean;
|
|
821
825
|
}>;
|
|
822
826
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -776,9 +776,13 @@ declare class Meta {
|
|
|
776
776
|
}
|
|
777
777
|
|
|
778
778
|
/**
|
|
779
|
-
* Per-product portal customization
|
|
780
|
-
*
|
|
781
|
-
*
|
|
779
|
+
* Per-product portal customization. Used by B2B2C platforms that model
|
|
780
|
+
* their professionals/coaches as Products under a single seller and want
|
|
781
|
+
* per-product branding on the customer payment + portal pages.
|
|
782
|
+
*
|
|
783
|
+
* `productId` accepts either the product UUID (preferred — same identifier
|
|
784
|
+
* returned by `garu.products.list()` and webhook payloads) or the legacy
|
|
785
|
+
* numeric id. UUID support added in Garu v0.10.0.
|
|
782
786
|
*/
|
|
783
787
|
declare class ProductPortalConfigResource {
|
|
784
788
|
private readonly http;
|
|
@@ -789,9 +793,9 @@ declare class ProductPortalConfigResource {
|
|
|
789
793
|
* portal config).
|
|
790
794
|
*
|
|
791
795
|
* @example
|
|
792
|
-
* const cfg = await garu.products.portalConfig.get(
|
|
796
|
+
* const cfg = await garu.products.portalConfig.get('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f');
|
|
793
797
|
*/
|
|
794
|
-
get(productId: number): Promise<ProductPortalConfig | null>;
|
|
798
|
+
get(productId: string | number): Promise<ProductPortalConfig | null>;
|
|
795
799
|
/**
|
|
796
800
|
* Create or merge the portal customization (idempotent upsert). Both
|
|
797
801
|
* `set` and `patch` have the same merge semantics — only fields present
|
|
@@ -799,24 +803,24 @@ declare class ProductPortalConfigResource {
|
|
|
799
803
|
* value. Use `clear` to reset everything.
|
|
800
804
|
*
|
|
801
805
|
* @example
|
|
802
|
-
* await garu.products.portalConfig.set(
|
|
806
|
+
* await garu.products.portalConfig.set('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f', {
|
|
803
807
|
* businessName: 'Coach Maria — Corrida & Trilha',
|
|
804
808
|
* primaryColor: '#257264',
|
|
805
809
|
* logoUrl: 'https://cdn.atletia.com.br/coaches/maria.png'
|
|
806
810
|
* });
|
|
807
811
|
*/
|
|
808
|
-
set(productId: number, params: SetProductPortalConfigParams): Promise<ProductPortalConfig>;
|
|
812
|
+
set(productId: string | number, params: SetProductPortalConfigParams): Promise<ProductPortalConfig>;
|
|
809
813
|
/** Same merge semantics as `set` — alias for HTTP-PATCH-prefering callers. */
|
|
810
|
-
patch(productId: number, params: SetProductPortalConfigParams): Promise<ProductPortalConfig>;
|
|
814
|
+
patch(productId: string | number, params: SetProductPortalConfigParams): Promise<ProductPortalConfig>;
|
|
811
815
|
/**
|
|
812
816
|
* Remove the per-product config. The product falls back to the
|
|
813
817
|
* seller-level portal config. Returns `{ removed: true }` when a row was
|
|
814
818
|
* deleted, `{ removed: false }` when there was nothing to remove.
|
|
815
819
|
*
|
|
816
820
|
* @example
|
|
817
|
-
* await garu.products.portalConfig.clear(
|
|
821
|
+
* await garu.products.portalConfig.clear('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f');
|
|
818
822
|
*/
|
|
819
|
-
clear(productId: number): Promise<{
|
|
823
|
+
clear(productId: string | number): Promise<{
|
|
820
824
|
removed: boolean;
|
|
821
825
|
}>;
|
|
822
826
|
}
|
package/dist/index.js
CHANGED
|
@@ -469,11 +469,11 @@ var ProductPortalConfigResource = class {
|
|
|
469
469
|
* portal config).
|
|
470
470
|
*
|
|
471
471
|
* @example
|
|
472
|
-
* const cfg = await garu.products.portalConfig.get(
|
|
472
|
+
* const cfg = await garu.products.portalConfig.get('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f');
|
|
473
473
|
*/
|
|
474
474
|
async get(productId) {
|
|
475
475
|
return this.http.call(
|
|
476
|
-
(signal) => this.http.client.GET(`/api/products/${productId}/portal-config`, {
|
|
476
|
+
(signal) => this.http.client.GET(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
|
|
477
477
|
signal
|
|
478
478
|
}).then((r) => r)
|
|
479
479
|
);
|
|
@@ -485,7 +485,7 @@ var ProductPortalConfigResource = class {
|
|
|
485
485
|
* value. Use `clear` to reset everything.
|
|
486
486
|
*
|
|
487
487
|
* @example
|
|
488
|
-
* await garu.products.portalConfig.set(
|
|
488
|
+
* await garu.products.portalConfig.set('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f', {
|
|
489
489
|
* businessName: 'Coach Maria — Corrida & Trilha',
|
|
490
490
|
* primaryColor: '#257264',
|
|
491
491
|
* logoUrl: 'https://cdn.atletia.com.br/coaches/maria.png'
|
|
@@ -493,7 +493,7 @@ var ProductPortalConfigResource = class {
|
|
|
493
493
|
*/
|
|
494
494
|
async set(productId, params) {
|
|
495
495
|
return this.http.call(
|
|
496
|
-
(signal) => this.http.client.POST(`/api/products/${productId}/portal-config`, {
|
|
496
|
+
(signal) => this.http.client.POST(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
|
|
497
497
|
body: params,
|
|
498
498
|
signal
|
|
499
499
|
}).then((r) => r)
|
|
@@ -502,7 +502,7 @@ var ProductPortalConfigResource = class {
|
|
|
502
502
|
/** Same merge semantics as `set` — alias for HTTP-PATCH-prefering callers. */
|
|
503
503
|
async patch(productId, params) {
|
|
504
504
|
return this.http.call(
|
|
505
|
-
(signal) => this.http.client.PATCH(`/api/products/${productId}/portal-config`, {
|
|
505
|
+
(signal) => this.http.client.PATCH(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
|
|
506
506
|
body: params,
|
|
507
507
|
signal
|
|
508
508
|
}).then((r) => r)
|
|
@@ -514,11 +514,11 @@ var ProductPortalConfigResource = class {
|
|
|
514
514
|
* deleted, `{ removed: false }` when there was nothing to remove.
|
|
515
515
|
*
|
|
516
516
|
* @example
|
|
517
|
-
* await garu.products.portalConfig.clear(
|
|
517
|
+
* await garu.products.portalConfig.clear('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f');
|
|
518
518
|
*/
|
|
519
519
|
async clear(productId) {
|
|
520
520
|
return this.http.call(
|
|
521
|
-
(signal) => this.http.client.DELETE(`/api/products/${productId}/portal-config`, {
|
|
521
|
+
(signal) => this.http.client.DELETE(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
|
|
522
522
|
signal
|
|
523
523
|
}).then((r) => r)
|
|
524
524
|
);
|