@garuhq/node 0.14.0 → 0.15.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,28 @@
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
+ ## [0.15.0] — 2026-05-31
7
+
8
+ ### Added
9
+
10
+ - **Product writes** — the `Products` resource now wraps the create and update
11
+ endpoints, not just reads:
12
+ - `products.create(params)` — `POST /api/products`, returns the created
13
+ `Product`. Only `name` is required; all other fields fall back to
14
+ seller/server defaults. Auto-attaches an `X-Idempotency-Key` (override
15
+ via `params.idempotencyKey`), so the built-in retry can't create a
16
+ duplicate product.
17
+ - `products.update(id, params)` — `PATCH /api/products/{id}`, partial update
18
+ returning the updated `Product`. `id` accepts the numeric id or the
19
+ product UUID, matching the `/api/products/:id` portal-config methods.
20
+ - New exported param types `CreateProductParams` and `UpdateProductParams`,
21
+ covering `name`, `value` (centavos), `description`, `image`, `tags`,
22
+ `pix`, `boleto`, `creditCard`, `pixAutomatic`, `installments`,
23
+ `isSubscription`, `subscriptionType`, `unitLabel`, `returnUrl`,
24
+ `returnUrlButtonText`, and `statementDescriptor`.
25
+ - Both param types include `pixAutomatic` so you can toggle Pix Automático
26
+ on the subscription checkout at create/update time.
27
+
6
28
  ## [0.14.0] — 2026-05-31
7
29
 
8
30
  ### Added
package/dist/index.cjs CHANGED
@@ -480,9 +480,12 @@ var ProductPortalConfigResource = class {
480
480
  */
481
481
  async get(productId) {
482
482
  return this.http.call(
483
- (signal) => this.http.client.GET(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
484
- signal
485
- }).then((r) => r)
483
+ (signal) => this.http.client.GET(
484
+ `/api/products/${encodeURIComponent(String(productId))}/portal-config`,
485
+ {
486
+ signal
487
+ }
488
+ ).then((r) => r)
486
489
  );
487
490
  }
488
491
  /**
@@ -500,19 +503,25 @@ var ProductPortalConfigResource = class {
500
503
  */
501
504
  async set(productId, params) {
502
505
  return this.http.call(
503
- (signal) => this.http.client.POST(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
504
- body: params,
505
- signal
506
- }).then((r) => r)
506
+ (signal) => this.http.client.POST(
507
+ `/api/products/${encodeURIComponent(String(productId))}/portal-config`,
508
+ {
509
+ body: params,
510
+ signal
511
+ }
512
+ ).then((r) => r)
507
513
  );
508
514
  }
509
515
  /** Same merge semantics as `set` — alias for HTTP-PATCH-prefering callers. */
510
516
  async patch(productId, params) {
511
517
  return this.http.call(
512
- (signal) => this.http.client.PATCH(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
513
- body: params,
514
- signal
515
- }).then((r) => r)
518
+ (signal) => this.http.client.PATCH(
519
+ `/api/products/${encodeURIComponent(String(productId))}/portal-config`,
520
+ {
521
+ body: params,
522
+ signal
523
+ }
524
+ ).then((r) => r)
516
525
  );
517
526
  }
518
527
  /**
@@ -525,10 +534,13 @@ var ProductPortalConfigResource = class {
525
534
  */
526
535
  async clear(productId) {
527
536
  return this.http.call(
528
- (signal) => this.http.client.DELETE(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
529
- body: {},
530
- signal
531
- }).then((r) => r)
537
+ (signal) => this.http.client.DELETE(
538
+ `/api/products/${encodeURIComponent(String(productId))}/portal-config`,
539
+ {
540
+ body: {},
541
+ signal
542
+ }
543
+ ).then((r) => r)
532
544
  );
533
545
  }
534
546
  };
@@ -574,6 +586,61 @@ var Products = class {
574
586
  )
575
587
  );
576
588
  }
