@dime-technology/dime-js-sdk 1.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/dist/index.cjs ADDED
@@ -0,0 +1,1227 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Address: () => Address,
24
+ ApiException: () => ApiException,
25
+ AuthenticationException: () => AuthenticationException,
26
+ Client: () => Client,
27
+ Config: () => Config,
28
+ ConnectionException: () => ConnectionException,
29
+ CursorPage: () => CursorPage,
30
+ Customer: () => Customer,
31
+ DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
32
+ Deposit: () => Deposit,
33
+ DepositGroup: () => DepositGroup,
34
+ DepositWithTransactions: () => DepositWithTransactions,
35
+ DimeException: () => DimeException,
36
+ FormLink: () => FormLink,
37
+ Merchant: () => Merchant,
38
+ MessageResult: () => MessageResult,
39
+ NotFoundException: () => NotFoundException,
40
+ PaymentMethod: () => PaymentMethod,
41
+ PermissionDeniedException: () => PermissionDeniedException,
42
+ RateLimitException: () => RateLimitException,
43
+ RecurringPayment: () => RecurringPayment,
44
+ RecurringPaymentMethod: () => RecurringPaymentMethod,
45
+ ServerException: () => ServerException,
46
+ TokenizeResult: () => TokenizeResult,
47
+ Transaction: () => Transaction,
48
+ TransactionAddress: () => TransactionAddress,
49
+ VERSION: () => VERSION,
50
+ ValidationException: () => ValidationException
51
+ });
52
+ module.exports = __toCommonJS(index_exports);
53
+
54
+ // src/config.ts
55
+ var DEFAULT_BASE_URL = "https://app.dimepayments.com";
56
+ var VERSION = "1.0.0";
57
+ var Config = class {
58
+ token;
59
+ baseUrl;
60
+ timeout;
61
+ maxRetries;
62
+ retryBaseDelay;
63
+ fetch;
64
+ sleep;
65
+ constructor(options, baseUrl) {
66
+ if (typeof options === "string") {
67
+ this.token = options;
68
+ this.baseUrl = baseUrl ?? DEFAULT_BASE_URL;
69
+ this.timeout = 30;
70
+ this.maxRetries = 2;
71
+ this.retryBaseDelay = 0.5;
72
+ } else {
73
+ this.token = options.token;
74
+ this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
75
+ this.timeout = options.timeout ?? 30;
76
+ this.maxRetries = options.maxRetries ?? 2;
77
+ this.retryBaseDelay = options.retryBaseDelay ?? 0.5;
78
+ this.fetch = options.fetch;
79
+ this.sleep = options.sleep;
80
+ }
81
+ }
82
+ baseUri() {
83
+ return `${this.baseUrl.replace(/\/$/, "")}/api/`;
84
+ }
85
+ };
86
+
87
+ // src/exceptions/dime-exception.ts
88
+ var DimeException = class extends Error {
89
+ constructor(message, statusCode, responseBody = {}, cause) {
90
+ super(message, { cause });
91
+ this.statusCode = statusCode;
92
+ this.responseBody = responseBody;
93
+ this.name = this.constructor.name;
94
+ Object.setPrototypeOf(this, new.target.prototype);
95
+ }
96
+ statusCode;
97
+ responseBody;
98
+ getStatusCode() {
99
+ return this.statusCode;
100
+ }
101
+ getResponseBody() {
102
+ return this.responseBody;
103
+ }
104
+ };
105
+
106
+ // src/exceptions/validation-exception.ts
107
+ var ValidationException = class extends DimeException {
108
+ constructor(message, errors = {}, statusCode, responseBody = {}, cause) {
109
+ super(message, statusCode, responseBody, cause);
110
+ this.errors = errors;
111
+ }
112
+ errors;
113
+ getErrors() {
114
+ return this.errors;
115
+ }
116
+ firstError() {
117
+ for (const messages of Object.values(this.errors)) {
118
+ if (messages.length > 0) return messages[0];
119
+ }
120
+ return void 0;
121
+ }
122
+ };
123
+
124
+ // src/exceptions/rate-limit-exception.ts
125
+ var RateLimitException = class extends DimeException {
126
+ constructor(message, retryAfter, statusCode = 429, responseBody = {}, cause) {
127
+ super(message, statusCode, responseBody, cause);
128
+ this.retryAfter = retryAfter;
129
+ }
130
+ retryAfter;
131
+ getRetryAfter() {
132
+ return this.retryAfter;
133
+ }
134
+ };
135
+
136
+ // src/exceptions/api-exception.ts
137
+ var ApiException = class extends DimeException {
138
+ };
139
+
140
+ // src/exceptions/authentication-exception.ts
141
+ var AuthenticationException = class extends DimeException {
142
+ };
143
+
144
+ // src/exceptions/permission-denied-exception.ts
145
+ var PermissionDeniedException = class extends DimeException {
146
+ };
147
+
148
+ // src/exceptions/not-found-exception.ts
149
+ var NotFoundException = class extends DimeException {
150
+ };
151
+
152
+ // src/exceptions/server-exception.ts
153
+ var ServerException = class extends DimeException {
154
+ };
155
+
156
+ // src/exceptions/connection-exception.ts
157
+ var ConnectionException = class extends DimeException {
158
+ };
159
+
160
+ // src/http/error-handler.ts
161
+ function looksLikeValidation(status, body) {
162
+ if (body["errors"] !== void 0 && typeof body["errors"] === "object" && !Array.isArray(body["errors"])) {
163
+ return true;
164
+ }
165
+ return (status === 400 || status === 422) && body["message"] !== void 0 && typeof body["message"] === "object" && !Array.isArray(body["message"]);
166
+ }
167
+ function extractErrors(body) {
168
+ const raw = body["errors"] ?? body["message"];
169
+ if (raw === null || raw === void 0 || typeof raw !== "object" || Array.isArray(raw)) {
170
+ return {};
171
+ }
172
+ const errors = {};
173
+ for (const [field, messages] of Object.entries(raw)) {
174
+ errors[field] = Array.isArray(messages) ? messages.map(String) : [String(messages)];
175
+ }
176
+ return errors;
177
+ }
178
+ function extractMessage(body) {
179
+ const data = body["data"];
180
+ if (data !== null && data !== void 0 && typeof data === "object" && !Array.isArray(data)) {
181
+ const msg = data["message"];
182
+ if (typeof msg === "string") return msg;
183
+ }
184
+ if (typeof body["message"] === "string") return body["message"];
185
+ return void 0;
186
+ }
187
+ function firstMessage(errors) {
188
+ for (const messages of Object.values(errors)) {
189
+ if (messages.length > 0) return messages[0];
190
+ }
191
+ return void 0;
192
+ }
193
+ function handleError(status, body, retryAfter) {
194
+ if (looksLikeValidation(status, body)) {
195
+ const errors = extractErrors(body);
196
+ throw new ValidationException(
197
+ firstMessage(errors) ?? "The given data was invalid.",
198
+ errors,
199
+ status,
200
+ body
201
+ );
202
+ }
203
+ const message = extractMessage(body) ?? `Dime API request failed with status ${status}.`;
204
+ if (status === 401) throw new AuthenticationException(message, status, body);
205
+ if (status === 403) throw new PermissionDeniedException(message, status, body);
206
+ if (status === 404) throw new NotFoundException(message, status, body);
207
+ if (status === 429) throw new RateLimitException(message, retryAfter, status, body);
208
+ if (status >= 500) throw new ServerException(message, status, body);
209
+ throw new ApiException(message, status, body);
210
+ }
211
+
212
+ // src/http/transport.ts
213
+ var Transport = class {
214
+ constructor(config) {
215
+ this.config = config;
216
+ this.fetchFn = config.fetch ?? globalThis.fetch;
217
+ this.sleepFn = config.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
218
+ }
219
+ config;
220
+ fetchFn;
221
+ sleepFn;
222
+ /**
223
+ * Execute a request and return the decoded JSON body.
224
+ *
225
+ * The Dime API expects request parameters in the JSON body even for GET
226
+ * requests; this transport always sends the payload as a JSON body regardless
227
+ * of HTTP method, matching the server's expectation.
228
+ */
229
+ async request(method, path, body = {}, query = {}) {
230
+ let url = `${this.config.baseUri()}${path.replace(/^\//, "")}`;
231
+ if (Object.keys(query).length > 0) {
232
+ url += "?" + new URLSearchParams(query).toString();
233
+ }
234
+ const hasBody = Object.keys(body).length > 0;
235
+ const init = {
236
+ method,
237
+ headers: {
238
+ Authorization: `Bearer ${this.config.token}`,
239
+ Accept: "application/json",
240
+ "Content-Type": "application/json",
241
+ "X-Dime-Sdk": `dime-js-sdk/${VERSION}`
242
+ },
243
+ ...hasBody ? { body: JSON.stringify(body) } : {}
244
+ };
245
+ return this.attempt(url, init, 0);
246
+ }
247
+ async attempt(url, init, attempt) {
248
+ let response;
249
+ try {
250
+ const controller = new AbortController();
251
+ const timer = setTimeout(() => controller.abort(), this.config.timeout * 1e3);
252
+ try {
253
+ response = await this.fetchFn(url, { ...init, signal: controller.signal });
254
+ } finally {
255
+ clearTimeout(timer);
256
+ }
257
+ } catch (err) {
258
+ const isAbort = err instanceof Error && err.name === "AbortError";
259
+ const label = isAbort ? `Request timed out after ${this.config.timeout}s` : `Could not reach the Dime API: ${err instanceof Error ? err.message : String(err)}`;
260
+ if (attempt < this.config.maxRetries) {
261
+ await this.sleep(attempt, void 0);
262
+ return this.attempt(url, init, attempt + 1);
263
+ }
264
+ throw new ConnectionException(label, void 0, {}, err instanceof Error ? err : void 0);
265
+ }
266
+ const status = response.status;
267
+ if ((status === 429 || status >= 500) && attempt < this.config.maxRetries) {
268
+ const retryAfter = parseRetryAfter(response);
269
+ await this.sleep(attempt, retryAfter);
270
+ return this.attempt(url, init, attempt + 1);
271
+ }
272
+ const decoded = await decode(response);
273
+ if (status < 200 || status >= 300) {
274
+ handleError(status, decoded, parseRetryAfter(response));
275
+ }
276
+ return decoded;
277
+ }
278
+ async sleep(attempt, retryAfter) {
279
+ const ms = retryAfter !== void 0 ? retryAfter * 1e3 : Math.min(2 ** attempt * this.config.retryBaseDelay * 1e3, 3e4);
280
+ await this.sleepFn(ms);
281
+ }
282
+ };
283
+ function parseRetryAfter(response) {
284
+ const header = response.headers.get("Retry-After");
285
+ if (header !== null && /^\d+$/.test(header)) return parseInt(header, 10);
286
+ return void 0;
287
+ }
288
+ async function decode(response) {
289
+ const text = await response.text();
290
+ if (!text) return {};
291
+ try {
292
+ const parsed = JSON.parse(text);
293
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
294
+ return parsed;
295
+ }
296
+ return { message: text };
297
+ } catch {
298
+ return { message: text };
299
+ }
300
+ }
301
+
302
+ // src/support/arr.ts
303
+ function arrString(data, key) {
304
+ const value = data[key];
305
+ if (value === null || value === void 0 || Array.isArray(value)) return void 0;
306
+ if (typeof value === "boolean") return value ? "1" : "0";
307
+ return String(value);
308
+ }
309
+ function arrInt(data, key) {
310
+ const value = data[key];
311
+ if (value === null || value === void 0) return void 0;
312
+ const n = Number(value);
313
+ return Number.isNaN(n) ? void 0 : Math.trunc(n);
314
+ }
315
+ function arrBool(data, key, defaultValue = false) {
316
+ const value = data[key];
317
+ return value === null || value === void 0 ? defaultValue : Boolean(value);
318
+ }
319
+ function arrObjectFrom(data, keys) {
320
+ for (const key of keys) {
321
+ const value = data[key];
322
+ if (value !== null && value !== void 0 && typeof value === "object" && !Array.isArray(value)) {
323
+ return value;
324
+ }
325
+ }
326
+ return {};
327
+ }
328
+
329
+ // src/data-objects/address.ts
330
+ var Address = class _Address {
331
+ constructor(id, recipient, lineOne, lineTwo, lineThree, city, state, zip) {
332
+ this.id = id;
333
+ this.recipient = recipient;
334
+ this.lineOne = lineOne;
335
+ this.lineTwo = lineTwo;
336
+ this.lineThree = lineThree;
337
+ this.city = city;
338
+ this.state = state;
339
+ this.zip = zip;
340
+ }
341
+ id;
342
+ recipient;
343
+ lineOne;
344
+ lineTwo;
345
+ lineThree;
346
+ city;
347
+ state;
348
+ zip;
349
+ static fromRaw(data) {
350
+ return new _Address(
351
+ // show returns address_id; list returns id
352
+ arrInt(data, "address_id") ?? arrInt(data, "id"),
353
+ arrString(data, "recipient"),
354
+ arrString(data, "line_one"),
355
+ arrString(data, "line_two"),
356
+ arrString(data, "line_three"),
357
+ arrString(data, "city"),
358
+ arrString(data, "state"),
359
+ arrString(data, "zip")
360
+ );
361
+ }
362
+ };
363
+
364
+ // src/data-objects/message-result.ts
365
+ var MessageResult = class _MessageResult {
366
+ constructor(message) {
367
+ this.message = message;
368
+ }
369
+ message;
370
+ static fromRaw(data) {
371
+ return new _MessageResult(arrString(data, "message"));
372
+ }
373
+ };
374
+
375
+ // src/pagination/cursor-page.ts
376
+ var CursorPage = class {
377
+ constructor(data, nextCursor, prevCursor, perPage, path, fetcher) {
378
+ this.data = data;
379
+ this.nextCursor = nextCursor;
380
+ this.prevCursor = prevCursor;
381
+ this.perPage = perPage;
382
+ this.path = path;
383
+ this.fetcher = fetcher;
384
+ }
385
+ data;
386
+ nextCursor;
387
+ prevCursor;
388
+ perPage;
389
+ path;
390
+ fetcher;
391
+ hasMore() {
392
+ return this.nextCursor !== void 0 && this.fetcher !== void 0;
393
+ }
394
+ async next() {
395
+ if (!this.hasMore() || this.nextCursor === void 0 || this.fetcher === void 0) {
396
+ return null;
397
+ }
398
+ return this.fetcher(this.nextCursor);
399
+ }
400
+ /** Lazily iterate every item across all remaining pages. */
401
+ async *autoPaging() {
402
+ let page = this;
403
+ while (page !== null) {
404
+ for (const item of page.data) {
405
+ yield item;
406
+ }
407
+ page = await page.next();
408
+ }
409
+ }
410
+ [Symbol.iterator]() {
411
+ return this.data[Symbol.iterator]();
412
+ }
413
+ get length() {
414
+ return this.data.length;
415
+ }
416
+ };
417
+
418
+ // src/resources/abstract-resource.ts
419
+ var AbstractResource = class {
420
+ constructor(transport) {
421
+ this.transport = transport;
422
+ }
423
+ transport;
424
+ /**
425
+ * Build the standard Dime request envelope, dropping null/undefined values.
426
+ */
427
+ envelope(data = {}, filters = {}) {
428
+ const body = {};
429
+ const prunedData = pruneNulls(data);
430
+ if (Object.keys(prunedData).length > 0) body["data"] = prunedData;
431
+ const prunedFilters = pruneNulls(filters);
432
+ if (Object.keys(prunedFilters).length > 0) body["filters"] = prunedFilters;
433
+ return body;
434
+ }
435
+ async paginate(method, path, body, map, query = {}) {
436
+ const raw = await this.transport.request(method, path, body, query);
437
+ const items = Array.isArray(raw["data"]) ? raw["data"] : [];
438
+ const meta = raw["meta"] !== null && typeof raw["meta"] === "object" && !Array.isArray(raw["meta"]) ? raw["meta"] : {};
439
+ const nextCursor = extractCursor(meta, "next_cursor");
440
+ const prevCursor = extractCursor(meta, "prev_cursor");
441
+ const fetcher = (cursor) => this.paginate(method, path, body, map, { cursor });
442
+ return new CursorPage(
443
+ items.map(map),
444
+ nextCursor,
445
+ prevCursor,
446
+ typeof meta["per_page"] === "number" ? meta["per_page"] : void 0,
447
+ typeof meta["path"] === "string" ? meta["path"] : void 0,
448
+ nextCursor !== void 0 ? fetcher : void 0
449
+ );
450
+ }
451
+ };
452
+ function extractCursor(meta, key) {
453
+ const v = meta[key];
454
+ return typeof v === "string" && v !== "" ? v : void 0;
455
+ }
456
+ function pruneNulls(obj) {
457
+ return Object.fromEntries(
458
+ Object.entries(obj).filter(([, v]) => v !== null && v !== void 0)
459
+ );
460
+ }
461
+
462
+ // src/resources/addresses.ts
463
+ var Addresses = class extends AbstractResource {
464
+ async list(sid, uuid) {
465
+ return this.paginate("GET", "address/list", this.envelope({ sid, uuid }), Address.fromRaw);
466
+ }
467
+ async show(sid, uuid, addressId) {
468
+ const raw = await this.transport.request("GET", "address/show", this.envelope({ sid, uuid, address_id: addressId }));
469
+ return Address.fromRaw(raw["data"] ?? {});
470
+ }
471
+ async create(sid, uuid, attributes) {
472
+ const raw = await this.transport.request("POST", "address/create", this.envelope({ sid, uuid, ...attributes }));
473
+ return Address.fromRaw(raw["data"] ?? {});
474
+ }
475
+ async update(sid, uuid, addressId, attributes) {
476
+ const raw = await this.transport.request("PATCH", "address/update", this.envelope({ sid, uuid, address_id: addressId, ...attributes }));
477
+ return Address.fromRaw(raw["data"] ?? {});
478
+ }
479
+ async delete(sid, uuid, addressId) {
480
+ const raw = await this.transport.request("POST", "address/delete", this.envelope({ sid, uuid, address_id: addressId }));
481
+ return MessageResult.fromRaw(raw["data"] ?? raw);
482
+ }
483
+ };
484
+
485
+ // src/data-objects/customer.ts
486
+ var Customer = class _Customer {
487
+ constructor(uuid, firstName, lastName, phone, email, addr1, addr2, addr3, city, state, zip, country) {
488
+ this.uuid = uuid;
489
+ this.firstName = firstName;
490
+ this.lastName = lastName;
491
+ this.phone = phone;
492
+ this.email = email;
493
+ this.addr1 = addr1;
494
+ this.addr2 = addr2;
495
+ this.addr3 = addr3;
496
+ this.city = city;
497
+ this.state = state;
498
+ this.zip = zip;
499
+ this.country = country;
500
+ }
501
+ uuid;
502
+ firstName;
503
+ lastName;
504
+ phone;
505
+ email;
506
+ addr1;
507
+ addr2;
508
+ addr3;
509
+ city;
510
+ state;
511
+ zip;
512
+ country;
513
+ static fromRaw(data) {
514
+ return new _Customer(
515
+ arrString(data, "uuid"),
516
+ arrString(data, "first_name"),
517
+ arrString(data, "last_name"),
518
+ arrString(data, "phone"),
519
+ arrString(data, "email"),
520
+ arrString(data, "addr1"),
521
+ arrString(data, "addr2"),
522
+ arrString(data, "addr3"),
523
+ arrString(data, "city"),
524
+ arrString(data, "state"),
525
+ arrString(data, "zip"),
526
+ arrString(data, "country")
527
+ );
528
+ }
529
+ };
530
+
531
+ // src/resources/customers.ts
532
+ var Customers = class extends AbstractResource {
533
+ async list(sid, filters = {}) {
534
+ return this.paginate("GET", "customer/list", this.envelope({ sid }, filters), Customer.fromRaw);
535
+ }
536
+ async show(sid, filters) {
537
+ const raw = await this.transport.request("GET", "customer/show", this.envelope({ sid }, filters));
538
+ return Customer.fromRaw(raw["data"] ?? {});
539
+ }
540
+ async create(sid, attributes) {
541
+ const raw = await this.transport.request("POST", "customer/create", this.envelope({ sid, ...attributes }));
542
+ return Customer.fromRaw(raw["data"] ?? {});
543
+ }
544
+ async update(sid, filters, attributes) {
545
+ const raw = await this.transport.request("PATCH", "customer/update", this.envelope({ sid, ...attributes }, filters));
546
+ return Customer.fromRaw(raw["data"] ?? {});
547
+ }
548
+ async delete(sid, filters) {
549
+ const raw = await this.transport.request("POST", "customer/delete", this.envelope({ sid }, filters));
550
+ return MessageResult.fromRaw(raw["data"] ?? raw);
551
+ }
552
+ };
553
+
554
+ // src/data-objects/deposit.ts
555
+ var Deposit = class _Deposit {
556
+ constructor(transactionDate, fundDate, transactionInfoId, transactionId, transactionDetailAccount, authorizationAmount, netAmount, sweepId, type) {
557
+ this.transactionDate = transactionDate;
558
+ this.fundDate = fundDate;
559
+ this.transactionInfoId = transactionInfoId;
560
+ this.transactionId = transactionId;
561
+ this.transactionDetailAccount = transactionDetailAccount;
562
+ this.authorizationAmount = authorizationAmount;
563
+ this.netAmount = netAmount;
564
+ this.sweepId = sweepId;
565
+ this.type = type;
566
+ }
567
+ transactionDate;
568
+ fundDate;
569
+ transactionInfoId;
570
+ transactionId;
571
+ transactionDetailAccount;
572
+ authorizationAmount;
573
+ netAmount;
574
+ sweepId;
575
+ type;
576
+ static fromRaw(data) {
577
+ return new _Deposit(
578
+ arrString(data, "transaction_date"),
579
+ arrString(data, "fund_date"),
580
+ arrString(data, "transaction_info_id"),
581
+ arrString(data, "transaction_id"),
582
+ arrString(data, "transaction_detail_account"),
583
+ arrString(data, "authorization_amount"),
584
+ arrString(data, "net_amount"),
585
+ arrString(data, "sweep_id"),
586
+ arrString(data, "type")
587
+ );
588
+ }
589
+ };
590
+
591
+ // src/data-objects/transaction-address.ts
592
+ var TransactionAddress = class _TransactionAddress {
593
+ constructor(firstName, lastName, addr1, addr2, city, state, zip) {
594
+ this.firstName = firstName;
595
+ this.lastName = lastName;
596
+ this.addr1 = addr1;
597
+ this.addr2 = addr2;
598
+ this.city = city;
599
+ this.state = state;
600
+ this.zip = zip;
601
+ }
602
+ firstName;
603
+ lastName;
604
+ addr1;
605
+ addr2;
606
+ city;
607
+ state;
608
+ zip;
609
+ static fromRaw(data) {
610
+ return new _TransactionAddress(
611
+ arrString(data, "first_name"),
612
+ arrString(data, "last_name"),
613
+ arrString(data, "addr1"),
614
+ arrString(data, "addr2"),
615
+ arrString(data, "city"),
616
+ arrString(data, "state"),
617
+ arrString(data, "zip")
618
+ );
619
+ }
620
+ };
621
+
622
+ // src/data-objects/transaction.ts
623
+ var Transaction = class _Transaction {
624
+ constructor(transactionType, transactionStatus, transactionStatusDescription, transactionNumber, transactionDate, fundDate, settleDate, amount, description, statusCode, statusText, email, phone, customerUuid, multiUseToken, pending = false, transactionInfoId, parentTransactionInfoId, billingAddress = new TransactionAddress(), shippingAddress = new TransactionAddress()) {
625
+ this.transactionType = transactionType;
626
+ this.transactionStatus = transactionStatus;
627
+ this.transactionStatusDescription = transactionStatusDescription;
628
+ this.transactionNumber = transactionNumber;
629
+ this.transactionDate = transactionDate;
630
+ this.fundDate = fundDate;
631
+ this.settleDate = settleDate;
632
+ this.amount = amount;
633
+ this.description = description;
634
+ this.statusCode = statusCode;
635
+ this.statusText = statusText;
636
+ this.email = email;
637
+ this.phone = phone;
638
+ this.customerUuid = customerUuid;
639
+ this.multiUseToken = multiUseToken;
640
+ this.pending = pending;
641
+ this.transactionInfoId = transactionInfoId;
642
+ this.parentTransactionInfoId = parentTransactionInfoId;
643
+ this.billingAddress = billingAddress;
644
+ this.shippingAddress = shippingAddress;
645
+ }
646
+ transactionType;
647
+ transactionStatus;
648
+ transactionStatusDescription;
649
+ transactionNumber;
650
+ transactionDate;
651
+ fundDate;
652
+ settleDate;
653
+ amount;
654
+ description;
655
+ statusCode;
656
+ statusText;
657
+ email;
658
+ phone;
659
+ customerUuid;
660
+ multiUseToken;
661
+ pending;
662
+ transactionInfoId;
663
+ parentTransactionInfoId;
664
+ billingAddress;
665
+ shippingAddress;
666
+ static fromRaw(data) {
667
+ return new _Transaction(
668
+ arrString(data, "transaction_type"),
669
+ arrString(data, "transaction_status"),
670
+ arrString(data, "transaction_status_description"),
671
+ arrString(data, "transaction_number"),
672
+ arrString(data, "transaction_date"),
673
+ arrString(data, "fund_date"),
674
+ arrString(data, "settle_date"),
675
+ arrString(data, "amount"),
676
+ arrString(data, "description"),
677
+ arrString(data, "status_code"),
678
+ arrString(data, "status_text"),
679
+ arrString(data, "email"),
680
+ arrString(data, "phone"),
681
+ arrString(data, "customer_uuid"),
682
+ arrString(data, "multi_use_token"),
683
+ arrBool(data, "pending"),
684
+ arrString(data, "transaction_info_id"),
685
+ arrString(data, "parent_transaction_info_id"),
686
+ TransactionAddress.fromRaw(arrObjectFrom(data, ["billing_address"])),
687
+ // The API returns shipping under the camelCase key `shippingAddress`; accept
688
+ // snake_case too in case that is ever corrected server-side.
689
+ TransactionAddress.fromRaw(arrObjectFrom(data, ["shippingAddress", "shipping_address"]))
690
+ );
691
+ }
692
+ };
693
+
694
+ // src/data-objects/deposit-with-transactions.ts
695
+ var DepositWithTransactions = class _DepositWithTransactions {
696
+ constructor(sid, transactionInfoId, transactionId, transactionDate, fundDate, type, countOfTransactions, transTotal, transactions = []) {
697
+ this.sid = sid;
698
+ this.transactionInfoId = transactionInfoId;
699
+ this.transactionId = transactionId;
700
+ this.transactionDate = transactionDate;
701
+ this.fundDate = fundDate;
702
+ this.type = type;
703
+ this.countOfTransactions = countOfTransactions;
704
+ this.transTotal = transTotal;
705
+ this.transactions = transactions;
706
+ }
707
+ sid;
708
+ transactionInfoId;
709
+ transactionId;
710
+ transactionDate;
711
+ fundDate;
712
+ type;
713
+ countOfTransactions;
714
+ transTotal;
715
+ transactions;
716
+ static fromRaw(data) {
717
+ const txRaw = data["transactions"];
718
+ const transactions = Array.isArray(txRaw) ? txRaw.map((t) => Transaction.fromRaw(t)) : typeof txRaw === "object" && txRaw !== null ? Object.values(txRaw).map((t) => Transaction.fromRaw(t)) : [];
719
+ return new _DepositWithTransactions(
720
+ arrString(data, "sid"),
721
+ arrString(data, "transaction_info_id"),
722
+ arrString(data, "transaction_id"),
723
+ arrString(data, "transaction_date"),
724
+ arrString(data, "fund_date"),
725
+ arrString(data, "type"),
726
+ arrInt(data, "countOfTransactions"),
727
+ arrString(data, "transTotal"),
728
+ transactions
729
+ );
730
+ }
731
+ };
732
+
733
+ // src/data-objects/deposit-group.ts
734
+ var DepositGroup = class _DepositGroup {
735
+ constructor(sid, count, deposits = []) {
736
+ this.sid = sid;
737
+ this.count = count;
738
+ this.deposits = deposits;
739
+ }
740
+ sid;
741
+ count;
742
+ deposits;
743
+ static fromRaw(data) {
744
+ const depositsRaw = data["deposits"];
745
+ const deposits = typeof depositsRaw === "object" && depositsRaw !== null && !Array.isArray(depositsRaw) ? Object.values(depositsRaw).map(
746
+ (d) => DepositWithTransactions.fromRaw(d)
747
+ ) : [];
748
+ return new _DepositGroup(arrString(data, "sid"), arrInt(data, "count"), deposits);
749
+ }
750
+ };
751
+
752
+ // src/resources/deposits.ts
753
+ var Deposits = class extends AbstractResource {
754
+ async list(sid, filters = {}) {
755
+ return this.paginate("GET", "deposit/list", this.envelope({ sid }, filters), Deposit.fromRaw);
756
+ }
757
+ async listWithTransactions(sid, filters) {
758
+ const raw = await this.transport.request("GET", "deposit/list-with-trans", this.envelope({ sid }, filters));
759
+ return DepositGroup.fromRaw(raw["data"] ?? {});
760
+ }
761
+ async show(sid, identifier) {
762
+ const raw = await this.transport.request("GET", "deposit/show", this.envelope({ sid, ...identifier }));
763
+ return DepositWithTransactions.fromRaw(raw["data"] ?? {});
764
+ }
765
+ };
766
+
767
+ // src/data-objects/form-link.ts
768
+ var FormLink = class _FormLink {
769
+ constructor(link) {
770
+ this.link = link;
771
+ }
772
+ link;
773
+ static fromRaw(data) {
774
+ return new _FormLink(arrString(data, "link"));
775
+ }
776
+ };
777
+
778
+ // src/data-objects/merchant.ts
779
+ var Merchant = class _Merchant {
780
+ constructor(name, sid, mcc, slug, pubApiKey, processorMid, active = false, activeAt, gPay = false, aPay = false, pciCompliance = false, website, addr1, addr2, city, state, zip, phone, primaryPhone, primaryEmail, primaryName) {
781
+ this.name = name;
782
+ this.sid = sid;
783
+ this.mcc = mcc;
784
+ this.slug = slug;
785
+ this.pubApiKey = pubApiKey;
786
+ this.processorMid = processorMid;
787
+ this.active = active;
788
+ this.activeAt = activeAt;
789
+ this.gPay = gPay;
790
+ this.aPay = aPay;
791
+ this.pciCompliance = pciCompliance;
792
+ this.website = website;
793
+ this.addr1 = addr1;
794
+ this.addr2 = addr2;
795
+ this.city = city;
796
+ this.state = state;
797
+ this.zip = zip;
798
+ this.phone = phone;
799
+ this.primaryPhone = primaryPhone;
800
+ this.primaryEmail = primaryEmail;
801
+ this.primaryName = primaryName;
802
+ }
803
+ name;
804
+ sid;
805
+ mcc;
806
+ slug;
807
+ pubApiKey;
808
+ processorMid;
809
+ active;
810
+ activeAt;
811
+ gPay;
812
+ aPay;
813
+ pciCompliance;
814
+ website;
815
+ addr1;
816
+ addr2;
817
+ city;
818
+ state;
819
+ zip;
820
+ phone;
821
+ primaryPhone;
822
+ primaryEmail;
823
+ primaryName;
824
+ static fromRaw(data) {
825
+ return new _Merchant(
826
+ arrString(data, "name"),
827
+ arrString(data, "sid"),
828
+ arrString(data, "mcc"),
829
+ arrString(data, "slug"),
830
+ arrString(data, "pub_api_key"),
831
+ arrString(data, "processor_mid"),
832
+ arrBool(data, "active"),
833
+ arrString(data, "active_at"),
834
+ arrBool(data, "g_pay"),
835
+ arrBool(data, "a_pay"),
836
+ arrBool(data, "pci_compliance"),
837
+ arrString(data, "website"),
838
+ arrString(data, "addr1"),
839
+ arrString(data, "addr2"),
840
+ arrString(data, "city"),
841
+ arrString(data, "state"),
842
+ arrString(data, "zip"),
843
+ arrString(data, "phone"),
844
+ arrString(data, "primary_phone"),
845
+ arrString(data, "primary_email"),
846
+ arrString(data, "primary_name")
847
+ );
848
+ }
849
+ };
850
+
851
+ // src/resources/merchants.ts
852
+ var Merchants = class extends AbstractResource {
853
+ async list(filters = {}) {
854
+ return this.paginate("GET", "merchant/list", this.envelope({}, filters), Merchant.fromRaw);
855
+ }
856
+ async show(sid) {
857
+ const raw = await this.transport.request("GET", "merchant/show", this.envelope({ sid }));
858
+ return Merchant.fromRaw(raw["data"] ?? {});
859
+ }
860
+ async create(attributes) {
861
+ const raw = await this.transport.request("POST", "merchant/create", this.envelope(attributes));
862
+ return Merchant.fromRaw(raw["data"] ?? {});
863
+ }
864
+ async update(sid, attributes) {
865
+ const raw = await this.transport.request("PATCH", "merchant/update", this.envelope({ sid, ...attributes }));
866
+ return Merchant.fromRaw(raw["data"] ?? {});
867
+ }
868
+ async getFormLink(sid) {
869
+ const raw = await this.transport.request("GET", "merchant/get-form-link", this.envelope({ sid }));
870
+ return FormLink.fromRaw(raw["data"] ?? {});
871
+ }
872
+ };
873
+
874
+ // src/data-objects/payment-method.ts
875
+ var PaymentMethod = class _PaymentMethod {
876
+ constructor(id, type, token, firstName, lastName, ccNameOnCard, ccLastFour, ccExpirationDate, ccBrand, achBankAccountName, achRoutingNumber, achAccountNumber, achOwnershipType, achAccountType, achBankName, status, statusDate, enabled = false, isDefault = false, addr1, addr2, addr3, city, state, zip) {
877
+ this.id = id;
878
+ this.type = type;
879
+ this.token = token;
880
+ this.firstName = firstName;
881
+ this.lastName = lastName;
882
+ this.ccNameOnCard = ccNameOnCard;
883
+ this.ccLastFour = ccLastFour;
884
+ this.ccExpirationDate = ccExpirationDate;
885
+ this.ccBrand = ccBrand;
886
+ this.achBankAccountName = achBankAccountName;
887
+ this.achRoutingNumber = achRoutingNumber;
888
+ this.achAccountNumber = achAccountNumber;
889
+ this.achOwnershipType = achOwnershipType;
890
+ this.achAccountType = achAccountType;
891
+ this.achBankName = achBankName;
892
+ this.status = status;
893
+ this.statusDate = statusDate;
894
+ this.enabled = enabled;
895
+ this.isDefault = isDefault;
896
+ this.addr1 = addr1;
897
+ this.addr2 = addr2;
898
+ this.addr3 = addr3;
899
+ this.city = city;
900
+ this.state = state;
901
+ this.zip = zip;
902
+ }
903
+ id;
904
+ type;
905
+ token;
906
+ firstName;
907
+ lastName;
908
+ ccNameOnCard;
909
+ ccLastFour;
910
+ ccExpirationDate;
911
+ ccBrand;
912
+ achBankAccountName;
913
+ achRoutingNumber;
914
+ achAccountNumber;
915
+ achOwnershipType;
916
+ achAccountType;
917
+ achBankName;
918
+ status;
919
+ statusDate;
920
+ enabled;
921
+ isDefault;
922
+ addr1;
923
+ addr2;
924
+ addr3;
925
+ city;
926
+ state;
927
+ zip;
928
+ static fromRaw(data) {
929
+ return new _PaymentMethod(
930
+ arrInt(data, "id"),
931
+ arrString(data, "type"),
932
+ arrString(data, "token"),
933
+ arrString(data, "first_name"),
934
+ arrString(data, "last_name"),
935
+ arrString(data, "cc_name_on_card"),
936
+ arrString(data, "cc_last_four"),
937
+ arrString(data, "cc_expiration_date"),
938
+ arrString(data, "cc_brand"),
939
+ arrString(data, "ach_bank_account_name"),
940
+ arrString(data, "ach_routing_number"),
941
+ arrString(data, "ach_account_number"),
942
+ arrString(data, "ach_ownership_type"),
943
+ arrString(data, "ach_account_type"),
944
+ arrString(data, "ach_bank_name"),
945
+ arrString(data, "status"),
946
+ arrString(data, "status_date"),
947
+ arrBool(data, "enabled"),
948
+ arrBool(data, "default"),
949
+ arrString(data, "addr1"),
950
+ arrString(data, "addr2"),
951
+ arrString(data, "addr3"),
952
+ arrString(data, "city"),
953
+ arrString(data, "state"),
954
+ arrString(data, "zip")
955
+ );
956
+ }
957
+ };
958
+
959
+ // src/resources/payment-methods.ts
960
+ var PaymentMethods = class extends AbstractResource {
961
+ async list(sid, filters) {
962
+ return this.paginate("GET", "payment-method/list", this.envelope({ sid }, filters), PaymentMethod.fromRaw);
963
+ }
964
+ async show(sid, paymentMethodId, filters) {
965
+ const raw = await this.transport.request("GET", "payment-method/show", this.envelope({ sid, payment_method_id: paymentMethodId }, filters));
966
+ return PaymentMethod.fromRaw(raw["data"] ?? {});
967
+ }
968
+ async create(sid, attributes) {
969
+ const raw = await this.transport.request("POST", "payment-method/create", this.envelope({ sid, ...attributes }));
970
+ return PaymentMethod.fromRaw(raw["data"] ?? {});
971
+ }
972
+ async update(sid, attributes) {
973
+ const raw = await this.transport.request("PATCH", "payment-method/update", this.envelope({ sid, ...attributes }));
974
+ return PaymentMethod.fromRaw(raw["data"] ?? {});
975
+ }
976
+ async delete(sid, paymentMethodId, uuid) {
977
+ const raw = await this.transport.request("POST", "payment-method/delete", this.envelope({ sid, payment_method_id: paymentMethodId, uuid }));
978
+ return MessageResult.fromRaw(raw["data"] ?? raw);
979
+ }
980
+ };
981
+
982
+ // src/data-objects/recurring-payment-method.ts
983
+ var RecurringPaymentMethod = class _RecurringPaymentMethod {
984
+ constructor(id, type, lastFour, expiration, zip, nameOnCard, bankAccountName, routingNumber, accountNumber, ownershipType, accountType, bankName) {
985
+ this.id = id;
986
+ this.type = type;
987
+ this.lastFour = lastFour;
988
+ this.expiration = expiration;
989
+ this.zip = zip;
990
+ this.nameOnCard = nameOnCard;
991
+ this.bankAccountName = bankAccountName;
992
+ this.routingNumber = routingNumber;
993
+ this.accountNumber = accountNumber;
994
+ this.ownershipType = ownershipType;
995
+ this.accountType = accountType;
996
+ this.bankName = bankName;
997
+ }
998
+ id;
999
+ type;
1000
+ lastFour;
1001
+ expiration;
1002
+ zip;
1003
+ nameOnCard;
1004
+ bankAccountName;
1005
+ routingNumber;
1006
+ accountNumber;
1007
+ ownershipType;
1008
+ accountType;
1009
+ bankName;
1010
+ static fromRaw(data) {
1011
+ return new _RecurringPaymentMethod(
1012
+ arrInt(data, "id"),
1013
+ arrString(data, "type"),
1014
+ arrString(data, "last_four"),
1015
+ arrString(data, "expiration"),
1016
+ arrString(data, "zip"),
1017
+ arrString(data, "name_on_card"),
1018
+ arrString(data, "bank_account_name"),
1019
+ arrString(data, "routing_number"),
1020
+ arrString(data, "account_number"),
1021
+ arrString(data, "ownership_type"),
1022
+ arrString(data, "account_type"),
1023
+ arrString(data, "bank_name")
1024
+ );
1025
+ }
1026
+ };
1027
+
1028
+ // src/data-objects/recurring-payment.ts
1029
+ var RecurringPayment = class _RecurringPayment {
1030
+ constructor(id, name, amount, startDate, endDate, recurrenceSchedule, lastRunDate, lastRunStatus, lastRunFailedCount, nextRunDate, status, pausedUntilDate, customerUuid, cancelledAt, error, paymentMethod = new RecurringPaymentMethod(), shippingAddress = new TransactionAddress()) {
1031
+ this.id = id;
1032
+ this.name = name;
1033
+ this.amount = amount;
1034
+ this.startDate = startDate;
1035
+ this.endDate = endDate;
1036
+ this.recurrenceSchedule = recurrenceSchedule;
1037
+ this.lastRunDate = lastRunDate;
1038
+ this.lastRunStatus = lastRunStatus;
1039
+ this.lastRunFailedCount = lastRunFailedCount;
1040
+ this.nextRunDate = nextRunDate;
1041
+ this.status = status;
1042
+ this.pausedUntilDate = pausedUntilDate;
1043
+ this.customerUuid = customerUuid;
1044
+ this.cancelledAt = cancelledAt;
1045
+ this.error = error;
1046
+ this.paymentMethod = paymentMethod;
1047
+ this.shippingAddress = shippingAddress;
1048
+ }
1049
+ id;
1050
+ name;
1051
+ amount;
1052
+ startDate;
1053
+ endDate;
1054
+ recurrenceSchedule;
1055
+ lastRunDate;
1056
+ lastRunStatus;
1057
+ lastRunFailedCount;
1058
+ nextRunDate;
1059
+ status;
1060
+ pausedUntilDate;
1061
+ customerUuid;
1062
+ cancelledAt;
1063
+ error;
1064
+ paymentMethod;
1065
+ shippingAddress;
1066
+ static fromRaw(data) {
1067
+ return new _RecurringPayment(
1068
+ arrInt(data, "id"),
1069
+ arrString(data, "name"),
1070
+ arrString(data, "amount"),
1071
+ arrString(data, "start_date"),
1072
+ arrString(data, "end_date"),
1073
+ arrString(data, "recurrence_schedule"),
1074
+ arrString(data, "last_run_date"),
1075
+ arrString(data, "last_run_status"),
1076
+ arrInt(data, "last_run_failed_count"),
1077
+ arrString(data, "next_run_date"),
1078
+ arrString(data, "status"),
1079
+ arrString(data, "paused_until_date"),
1080
+ arrString(data, "customer_uuid"),
1081
+ arrString(data, "cancelled_at"),
1082
+ arrString(data, "error"),
1083
+ RecurringPaymentMethod.fromRaw(arrObjectFrom(data, ["payment_method"])),
1084
+ TransactionAddress.fromRaw(arrObjectFrom(data, ["shipping_address"]))
1085
+ );
1086
+ }
1087
+ };
1088
+
1089
+ // src/resources/recurring-payments.ts
1090
+ var RecurringPayments = class extends AbstractResource {
1091
+ async list(sid, filters = {}) {
1092
+ return this.paginate("GET", "recurring-payment/list", this.envelope({ sid }, filters), RecurringPayment.fromRaw);
1093
+ }
1094
+ async show(sid, recurringPaymentId) {
1095
+ const raw = await this.transport.request("GET", "recurring-payment/show", this.envelope({ sid, recurring_payment_id: recurringPaymentId }));
1096
+ return RecurringPayment.fromRaw(raw["data"] ?? {});
1097
+ }
1098
+ async create(sid, attributes) {
1099
+ const raw = await this.transport.request("POST", "recurring-payment/create", this.envelope({ sid, ...attributes }));
1100
+ return RecurringPayment.fromRaw(raw["data"] ?? {});
1101
+ }
1102
+ async edit(sid, recurringPaymentId, attributes) {
1103
+ const raw = await this.transport.request("PATCH", "recurring-payment/edit", this.envelope({ sid, recurring_payment_id: recurringPaymentId, ...attributes }));
1104
+ return RecurringPayment.fromRaw(raw["data"] ?? {});
1105
+ }
1106
+ async pause(sid, recurringPaymentId, pauseUntilDate) {
1107
+ const raw = await this.transport.request("PATCH", "recurring-payment/pause", this.envelope({ sid, recurring_payment_id: recurringPaymentId, pause_until_date: pauseUntilDate }));
1108
+ return RecurringPayment.fromRaw(raw["data"] ?? {});
1109
+ }
1110
+ async cancel(sid, recurringPaymentId) {
1111
+ const raw = await this.transport.request("PATCH", "recurring-payment/cancel", this.envelope({ sid, recurring_payment_id: recurringPaymentId }));
1112
+ return RecurringPayment.fromRaw(raw["data"] ?? {});
1113
+ }
1114
+ async activate(sid, recurringPaymentId) {
1115
+ const raw = await this.transport.request("PATCH", "recurring-payment/activate", this.envelope({ sid, recurring_payment_id: recurringPaymentId }));
1116
+ return RecurringPayment.fromRaw(raw["data"] ?? {});
1117
+ }
1118
+ async delete(sid, recurringPaymentId) {
1119
+ const raw = await this.transport.request("POST", "recurring-payment/delete", this.envelope({ sid, recurring_payment_id: recurringPaymentId }));
1120
+ return MessageResult.fromRaw(raw["data"] ?? raw);
1121
+ }
1122
+ };
1123
+
1124
+ // src/data-objects/tokenize-result.ts
1125
+ var TokenizeResult = class _TokenizeResult {
1126
+ constructor(token) {
1127
+ this.token = token;
1128
+ }
1129
+ token;
1130
+ static fromRaw(data) {
1131
+ return new _TokenizeResult(arrString(data, "token"));
1132
+ }
1133
+ };
1134
+
1135
+ // src/resources/transactions.ts
1136
+ var Transactions = class extends AbstractResource {
1137
+ async list(sid, filters = {}) {
1138
+ return this.paginate("GET", "transactions", this.envelope({ sid }, filters), Transaction.fromRaw);
1139
+ }
1140
+ async show(sid, identifier) {
1141
+ const raw = await this.transport.request("GET", "transaction", this.envelope({ sid, ...identifier }));
1142
+ return Transaction.fromRaw(raw["data"] ?? {});
1143
+ }
1144
+ async chargeCard(sid, attributes) {
1145
+ const raw = await this.transport.request("POST", "transaction/charge-card", this.envelope({ sid, ...attributes }));
1146
+ return Transaction.fromRaw(raw["data"] ?? {});
1147
+ }
1148
+ /** @deprecated The API marks this deprecated; prefer chargeCard() with a token. */
1149
+ async chargeCardToken(sid, attributes) {
1150
+ const raw = await this.transport.request("POST", "transaction/charge-card-token", this.envelope({ sid, ...attributes }));
1151
+ return Transaction.fromRaw(raw["data"] ?? {});
1152
+ }
1153
+ async chargeAch(sid, attributes) {
1154
+ const raw = await this.transport.request("POST", "transaction/charge-ach", this.envelope({ sid, ...attributes }));
1155
+ return Transaction.fromRaw(raw["data"] ?? {});
1156
+ }
1157
+ async tokenizeCard(sid, attributes) {
1158
+ const raw = await this.transport.request("POST", "transaction/tokenize-card", this.envelope({ sid, ...attributes }));
1159
+ return TokenizeResult.fromRaw(raw["data"] ?? {});
1160
+ }
1161
+ async refund(sid, attributes) {
1162
+ const raw = await this.transport.request("POST", "transaction/refund", this.envelope({ sid, ...attributes }));
1163
+ return MessageResult.fromRaw(raw["data"] ?? raw);
1164
+ }
1165
+ async void(sid, transactionType, transactionId) {
1166
+ const raw = await this.transport.request("PATCH", "transaction/void", this.envelope({ sid, transaction_type: transactionType, transaction_id: transactionId }));
1167
+ return MessageResult.fromRaw(raw["data"] ?? raw);
1168
+ }
1169
+ };
1170
+
1171
+ // src/client.ts
1172
+ var Client = class {
1173
+ transactions;
1174
+ customers;
1175
+ paymentMethods;
1176
+ merchants;
1177
+ addresses;
1178
+ deposits;
1179
+ recurringPayments;
1180
+ _config;
1181
+ constructor(token, baseUrl = DEFAULT_BASE_URL) {
1182
+ this._config = token instanceof Config ? token : new Config(token, baseUrl);
1183
+ const transport = new Transport(this._config);
1184
+ this.transactions = new Transactions(transport);
1185
+ this.customers = new Customers(transport);
1186
+ this.paymentMethods = new PaymentMethods(transport);
1187
+ this.merchants = new Merchants(transport);
1188
+ this.addresses = new Addresses(transport);
1189
+ this.deposits = new Deposits(transport);
1190
+ this.recurringPayments = new RecurringPayments(transport);
1191
+ }
1192
+ config() {
1193
+ return this._config;
1194
+ }
1195
+ };
1196
+ // Annotate the CommonJS export names for ESM import in node:
1197
+ 0 && (module.exports = {
1198
+ Address,
1199
+ ApiException,
1200
+ AuthenticationException,
1201
+ Client,
1202
+ Config,
1203
+ ConnectionException,
1204
+ CursorPage,
1205
+ Customer,
1206
+ DEFAULT_BASE_URL,
1207
+ Deposit,
1208
+ DepositGroup,
1209
+ DepositWithTransactions,
1210
+ DimeException,
1211
+ FormLink,
1212
+ Merchant,
1213
+ MessageResult,
1214
+ NotFoundException,
1215
+ PaymentMethod,
1216
+ PermissionDeniedException,
1217
+ RateLimitException,
1218
+ RecurringPayment,
1219
+ RecurringPaymentMethod,
1220
+ ServerException,
1221
+ TokenizeResult,
1222
+ Transaction,
1223
+ TransactionAddress,
1224
+ VERSION,
1225
+ ValidationException
1226
+ });
1227
+ //# sourceMappingURL=index.cjs.map