@garuhq/node 1.0.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 +74 -0
- package/README.md +22 -15
- package/dist/index.cjs +326 -20
- package/dist/index.d.cts +415 -29
- package/dist/index.d.ts +415 -29
- package/dist/index.js +326 -20
- package/package.json +1 -1
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
|
-
|
|
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
|
|
291
|
+
billingEmail: string;
|
|
285
292
|
/** True when a sticky `billingEmailOverride` is set for this seller. */
|
|
286
|
-
hasBillingEmailOverride
|
|
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
|
-
|
|
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;
|
|
@@ -600,13 +613,6 @@ interface Product {
|
|
|
600
613
|
updatedAt: string;
|
|
601
614
|
[key: string]: unknown;
|
|
602
615
|
}
|
|
603
|
-
/** One entry in a product's credit-card installment breakdown. */
|
|
604
|
-
interface Installment {
|
|
605
|
-
/** Number of parcelas. */
|
|
606
|
-
quantity: number;
|
|
607
|
-
/** Amount charged per installment, in reais (BRL), with the fator markup applied. */
|
|
608
|
-
value: number;
|
|
609
|
-
}
|
|
610
616
|
/**
|
|
611
617
|
* List envelope returned by `products.list()`. Flat (not `{ data, meta }`) —
|
|
612
618
|
* matches the `/api/v1/products` response.
|
|
@@ -865,6 +871,167 @@ interface SetProductPortalConfigParams {
|
|
|
865
871
|
customCancellationMessage?: string | null;
|
|
866
872
|
customWelcomeText?: string | null;
|
|
867
873
|
}
|
|
874
|
+
type InstallmentPlanStatus = 'pending_activation' | 'active' | 'completed' | 'defaulted' | 'canceled' | 'refunded';
|
|
875
|
+
type InstallmentStatus = 'scheduled' | 'due_today' | 'processing' | 'paid' | 'overdue' | 'failed' | 'canceled';
|
|
876
|
+
/** One entry in a product's credit-card installment breakdown. */
|
|
877
|
+
interface Installment {
|
|
878
|
+
/** Number of parcelas. */
|
|
879
|
+
quantity: number;
|
|
880
|
+
/** Amount charged per installment, in reais (BRL), with the fator markup applied. */
|
|
881
|
+
value: number;
|
|
882
|
+
}
|
|
883
|
+
/** One monthly slip of a carnê. */
|
|
884
|
+
interface Installment {
|
|
885
|
+
/** 1-based position in the plan. */
|
|
886
|
+
number: number;
|
|
887
|
+
amount: number;
|
|
888
|
+
/** YYYY-MM-DD in São Paulo time. */
|
|
889
|
+
dueDate: string;
|
|
890
|
+
status: InstallmentStatus;
|
|
891
|
+
paidAt: string | null;
|
|
892
|
+
/**
|
|
893
|
+
* Null until the slip is registered. Parcelas 2..N are emitted month by
|
|
894
|
+
* month, so most of a fresh plan has no barcode yet.
|
|
895
|
+
*/
|
|
896
|
+
boleto: {
|
|
897
|
+
barcodeLine: string;
|
|
898
|
+
pdfUrl: string;
|
|
899
|
+
} | null;
|
|
900
|
+
reissueCount: number;
|
|
901
|
+
}
|
|
902
|
+
interface InstallmentPlan {
|
|
903
|
+
uuid: string;
|
|
904
|
+
status: InstallmentPlanStatus;
|
|
905
|
+
installments: number;
|
|
906
|
+
installmentsPaid: number;
|
|
907
|
+
/** The cash price the buyer would have paid in one go. */
|
|
908
|
+
baseValue: number;
|
|
909
|
+
/** Interest multiplier snapshotted at sale time; never recomputed. */
|
|
910
|
+
fator: number;
|
|
911
|
+
installmentAmount: number;
|
|
912
|
+
/** `installmentAmount × installments` — what the carnê bills in total. */
|
|
913
|
+
totalScheduled: number;
|
|
914
|
+
/**
|
|
915
|
+
* What has actually cleared. May exceed `totalScheduled` once a bank adds
|
|
916
|
+
* multa or mora, which is why the two are separate fields.
|
|
917
|
+
*/
|
|
918
|
+
totalCollected: number;
|
|
919
|
+
firstDueDate: string;
|
|
920
|
+
graceDays: number | null;
|
|
921
|
+
cancelReason: string | null;
|
|
922
|
+
product: {
|
|
923
|
+
uuid: string;
|
|
924
|
+
name: string;
|
|
925
|
+
} | null;
|
|
926
|
+
customer: {
|
|
927
|
+
name: string;
|
|
928
|
+
email: string;
|
|
929
|
+
document: string;
|
|
930
|
+
} | null;
|
|
931
|
+
activatedAt: string | null;
|
|
932
|
+
completedAt: string | null;
|
|
933
|
+
canceledAt: string | null;
|
|
934
|
+
createdAt: string;
|
|
935
|
+
/** Present on retrieve and create; omitted from list responses. */
|
|
936
|
+
installmentsDetail?: Installment[];
|
|
937
|
+
}
|
|
938
|
+
interface InstallmentPlanList {
|
|
939
|
+
data: InstallmentPlan[];
|
|
940
|
+
count: number;
|
|
941
|
+
totalCount: number;
|
|
942
|
+
totalPages: number;
|
|
943
|
+
}
|
|
944
|
+
interface CreateInstallmentPlanParams {
|
|
945
|
+
/** Public uuid of a product with carnê enabled. */
|
|
946
|
+
productId: string;
|
|
947
|
+
/** Numeric customer id, as returned by `garu.customers.create`. */
|
|
948
|
+
customerId: number;
|
|
949
|
+
/** 2..12. One parcela is not a carnê. */
|
|
950
|
+
installments: number;
|
|
951
|
+
/** YYYY-MM-DD. Defaults to today; must be within 90 days. */
|
|
952
|
+
firstDueDate?: string;
|
|
953
|
+
/**
|
|
954
|
+
* The affiliate who made this sale. Fixed at sale time: every later parcela
|
|
955
|
+
* inherits it, so omitting it pays that affiliate nothing for the whole
|
|
956
|
+
* carnê.
|
|
957
|
+
*/
|
|
958
|
+
affiliateId?: number;
|
|
959
|
+
/** Auto-generated when omitted. */
|
|
960
|
+
idempotencyKey?: string;
|
|
961
|
+
}
|
|
962
|
+
interface ListInstallmentPlansParams {
|
|
963
|
+
page?: number;
|
|
964
|
+
limit?: number;
|
|
965
|
+
status?: InstallmentPlanStatus | InstallmentPlanStatus[];
|
|
966
|
+
customerId?: number;
|
|
967
|
+
productId?: string;
|
|
968
|
+
/** Filters on the FIRST parcela's due date, which identifies the plan. */
|
|
969
|
+
dueFrom?: string;
|
|
970
|
+
dueTo?: string;
|
|
971
|
+
}
|
|
972
|
+
interface PostponeInstallmentParams {
|
|
973
|
+
/** YYYY-MM-DD. Moves this parcela only; its siblings keep their dates. */
|
|
974
|
+
newDueDate: string;
|
|
975
|
+
}
|
|
976
|
+
interface ReissueInstallmentResult {
|
|
977
|
+
status: string;
|
|
978
|
+
reason: string | null;
|
|
979
|
+
installment: Installment | null;
|
|
980
|
+
}
|
|
981
|
+
interface CancelInstallmentPlanParams {
|
|
982
|
+
note?: string;
|
|
983
|
+
}
|
|
984
|
+
type RefundRequestStatus = 'pending' | 'confirmed' | 'rejected';
|
|
985
|
+
/**
|
|
986
|
+
* A refund Garu has been ASKED to make and has not made. Garu never moves this
|
|
987
|
+
* money: a boleto cannot be reversed and Celcoin exposes no Pix devolução, so
|
|
988
|
+
* the funds already settled to the seller and the return is a bank transfer
|
|
989
|
+
* only they can make.
|
|
990
|
+
*/
|
|
991
|
+
interface RefundRequest {
|
|
992
|
+
uuid: string;
|
|
993
|
+
status: RefundRequestStatus;
|
|
994
|
+
/** Amount the seller is being asked to return, in reais. */
|
|
995
|
+
amount: number;
|
|
996
|
+
reason: string | null;
|
|
997
|
+
/** Exactly one of these is set. */
|
|
998
|
+
installmentPlanId: string | null;
|
|
999
|
+
chargeId: string | null;
|
|
1000
|
+
requestedBy: {
|
|
1001
|
+
type: string;
|
|
1002
|
+
id?: number | string | null;
|
|
1003
|
+
};
|
|
1004
|
+
resolvedBy: {
|
|
1005
|
+
type: string;
|
|
1006
|
+
id?: number | string | null;
|
|
1007
|
+
} | null;
|
|
1008
|
+
sellerNote: string | null;
|
|
1009
|
+
resolvedAt: string | null;
|
|
1010
|
+
createdAt: string;
|
|
1011
|
+
}
|
|
1012
|
+
interface RefundRequestList {
|
|
1013
|
+
data: RefundRequest[];
|
|
1014
|
+
count: number;
|
|
1015
|
+
totalCount: number;
|
|
1016
|
+
totalPages: number;
|
|
1017
|
+
}
|
|
1018
|
+
interface RequestPlanRefundParams {
|
|
1019
|
+
/** Defaults to everything the carnê has collected. */
|
|
1020
|
+
amount?: number;
|
|
1021
|
+
reason?: string;
|
|
1022
|
+
}
|
|
1023
|
+
interface ListRefundRequestsParams {
|
|
1024
|
+
page?: number;
|
|
1025
|
+
limit?: number;
|
|
1026
|
+
status?: RefundRequestStatus | RefundRequestStatus[];
|
|
1027
|
+
/** Filter by carnê uuid. */
|
|
1028
|
+
planId?: string;
|
|
1029
|
+
/** Filter by charge uuid (Pix and boleto requests). */
|
|
1030
|
+
chargeId?: string;
|
|
1031
|
+
}
|
|
1032
|
+
interface ResolveRefundRequestParams {
|
|
1033
|
+
note?: string;
|
|
1034
|
+
}
|
|
868
1035
|
|
|
869
1036
|
/**
|
|
870
1037
|
* Charges — create and manage payments against a product.
|
|
@@ -954,12 +1121,218 @@ declare class Charges {
|
|
|
954
1121
|
private post;
|
|
955
1122
|
}
|
|
956
1123
|
|
|
1124
|
+
/**
|
|
1125
|
+
* Boleto parcelado (carnê) — one product sold as N monthly bank slips.
|
|
1126
|
+
*
|
|
1127
|
+
* This is seller-financed consumer credit, not a card instalment. Nobody
|
|
1128
|
+
* guarantees a boleto: if the buyer stops paying at parcela 4, the seller
|
|
1129
|
+
* keeps four parcelas and loses the rest. Garu emits the slips, chases them
|
|
1130
|
+
* and reports, but carries none of the default risk.
|
|
1131
|
+
*
|
|
1132
|
+
* Only the FIRST boleto exists at creation. The rest are emitted month by
|
|
1133
|
+
* month, and the sale activates when parcela 1 compensates — a plan is not a
|
|
1134
|
+
* sale until the buyer has paid something.
|
|
1135
|
+
*/
|
|
1136
|
+
declare class InstallmentPlans {
|
|
1137
|
+
private readonly http;
|
|
1138
|
+
constructor(http: HttpClient);
|
|
1139
|
+
/**
|
|
1140
|
+
* Sell a product as a carnê. Auto-attaches `X-Idempotency-Key` (UUIDv4 if
|
|
1141
|
+
* you don't pass `idempotencyKey`), which matters more here than anywhere
|
|
1142
|
+
* else in the API: this call registers a REAL boleto at the bank, so a
|
|
1143
|
+
* blind retry can put two payable barcodes in one buyer's hands.
|
|
1144
|
+
*
|
|
1145
|
+
* @example
|
|
1146
|
+
* const carne = await garu.installmentPlans.create({
|
|
1147
|
+
* productId: '40381e8e-6ee7-4b8e-9393-766a6e2109d2',
|
|
1148
|
+
* customerId: 4821,
|
|
1149
|
+
* installments: 12
|
|
1150
|
+
* });
|
|
1151
|
+
* // A R$1.200 product at fator 1,30 bills R$130,00 a month:
|
|
1152
|
+
* carne.totalScheduled; // 1560
|
|
1153
|
+
* carne.installmentAmount; // 130
|
|
1154
|
+
* carne.installmentsDetail?.[0]; // parcela 1, with its barcode
|
|
1155
|
+
*
|
|
1156
|
+
* @example
|
|
1157
|
+
* // Attribute the sale to an affiliate. Fixed at sale time: every later
|
|
1158
|
+
* // parcela inherits it, so omitting it pays them nothing for the whole
|
|
1159
|
+
* // carnê. The affiliate must already be active on this product.
|
|
1160
|
+
* await garu.installmentPlans.create({
|
|
1161
|
+
* productId: '40381e8e-6ee7-4b8e-9393-766a6e2109d2',
|
|
1162
|
+
* customerId: 4821,
|
|
1163
|
+
* installments: 6,
|
|
1164
|
+
* firstDueDate: '2026-10-05',
|
|
1165
|
+
* affiliateId: 5
|
|
1166
|
+
* });
|
|
1167
|
+
*/
|
|
1168
|
+
create(params: CreateInstallmentPlanParams): Promise<InstallmentPlan>;
|
|
1169
|
+
/**
|
|
1170
|
+
* List carnês, newest first. `dueFrom`/`dueTo` filter on the FIRST
|
|
1171
|
+
* parcela's due date, which is what identifies the plan; filtering on every
|
|
1172
|
+
* parcela would return one carnê twelve times.
|
|
1173
|
+
*
|
|
1174
|
+
* @example
|
|
1175
|
+
* const atRisk = await garu.installmentPlans.list({ status: 'defaulted' });
|
|
1176
|
+
*
|
|
1177
|
+
* @example
|
|
1178
|
+
* const live = await garu.installmentPlans.list({
|
|
1179
|
+
* status: ['active', 'pending_activation'],
|
|
1180
|
+
* customerId: 4821,
|
|
1181
|
+
* limit: 50
|
|
1182
|
+
* });
|
|
1183
|
+
*/
|
|
1184
|
+
list(params?: ListInstallmentPlansParams): Promise<InstallmentPlanList>;
|
|
1185
|
+
/**
|
|
1186
|
+
* Retrieve one carnê with every parcela: due date, status, barcode line and
|
|
1187
|
+
* boleto PDF.
|
|
1188
|
+
*
|
|
1189
|
+
* @example
|
|
1190
|
+
* const carne = await garu.installmentPlans.get(uuid);
|
|
1191
|
+
* const unpaid = carne.installmentsDetail?.filter((i) => i.status !== 'paid');
|
|
1192
|
+
* carne.totalCollected; // what has actually cleared, not what was billed
|
|
1193
|
+
*/
|
|
1194
|
+
get(uuid: string): Promise<InstallmentPlan>;
|
|
1195
|
+
/**
|
|
1196
|
+
* Issue a segunda via for one parcela, once the current slip has expired.
|
|
1197
|
+
*
|
|
1198
|
+
* A boleto stays payable at any bank until its due date plus five days, so
|
|
1199
|
+
* Garu refuses while the old barcode is still live — two live barcodes for
|
|
1200
|
+
* one parcela is how a buyer pays it twice. Once per parcela per day.
|
|
1201
|
+
*
|
|
1202
|
+
* @example
|
|
1203
|
+
* const result = await garu.installmentPlans.reissueInstallment(uuid, 4);
|
|
1204
|
+
* if (result.status === 'emitted') {
|
|
1205
|
+
* send(result.installment!.boleto!.barcodeLine);
|
|
1206
|
+
* }
|
|
1207
|
+
*/
|
|
1208
|
+
reissueInstallment(uuid: string, number: number): Promise<ReissueInstallmentResult>;
|
|
1209
|
+
/**
|
|
1210
|
+
* Move one parcela to a later date. Its siblings keep theirs — this
|
|
1211
|
+
* postpones a payment, it does not restructure the carnê. A slip already
|
|
1212
|
+
* emitted stays payable on its original date until it expires.
|
|
1213
|
+
*
|
|
1214
|
+
* @example
|
|
1215
|
+
* await garu.installmentPlans.postponeInstallment(uuid, 4, {
|
|
1216
|
+
* newDueDate: '2026-12-20'
|
|
1217
|
+
* });
|
|
1218
|
+
*/
|
|
1219
|
+
postponeInstallment(uuid: string, number: number, params: PostponeInstallmentParams): Promise<Installment>;
|
|
1220
|
+
/**
|
|
1221
|
+
* Record a parcela as paid, for when the buyer paid the slip but the
|
|
1222
|
+
* webhook never arrived.
|
|
1223
|
+
*
|
|
1224
|
+
* Garu asks the provider to confirm the charge really compensated before
|
|
1225
|
+
* recording it, because this settles the transaction and pays affiliate and
|
|
1226
|
+
* co-producer commissions. A provider outage refuses the action rather than
|
|
1227
|
+
* trusting the assertion.
|
|
1228
|
+
*
|
|
1229
|
+
* @example
|
|
1230
|
+
* const parcela = await garu.installmentPlans.markInstallmentPaid(uuid, 3);
|
|
1231
|
+
* parcela.status; // 'paid'
|
|
1232
|
+
*/
|
|
1233
|
+
markInstallmentPaid(uuid: string, number: number): Promise<Installment>;
|
|
1234
|
+
/**
|
|
1235
|
+
* Cancel the carnê. Emission and reminders stop and open slips are
|
|
1236
|
+
* cancelled at the provider.
|
|
1237
|
+
*
|
|
1238
|
+
* Money already collected is NOT returned — open a refund request for that.
|
|
1239
|
+
* A cancelled carnê is never revived by a late payment; that money opens a
|
|
1240
|
+
* refund request instead.
|
|
1241
|
+
*
|
|
1242
|
+
* @example
|
|
1243
|
+
* await garu.installmentPlans.cancel(uuid, { note: 'Comprador desistiu' });
|
|
1244
|
+
*/
|
|
1245
|
+
cancel(uuid: string, params?: CancelInstallmentPlanParams): Promise<InstallmentPlan>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Ask for this carnê to be refunded.
|
|
1248
|
+
*
|
|
1249
|
+
* Garu does NOT move the money. A boleto cannot be reversed and the funds
|
|
1250
|
+
* already settled to you, so this records the request and notifies your
|
|
1251
|
+
* team. Transfer the money to the buyer yourself, then close it with
|
|
1252
|
+
* `garu.refundRequests.confirm`.
|
|
1253
|
+
*
|
|
1254
|
+
* @example
|
|
1255
|
+
* const request = await garu.installmentPlans.requestRefund(uuid, {
|
|
1256
|
+
* reason: 'Produto não entregue'
|
|
1257
|
+
* });
|
|
1258
|
+
* request.status; // 'pending' — nothing has moved yet
|
|
1259
|
+
* request.amount; // defaults to everything the carnê collected
|
|
1260
|
+
*/
|
|
1261
|
+
requestRefund(uuid: string, params?: RequestPlanRefundParams): Promise<RefundRequest>;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* Refunds Garu has been asked to make and cannot make for you.
|
|
1266
|
+
*
|
|
1267
|
+
* A boleto cannot be reversed at all, and Celcoin exposes no Pix devolução.
|
|
1268
|
+
* Either way the funds already settled to you, so the return is a bank
|
|
1269
|
+
* transfer only you can make. This resource records the request, notifies
|
|
1270
|
+
* your team, and waits for you to assert the money went back. Garu records
|
|
1271
|
+
* the assertion; it never observes the transfer.
|
|
1272
|
+
*
|
|
1273
|
+
* Card and Woovi Pix never appear here — they have real automated reversals
|
|
1274
|
+
* (`garu.charges.refund`).
|
|
1275
|
+
*/
|
|
1276
|
+
declare class RefundRequests {
|
|
1277
|
+
private readonly http;
|
|
1278
|
+
constructor(http: HttpClient);
|
|
1279
|
+
/**
|
|
1280
|
+
* List refund requests, newest first. Covers carnê and Pix/boleto alike.
|
|
1281
|
+
*
|
|
1282
|
+
* @example
|
|
1283
|
+
* // Everything you still owe a buyer.
|
|
1284
|
+
* const owed = await garu.refundRequests.list({ status: 'pending' });
|
|
1285
|
+
* const total = owed.data.reduce((sum, r) => sum + r.amount, 0);
|
|
1286
|
+
*
|
|
1287
|
+
* @example
|
|
1288
|
+
* const forThisCarne = await garu.refundRequests.list({ planId: carne.uuid });
|
|
1289
|
+
*/
|
|
1290
|
+
list(params?: ListRefundRequestsParams): Promise<RefundRequestList>;
|
|
1291
|
+
/**
|
|
1292
|
+
* Retrieve one refund request.
|
|
1293
|
+
*
|
|
1294
|
+
* @example
|
|
1295
|
+
* const request = await garu.refundRequests.get(uuid);
|
|
1296
|
+
* request.installmentPlanId ?? request.chargeId; // exactly one is set
|
|
1297
|
+
*/
|
|
1298
|
+
get(uuid: string): Promise<RefundRequest>;
|
|
1299
|
+
/**
|
|
1300
|
+
* Record that you returned the money. Call this AFTER transferring it.
|
|
1301
|
+
*
|
|
1302
|
+
* Confirming closes a carnê as refunded, stops remaining parcelas, cancels
|
|
1303
|
+
* open slips at the provider and claws back the affiliate and co-producer
|
|
1304
|
+
* commissions on the parcelas that cleared. For a Pix or boleto charge it
|
|
1305
|
+
* marks the charge reversed and fires `transaction.refunded`. Idempotent:
|
|
1306
|
+
* confirming twice does not claw back twice.
|
|
1307
|
+
*
|
|
1308
|
+
* @example
|
|
1309
|
+
* // 1. You send the money to the buyer, out of band.
|
|
1310
|
+
* // 2. Then tell Garu it happened.
|
|
1311
|
+
* await garu.refundRequests.confirm(uuid, {
|
|
1312
|
+
* note: 'Pix devolvido em 14/08, e2e E12345678'
|
|
1313
|
+
* });
|
|
1314
|
+
*/
|
|
1315
|
+
confirm(uuid: string, params?: ResolveRefundRequestParams): Promise<RefundRequest>;
|
|
1316
|
+
/**
|
|
1317
|
+
* Decline the request. The carnê is untouched and keeps running.
|
|
1318
|
+
* Idempotent.
|
|
1319
|
+
*
|
|
1320
|
+
* @example
|
|
1321
|
+
* await garu.refundRequests.reject(uuid, {
|
|
1322
|
+
* note: 'Produto entregue e retirado na loja em 02/08'
|
|
1323
|
+
* });
|
|
1324
|
+
*/
|
|
1325
|
+
reject(uuid: string, params?: ResolveRefundRequestParams): Promise<RefundRequest>;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
957
1328
|
/**
|
|
958
1329
|
* Customers — manage your customer base.
|
|
959
1330
|
*
|
|
960
|
-
*
|
|
961
|
-
*
|
|
962
|
-
* exist across multiple
|
|
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.
|
|
963
1336
|
*/
|
|
964
1337
|
declare class Customers {
|
|
965
1338
|
private readonly http;
|
|
@@ -975,29 +1348,35 @@ declare class Customers {
|
|
|
975
1348
|
* phone: '11987654321',
|
|
976
1349
|
* personType: 'fisica'
|
|
977
1350
|
* });
|
|
1351
|
+
* customer.uuid;
|
|
978
1352
|
*/
|
|
979
1353
|
create(params: CreateCustomerParams): Promise<CustomerRecord>;
|
|
980
1354
|
/**
|
|
981
1355
|
* List customers for the authenticated seller, with pagination and search.
|
|
982
1356
|
*
|
|
983
1357
|
* @example
|
|
984
|
-
* const { data,
|
|
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' });
|
|
985
1363
|
*/
|
|
986
1364
|
list(params?: ListCustomersParams): Promise<CustomerList>;
|
|
987
1365
|
/**
|
|
988
|
-
* Fetch a single customer by
|
|
1366
|
+
* Fetch a single customer by uuid.
|
|
989
1367
|
*
|
|
990
1368
|
* @example
|
|
991
|
-
* const customer = await garu.customers.get(
|
|
1369
|
+
* const customer = await garu.customers.get('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
|
|
992
1370
|
*/
|
|
993
|
-
get(
|
|
1371
|
+
get(uuid: string): Promise<CustomerRecord>;
|
|
994
1372
|
/**
|
|
995
|
-
* 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.
|
|
996
1375
|
*
|
|
997
1376
|
* @example
|
|
998
|
-
* const updated = await garu.customers.update(
|
|
1377
|
+
* const updated = await garu.customers.update('a1b2c3d4-...', { name: 'Maria Santos' });
|
|
999
1378
|
*/
|
|
1000
|
-
update(
|
|
1379
|
+
update(uuid: string, params: UpdateCustomerParams): Promise<CustomerRecord>;
|
|
1001
1380
|
/**
|
|
1002
1381
|
* Set or clear the per-seller billing email override.
|
|
1003
1382
|
*
|
|
@@ -1007,21 +1386,24 @@ declare class Customers {
|
|
|
1007
1386
|
*
|
|
1008
1387
|
* @example
|
|
1009
1388
|
* // Set
|
|
1010
|
-
* await garu.customers.setBillingEmailOverride(
|
|
1389
|
+
* await garu.customers.setBillingEmailOverride('a1b2c3d4-...', {
|
|
1011
1390
|
* billingEmailOverride: 'cobrancas@empresa.com.br'
|
|
1012
1391
|
* });
|
|
1013
1392
|
*
|
|
1014
1393
|
* // Clear and fall back to the last-used email
|
|
1015
|
-
* await garu.customers.setBillingEmailOverride(
|
|
1394
|
+
* await garu.customers.setBillingEmailOverride('a1b2c3d4-...', { billingEmailOverride: null });
|
|
1016
1395
|
*/
|
|
1017
|
-
setBillingEmailOverride(
|
|
1396
|
+
setBillingEmailOverride(uuid: string, params: SetBillingEmailOverrideParams): Promise<CustomerRecord>;
|
|
1018
1397
|
/**
|
|
1019
|
-
* 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).
|
|
1020
1400
|
*
|
|
1021
1401
|
* @example
|
|
1022
|
-
* await garu.customers.delete(
|
|
1402
|
+
* await garu.customers.delete('a1b2c3d4-e5f6-7890-abcd-ef1234567890');
|
|
1023
1403
|
*/
|
|
1024
|
-
delete(
|
|
1404
|
+
delete(uuid: string): Promise<{
|
|
1405
|
+
removed: boolean;
|
|
1406
|
+
}>;
|
|
1025
1407
|
}
|
|
1026
1408
|
|
|
1027
1409
|
/**
|
|
@@ -1504,6 +1886,10 @@ interface GaruOptions {
|
|
|
1504
1886
|
*/
|
|
1505
1887
|
declare class Garu {
|
|
1506
1888
|
readonly charges: Charges;
|
|
1889
|
+
/** Boleto parcelado (carnê): one product sold as N monthly bank slips. */
|
|
1890
|
+
readonly installmentPlans: InstallmentPlans;
|
|
1891
|
+
/** Refunds Garu has been asked to make and cannot make for you. */
|
|
1892
|
+
readonly refundRequests: RefundRequests;
|
|
1507
1893
|
readonly customers: Customers;
|
|
1508
1894
|
readonly meta: Meta;
|
|
1509
1895
|
readonly products: Products;
|
|
@@ -1567,4 +1953,4 @@ declare class GaruServerError extends GaruAPIError {
|
|
|
1567
1953
|
constructor(message: string, status: number, requestId: string | null, body: unknown);
|
|
1568
1954
|
}
|
|
1569
1955
|
|
|
1570
|
-
export { type CancelAtPeriodEndScheduledChargeParams, type CancelChargeResult, 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 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 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, 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 };
|