589
+ /**
590
+ * Create a product for the authenticated seller. Returns the created
591
+ * product (HTTP 201). Only `name` is required; everything else falls back
592
+ * to seller/server defaults.
593
+ *
594
+ * Automatically attaches an `X-Idempotency-Key` header — if you don't pass
595
+ * `idempotencyKey`, the SDK generates a UUIDv4. This makes the built-in
596
+ * retry on transient failures safe: a retried POST returns the original
597
+ * product instead of creating a duplicate.
598
+ *
599
+ * @example
600
+ * const product = await garu.products.create({
601
+ * name: 'Plano Mensal',
602
+ * value: 4990, // R$ 49,90 in centavos
603
+ * description: 'Acesso completo à plataforma',
604
+ * pix: true,
605
+ * creditCard: true,
606
+ * isSubscription: true,
607
+ * subscriptionType: 'monthly',
608
+ * pixAutomatic: true // expose Pix Automático on the subscription checkout
609
+ * });
610
+ */
611
+ async create(params) {
612
+ const { idempotencyKey, ...body } = params;
613
+ const key = idempotencyKey ?? generateIdempotencyKey();
614
+ return this.http.call(
615
+ (signal) => this.http.client.POST("/api/products", {
616
+ body,
617
+ headers: { "X-Idempotency-Key": key },
618
+ signal
619
+ }).then((r) => r)
620
+ );
621
+ }
622
+ /**
623
+ * Update a product (partial PATCH — only the fields you pass are changed).
624
+ * Returns the updated product.
625
+ *
626
+ * `id` accepts the numeric id or the product UUID — the same identifiers
627
+ * accepted elsewhere on the `/api/products/:id` path (see
628
+ * {@link ProductPortalConfigResource}).
629
+ *
630
+ * @example
631
+ * const updated = await garu.products.update('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f', {
632
+ * value: 5990,
633
+ * pixAutomatic: true // turn on Pix Automático for this product
634
+ * });
635
+ */
636
+ async update(id, params) {
637
+ return this.http.call(
638
+ (signal) => this.http.client.PATCH(`/api/products/${encodeURIComponent(String(id))}`, {
639
+ body: params,
640
+ signal
641
+ }).then((r) => r)
642
+ );
643
+ }
577
644
  };
578
645
 
579
646
  // src/resources/scheduled-charges.ts
package/dist/index.d.cts CHANGED
@@ -550,6 +550,57 @@ interface ListProductsParams {
550
550
  /** Backend tab filter (e.g. `active`, `archived`). Backend default is used when omitted. */
551
551
  tab?: string;
552
552
  }
553
+ interface CreateProductParams {
554
+ name: string;
555
+ /** Price in centavos (BRL × 100). */
556
+ value?: number;
557
+ description?: string;
558
+ /** HTTPS URL of the product cover image. */
559
+ image?: string;
560
+ tags?: string[];
561
+ pix?: boolean;
562
+ boleto?: boolean;
563
+ creditCard?: boolean;
564
+ /**
565
+ * Enable Pix Automático (BACEN auto-debit recurring Pix) on the
566
+ * subscription checkout. Defaults to enabled server-side. Only the
567
+ * subscription checkout mode reads this flag. See {@link Product.pixAutomatic}.
568
+ */
569
+ pixAutomatic?: boolean;
570
+ /** Max number of installments offered on credit card. */
571
+ installments?: number;
572
+ isSubscription?: boolean;
573
+ subscriptionType?: string;
574
+ unitLabel?: string;
575
+ returnUrl?: string;
576
+ returnUrlButtonText?: string;
577
+ /** Text shown on the buyer's card/bank statement. */
578
+ statementDescriptor?: string;
579
+ /**
580
+ * Idempotency key for the create request. Defaults to a generated UUIDv4.
581
+ * Pass your own to make a retry across process restarts safe — the backend
582
+ * returns the original product instead of creating a duplicate.
583
+ */
584
+ idempotencyKey?: string;
585
+ }
586
+ interface UpdateProductParams {
587
+ name?: string;
588
+ value?: number;
589
+ description?: string;
590
+ image?: string;
591
+ tags?: string[];
592
+ pix?: boolean;
593
+ boleto?: boolean;
594
+ creditCard?: boolean;
595
+ pixAutomatic?: boolean;
596
+ installments?: number;
597
+ isSubscription?: boolean;
598
+ subscriptionType?: string;
599
+ unitLabel?: string;
600
+ returnUrl?: string;
601
+ returnUrlButtonText?: string;
602
+ statementDescriptor?: string;
603
+ }
553
604
  interface MetaFeatures {
554
605
  subscriptions: boolean;
555
606
  checkout_sessions: boolean;
@@ -983,6 +1034,44 @@ declare class Products {
983
1034
  * const product = await garu.products.get('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f');
984
1035
  */
985
1036
  get(uuid: string): Promise<Product>;
1037
+ /**
1038
+ * Create a product for the authenticated seller. Returns the created
1039
+ * product (HTTP 201). Only `name` is required; everything else falls back
1040
+ * to seller/server defaults.
1041
+ *
1042
+ * Automatically attaches an `X-Idempotency-Key` header — if you don't pass
1043
+ * `idempotencyKey`, the SDK generates a UUIDv4. This makes the built-in
1044
+ * retry on transient failures safe: a retried POST returns the original
1045
+ * product instead of creating a duplicate.
1046
+ *
1047
+ * @example
1048
+ * const product = await garu.products.create({
1049
+ * name: 'Plano Mensal',
1050
+ * value: 4990, // R$ 49,90 in centavos
1051
+ * description: 'Acesso completo à plataforma',
1052
+ * pix: true,
1053
+ * creditCard: true,
1054
+ * isSubscription: true,
1055
+ * subscriptionType: 'monthly',
1056
+ * pixAutomatic: true // expose Pix Automático on the subscription checkout
1057
+ * });
1058
+ */
1059
+ create(params: CreateProductParams): Promise<Product>;
1060
+ /**
1061
+ * Update a product (partial PATCH — only the fields you pass are changed).
1062
+ * Returns the updated product.
1063
+ *
1064
+ * `id` accepts the numeric id or the product UUID — the same identifiers
1065
+ * accepted elsewhere on the `/api/products/:id` path (see
1066
+ * {@link ProductPortalConfigResource}).
1067
+ *
1068
+ * @example
1069
+ * const updated = await garu.products.update('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f', {
1070
+ * value: 5990,
1071
+ * pixAutomatic: true // turn on Pix Automático for this product
1072
+ * });
1073
+ */
1074
+ update(id: string | number, params: UpdateProductParams): Promise<Product>;
986
1075
  }
987
1076
 
988
1077
  /**
@@ -1391,4 +1480,4 @@ declare class GaruServerError extends GaruAPIError {
1391
1480
  constructor(message: string, status: number, requestId: string | null, body: unknown);
1392
1481
  }
1393
1482
 
1394
- export { type CancelAtPeriodEndScheduledChargeParams, type CancelRecurrenceScheduledChargeParams, type CardInfo, type ChangePaymentMethodScheduledChargeParams, type Charge, type ChargeList, type ChargeNowOutcome, type ChargeNowReason, type ChargeNowResult, type ChargeStatus, type CreateChargeParams, type CreateCustomerParams, 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 ListChargesParams, type ListCustomersParams, type ListProductsParams, type ListScheduledChargeAttemptsParams, type ListScheduledChargesParams, type ListWebhookEventsParams, type MarkPaidScheduledChargeParams, type MetaFeatures, type MetaResponse, type PaginatedList, type PauseScheduledChargeParams, type PaymentMethod, type PaymentMethodExpiredPayload, type PaymentMethodExpiringPayload, type PostponeScheduledChargeParams, type Product, type ProductList, type ProductPortalConfig, type RecurrenceConfig, type RecurrenceInterval, type RefundChargeParams, type ResendWebhookEventParams, 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 VerifiedWebhook, type VerifyWebhookParams, type WebhookEvent, type WebhookEventEndpoint, type WebhookEventList, type WebhookEventStatus, type WirePaymentMethodId, webhooks };
1483
+ export { type CancelAtPeriodEndScheduledChargeParams, type CancelRecurrenceScheduledChargeParams, type CardInfo, type ChangePaymentMethodScheduledChargeParams, type Charge, type ChargeList, type ChargeNowOutcome, type ChargeNowReason, type ChargeNowResult, type ChargeStatus, type CreateChargeParams, type CreateCustomerParams, 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 ListChargesParams, type ListCustomersParams, type ListProductsParams, type ListScheduledChargeAttemptsParams, type ListScheduledChargesParams, type ListWebhookEventsParams, type MarkPaidScheduledChargeParams, type MetaFeatures, type MetaResponse, type PaginatedList, type PauseScheduledChargeParams, type PaymentMethod, type PaymentMethodExpiredPayload, type PaymentMethodExpiringPayload, type PostponeScheduledChargeParams, type Product, type ProductList, type ProductPortalConfig, type RecurrenceConfig, type RecurrenceInterval, type RefundChargeParams, type ResendWebhookEventParams, 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, type WirePaymentMethodId, webhooks };
package/dist/index.d.ts CHANGED
@@ -550,6 +550,57 @@ interface ListProductsParams {
550
550
  /** Backend tab filter (e.g. `active`, `archived`). Backend default is used when omitted. */
551
551
  tab?: string;
552
552
  }
553
+ interface CreateProductParams {
554
+ name: string;
555
+ /** Price in centavos (BRL × 100). */
556
+ value?: number;
557
+ description?: string;
558
+ /** HTTPS URL of the product cover image. */
559
+ image?: string;
560
+ tags?: string[];
561
+ pix?: boolean;
562
+ boleto?: boolean;
563
+ creditCard?: boolean;
564
+ /**
565
+ * Enable Pix Automático (BACEN auto-debit recurring Pix) on the
566
+ * subscription checkout. Defaults to enabled server-side. Only the
567
+ * subscription checkout mode reads this flag. See {@link Product.pixAutomatic}.
568
+ */
569
+ pixAutomatic?: boolean;
570
+ /** Max number of installments offered on credit card. */
571
+ installments?: number;
572
+ isSubscription?: boolean;
573
+ subscriptionType?: string;
574
+ unitLabel?: string;
575
+ returnUrl?: string;
576
+ returnUrlButtonText?: string;
577
+ /** Text shown on the buyer's card/bank statement. */
578
+ statementDescriptor?: string;
579
+ /**
580
+ * Idempotency key for the create request. Defaults to a generated UUIDv4.
581
+ * Pass your own to make a retry across process restarts safe — the backend
582
+ * returns the original product instead of creating a duplicate.
583
+ */
584
+ idempotencyKey?: string;
585
+ }
586
+ interface UpdateProductParams {
587
+ name?: string;
588
+ value?: number;
589
+ description?: string;
590
+ image?: string;
591
+ tags?: string[];
592
+ pix?: boolean;
593
+ boleto?: boolean;
594
+ creditCard?: boolean;
595
+ pixAutomatic?: boolean;
596
+ installments?: number;
597
+ isSubscription?: boolean;
598
+ subscriptionType?: string;
599
+ unitLabel?: string;
600
+ returnUrl?: string;
601
+ returnUrlButtonText?: string;
602
+ statementDescriptor?: string;
603
+ }
553
604
  interface MetaFeatures {
554
605
  subscriptions: boolean;
555
606
  checkout_sessions: boolean;
@@ -983,6 +1034,44 @@ declare class Products {
983
1034
  * const product = await garu.products.get('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f');
984
1035
  */
985
1036
  get(uuid: string): Promise<Product>;
1037
+ /**
1038
+ * Create a product for the authenticated seller. Returns the created
1039
+ * product (HTTP 201). Only `name` is required; everything else falls back
1040
+ * to seller/server defaults.
1041
+ *
1042
+ * Automatically attaches an `X-Idempotency-Key` header — if you don't pass
1043
+ * `idempotencyKey`, the SDK generates a UUIDv4. This makes the built-in
1044
+ * retry on transient failures safe: a retried POST returns the original
1045
+ * product instead of creating a duplicate.
1046
+ *
1047
+ * @example
1048
+ * const product = await garu.products.create({
1049
+ * name: 'Plano Mensal',
1050
+ * value: 4990, // R$ 49,90 in centavos
1051
+ * description: 'Acesso completo à plataforma',
1052
+ * pix: true,
1053
+ * creditCard: true,
1054
+ * isSubscription: true,
1055
+ * subscriptionType: 'monthly',
1056
+ * pixAutomatic: true // expose Pix Automático on the subscription checkout
1057
+ * });
1058
+ */
1059
+ create(params: CreateProductParams): Promise<Product>;
1060
+ /**
1061
+ * Update a product (partial PATCH — only the fields you pass are changed).
1062
+ * Returns the updated product.
1063
+ *
1064
+ * `id` accepts the numeric id or the product UUID — the same identifiers
1065
+ * accepted elsewhere on the `/api/products/:id` path (see
1066
+ * {@link ProductPortalConfigResource}).
1067
+ *
1068
+ * @example
1069
+ * const updated = await garu.products.update('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f', {
1070
+ * value: 5990,
1071
+ * pixAutomatic: true // turn on Pix Automático for this product
1072
+ * });
1073
+ */
1074
+ update(id: string | number, params: UpdateProductParams): Promise<Product>;
986
1075
  }
987
1076
 
988
1077
  /**
@@ -1391,4 +1480,4 @@ declare class GaruServerError extends GaruAPIError {
1391
1480
  constructor(message: string, status: number, requestId: string | null, body: unknown);
1392
1481
  }
1393
1482
 
1394
- export { type CancelAtPeriodEndScheduledChargeParams, type CancelRecurrenceScheduledChargeParams, type CardInfo, type ChangePaymentMethodScheduledChargeParams, type Charge, type ChargeList, type ChargeNowOutcome, type ChargeNowReason, type ChargeNowResult, type ChargeStatus, type CreateChargeParams, type CreateCustomerParams, 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 ListChargesParams, type ListCustomersParams, type ListProductsParams, type ListScheduledChargeAttemptsParams, type ListScheduledChargesParams, type ListWebhookEventsParams, type MarkPaidScheduledChargeParams, type MetaFeatures, type MetaResponse, type PaginatedList, type PauseScheduledChargeParams, type PaymentMethod, type PaymentMethodExpiredPayload, type PaymentMethodExpiringPayload, type PostponeScheduledChargeParams, type Product, type ProductList, type ProductPortalConfig, type RecurrenceConfig, type RecurrenceInterval, type RefundChargeParams, type ResendWebhookEventParams, 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 VerifiedWebhook, type VerifyWebhookParams, type WebhookEvent, type WebhookEventEndpoint, type WebhookEventList, type WebhookEventStatus, type WirePaymentMethodId, webhooks };
1483
+ export { type CancelAtPeriodEndScheduledChargeParams, type CancelRecurrenceScheduledChargeParams, type CardInfo, type ChangePaymentMethodScheduledChargeParams, type Charge, type ChargeList, type ChargeNowOutcome, type ChargeNowReason, type ChargeNowResult, type ChargeStatus, type CreateChargeParams, type CreateCustomerParams, 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 ListChargesParams, type ListCustomersParams, type ListProductsParams, type ListScheduledChargeAttemptsParams, type ListScheduledChargesParams, type ListWebhookEventsParams, type MarkPaidScheduledChargeParams, type MetaFeatures, type MetaResponse, type PaginatedList, type PauseScheduledChargeParams, type PaymentMethod, type PaymentMethodExpiredPayload, type PaymentMethodExpiringPayload, type PostponeScheduledChargeParams, type Product, type ProductList, type ProductPortalConfig, type RecurrenceConfig, type RecurrenceInterval, type RefundChargeParams, type ResendWebhookEventParams, 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, type WirePaymentMethodId, webhooks };
package/dist/index.js CHANGED
@@ -474,9 +474,12 @@ var ProductPortalConfigResource = class {
474
474
  */
475
475
  async get(productId) {
476
476
  return this.http.call(
477
- (signal) => this.http.client.GET(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
478
- signal
479
- }).then((r) => r)
477
+ (signal) => this.http.client.GET(
478
+ `/api/products/${encodeURIComponent(String(productId))}/portal-config`,
479
+ {
480
+ signal
481
+ }
482
+ ).then((r) => r)
480
483
  );
481
484
  }
482
485
  /**
@@ -494,19 +497,25 @@ var ProductPortalConfigResource = class {
494
497
  */
495
498
  async set(productId, params) {
496
499
  return this.http.call(
497
- (signal) => this.http.client.POST(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
498
- body: params,
499
- signal
500
- }).then((r) => r)
500
+ (signal) => this.http.client.POST(
501
+ `/api/products/${encodeURIComponent(String(productId))}/portal-config`,
502
+ {
503
+ body: params,
504
+ signal
505
+ }
506
+ ).then((r) => r)
501
507
  );
502
508
  }
503
509
  /** Same merge semantics as `set` — alias for HTTP-PATCH-prefering callers. */
504
510
  async patch(productId, params) {
505
511
  return this.http.call(
506
- (signal) => this.http.client.PATCH(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
507
- body: params,
508
- signal
509
- }).then((r) => r)
512
+ (signal) => this.http.client.PATCH(
513
+ `/api/products/${encodeURIComponent(String(productId))}/portal-config`,
514
+ {
515
+ body: params,
516
+ signal
517
+ }
518
+ ).then((r) => r)
510
519
  );
511
520
  }
512
521
  /**
@@ -519,10 +528,13 @@ var ProductPortalConfigResource = class {
519
528
  */
520
529
  async clear(productId) {
521
530
  return this.http.call(
522
- (signal) => this.http.client.DELETE(`/api/products/${encodeURIComponent(String(productId))}/portal-config`, {
523
- body: {},
524
- signal
525
- }).then((r) => r)
531
+ (signal) => this.http.client.DELETE(
532
+ `/api/products/${encodeURIComponent(String(productId))}/portal-config`,
533
+ {
534
+ body: {},
535
+ signal
536
+ }
537
+ ).then((r) => r)
526
538
  );
527
539
  }
528
540
  };
@@ -568,6 +580,61 @@ var Products = class {
568
580
  )
569
581
  );
570
582
  }
583
+ /**
584
+ * Create a product for the authenticated seller. Returns the created
585
+ * product (HTTP 201). Only `name` is required; everything else falls back
586
+ * to seller/server defaults.
587
+ *
588
+ * Automatically attaches an `X-Idempotency-Key` header — if you don't pass
589
+ * `idempotencyKey`, the SDK generates a UUIDv4. This makes the built-in
590
+ * retry on transient failures safe: a retried POST returns the original
591
+ * product instead of creating a duplicate.
592
+ *
593
+ * @example
594
+ * const product = await garu.products.create({
595
+ * name: 'Plano Mensal',
596
+ * value: 4990, // R$ 49,90 in centavos
597
+ * description: 'Acesso completo à plataforma',
598
+ * pix: true,
599
+ * creditCard: true,
600
+ * isSubscription: true,
601
+ * subscriptionType: 'monthly',
602
+ * pixAutomatic: true // expose Pix Automático on the subscription checkout
603
+ * });
604
+ */
605
+ async create(params) {
606
+ const { idempotencyKey, ...body } = params;
607
+ const key = idempotencyKey ?? generateIdempotencyKey();
608
+ return this.http.call(
609
+ (signal) => this.http.client.POST("/api/products", {
610
+ body,
611
+ headers: { "X-Idempotency-Key": key },
612
+ signal
613
+ }).then((r) => r)
614
+ );
615
+ }
616
+ /**
617
+ * Update a product (partial PATCH — only the fields you pass are changed).
618
+ * Returns the updated product.
619
+ *
620
+ * `id` accepts the numeric id or the product UUID — the same identifiers
621
+ * accepted elsewhere on the `/api/products/:id` path (see
622
+ * {@link ProductPortalConfigResource}).
623
+ *
624
+ * @example
625
+ * const updated = await garu.products.update('b3f2c1e8-6e4a-4b9f-9d1c-2a1f6c3d4e5f', {
626
+ * value: 5990,
627
+ * pixAutomatic: true // turn on Pix Automático for this product
628
+ * });
629
+ */
630
+ async update(id, params) {
631
+ return this.http.call(
632
+ (signal) => this.http.client.PATCH(`/api/products/${encodeURIComponent(String(id))}`, {
633
+ body: params,
634
+ signal
635
+ }).then((r) => r)
636
+ );
637
+ }
571
638
  };
572
639
 
573
640
  // src/resources/scheduled-charges.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@garuhq/node",
3
- "version": "0.14.0",
3
+ "version": "0.15.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",