@cuenca-mx/cuenca-js 0.0.1-dev.23 → 0.0.1-dev.24
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/build/data-9edbb2a0.cjs +13 -0
- package/build/data-d5bcb7c8.mjs +10 -0
- package/build/identities-5808ada9.mjs +592 -0
- package/build/identities-89a79d34.cjs +626 -0
- package/build/index.cjs +80 -66
- package/build/index.mjs +24 -10
- package/build/requests/index.cjs +3 -2
- package/build/requests/index.mjs +2 -2
- package/build/types/index.cjs +17 -15
- package/build/types/index.mjs +2 -2
- package/build/umd/cuenca.umd.js +1 -1
- package/build/{walletTransactionRequest-a1851594.cjs → walletTransactionRequest-507c5996.cjs} +50 -4
- package/build/{walletTransactionRequest-7334f8c5.mjs → walletTransactionRequest-ede62457.mjs} +49 -4
- package/package.json +1 -1
- package/build/identities-7fc7251d.mjs +0 -289
- package/build/identities-b7106a30.cjs +0 -310
- package/build/queries-59c893b6.mjs +0 -282
- package/build/queries-bc02f9a8.cjs +0 -296
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var errors_index = require('./errors/index.cjs');
|
|
4
|
-
var identities = require('./identities-b7106a30.cjs');
|
|
5
|
-
|
|
6
|
-
class PageSize {
|
|
7
|
-
constructor(size) {
|
|
8
|
-
this.maxSize = 100;
|
|
9
|
-
this._ps = size;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
get size() {
|
|
13
|
-
return this._pageSize;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
set _ps(value) {
|
|
17
|
-
let validatedPageSize = this.maxSize;
|
|
18
|
-
if (value && value > 0 && value <= this.maxSize) {
|
|
19
|
-
validatedPageSize = value;
|
|
20
|
-
}
|
|
21
|
-
this._pageSize = validatedPageSize;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
class QueryParams {
|
|
26
|
-
constructor({
|
|
27
|
-
createdAfter,
|
|
28
|
-
createdBefore,
|
|
29
|
-
limit,
|
|
30
|
-
pageSize,
|
|
31
|
-
relatedTransaction,
|
|
32
|
-
userId,
|
|
33
|
-
count = false,
|
|
34
|
-
}) {
|
|
35
|
-
this.createdAfter = createdAfter;
|
|
36
|
-
this.createdBefore = createdBefore;
|
|
37
|
-
this._lmt = limit;
|
|
38
|
-
this.relatedTransaction = relatedTransaction;
|
|
39
|
-
this.userId = userId;
|
|
40
|
-
this.count = count;
|
|
41
|
-
this.pageSize = pageSize;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get limit() {
|
|
45
|
-
return this._limit;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Validator for limit
|
|
49
|
-
set _lmt(value) {
|
|
50
|
-
let validatedValue = null;
|
|
51
|
-
if (value && value >= 0) {
|
|
52
|
-
validatedValue = value;
|
|
53
|
-
}
|
|
54
|
-
this._limit = validatedValue;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
toObject() {
|
|
58
|
-
return {
|
|
59
|
-
created_after: this.createdAfter,
|
|
60
|
-
created_before: this.createdBefore,
|
|
61
|
-
limit: this.limit,
|
|
62
|
-
related_transaction: this.relatedTransaction,
|
|
63
|
-
user_id: this.userId,
|
|
64
|
-
page_size: this.pageSize && this.pageSize.size,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
toParams() {
|
|
69
|
-
const helper = { ...this.toObject() };
|
|
70
|
-
if (this.count) helper.count = 1;
|
|
71
|
-
Object.keys(helper).forEach((k) => {
|
|
72
|
-
if (helper[k] == null) delete helper[k];
|
|
73
|
-
});
|
|
74
|
-
return helper;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
toQueryString() {
|
|
78
|
-
return new URLSearchParams(this.toParams()).toString();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
class AccountQuery extends QueryParams {
|
|
83
|
-
constructor({ accountNumber, ...args }) {
|
|
84
|
-
super(args);
|
|
85
|
-
this.accountNumber = accountNumber;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
toObject() {
|
|
89
|
-
return Object.assign(super.toObject(), {
|
|
90
|
-
account_number: this.accountNumber,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
class ApiKeyQuery extends QueryParams {
|
|
96
|
-
constructor({ active, ...args }) {
|
|
97
|
-
super(args);
|
|
98
|
-
this.active = active;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
toObject() {
|
|
102
|
-
return Object.assign(super.toObject(), {
|
|
103
|
-
active: this.active,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
class TransactionQuery extends QueryParams {
|
|
109
|
-
constructor({ status, ...args }) {
|
|
110
|
-
super(args);
|
|
111
|
-
this.status = status;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
toObject() {
|
|
115
|
-
return Object.assign(super.toObject(), {
|
|
116
|
-
status: this.status,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
class DepositQuery extends TransactionQuery {
|
|
122
|
-
constructor({ trackingKey, network, ...args }) {
|
|
123
|
-
super(args);
|
|
124
|
-
this.trackingKey = trackingKey;
|
|
125
|
-
this.network = network;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
toObject() {
|
|
129
|
-
return Object.assign(super.toObject(), {
|
|
130
|
-
tracking_key: this.trackingKey,
|
|
131
|
-
network: this.network,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
class TransferQuery extends TransactionQuery {
|
|
137
|
-
constructor({
|
|
138
|
-
accountNumber,
|
|
139
|
-
idempotencyKey,
|
|
140
|
-
trackingKey,
|
|
141
|
-
network,
|
|
142
|
-
...args
|
|
143
|
-
}) {
|
|
144
|
-
super(args);
|
|
145
|
-
this.accountNumber = accountNumber;
|
|
146
|
-
this.idempotencyKey = idempotencyKey;
|
|
147
|
-
this.trackingKey = trackingKey;
|
|
148
|
-
this.network = network;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
toObject() {
|
|
152
|
-
return Object.assign(super.toObject(), {
|
|
153
|
-
account_number: this.accountNumber,
|
|
154
|
-
idempotency_key: this.idempotencyKey,
|
|
155
|
-
tracking_key: this.trackingKey,
|
|
156
|
-
network: this.network,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
class BalanceEntryQuery extends QueryParams {
|
|
162
|
-
constructor({
|
|
163
|
-
fundingInstrumentUri,
|
|
164
|
-
count = false,
|
|
165
|
-
walletId = 'default',
|
|
166
|
-
...args
|
|
167
|
-
}) {
|
|
168
|
-
super(args);
|
|
169
|
-
this.fundingInstrumentUri = fundingInstrumentUri;
|
|
170
|
-
this.count = count;
|
|
171
|
-
this.walletId = walletId;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
toObject() {
|
|
175
|
-
return Object.assign(super.toObject(), {
|
|
176
|
-
wallet_id: this.walletId,
|
|
177
|
-
funding_instrument_uri: this.fundingInstrumentUri,
|
|
178
|
-
count: this.count,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
class BillPaymentQuery extends QueryParams {
|
|
184
|
-
constructor({ accountNumber, ...args }) {
|
|
185
|
-
super(args);
|
|
186
|
-
this.accountNumber = accountNumber;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
toObject() {
|
|
190
|
-
return Object.assign(super.toObject(), {
|
|
191
|
-
account_number: this.accountNumber,
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
class CardTransactionQuery extends QueryParams {
|
|
197
|
-
constructor({ cardUri, ...args }) {
|
|
198
|
-
super(args);
|
|
199
|
-
this.cardUri = cardUri;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
toObject() {
|
|
203
|
-
return Object.assign(super.toObject(), {
|
|
204
|
-
card_uri: this.cardUri,
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
class CardsQuery extends QueryParams {
|
|
210
|
-
constructor({ cardUri, count = false, ...args }) {
|
|
211
|
-
super(args);
|
|
212
|
-
this.cardUri = cardUri;
|
|
213
|
-
this.count = count;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
toObject() {
|
|
217
|
-
return Object.assign(super.toObject(), {
|
|
218
|
-
card_uri: this.cardUri,
|
|
219
|
-
count: this.count,
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
class WalletTransactionQuery extends QueryParams {
|
|
225
|
-
constructor({ walletUri, ...args }) {
|
|
226
|
-
super(args);
|
|
227
|
-
this.walletUri = walletUri;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
toObject() {
|
|
231
|
-
return Object.assign(super.toObject(), {
|
|
232
|
-
wallet_uri: this.walletUri,
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
class WalletQuery extends QueryParams {
|
|
238
|
-
constructor({ active, ...args }) {
|
|
239
|
-
super(args);
|
|
240
|
-
this.active = active;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
toObject() {
|
|
244
|
-
return Object.assign(super.toObject(), {
|
|
245
|
-
active: this.active,
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
class StatementQuery extends QueryParams {
|
|
251
|
-
constructor({ month, year, ...args }) {
|
|
252
|
-
super(args);
|
|
253
|
-
this.d = { month, year };
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
get month() {
|
|
257
|
-
return this._date.month;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
get year() {
|
|
261
|
-
return this._date.year;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
set d({ month, year }) {
|
|
265
|
-
const now = identities.dateToUTC(Date.now());
|
|
266
|
-
now.setUTCDate(1);
|
|
267
|
-
const date = identities.dateToUTC(`${year}-${month}-01`);
|
|
268
|
-
if (date.getTime() >= now.getTime()) {
|
|
269
|
-
throw new errors_index.ValidationError(
|
|
270
|
-
`${year}-${month} is not a valid year-month pair`,
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
this._date = { month, year };
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
toObject() {
|
|
277
|
-
return Object.assign(super.toObject(), {
|
|
278
|
-
month: this.month,
|
|
279
|
-
year: this.year,
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
exports.AccountQuery = AccountQuery;
|
|
285
|
-
exports.ApiKeyQuery = ApiKeyQuery;
|
|
286
|
-
exports.BalanceEntryQuery = BalanceEntryQuery;
|
|
287
|
-
exports.BillPaymentQuery = BillPaymentQuery;
|
|
288
|
-
exports.CardTransactionQuery = CardTransactionQuery;
|
|
289
|
-
exports.CardsQuery = CardsQuery;
|
|
290
|
-
exports.DepositQuery = DepositQuery;
|
|
291
|
-
exports.PageSize = PageSize;
|
|
292
|
-
exports.QueryParams = QueryParams;
|
|
293
|
-
exports.StatementQuery = StatementQuery;
|
|
294
|
-
exports.TransferQuery = TransferQuery;
|
|
295
|
-
exports.WalletQuery = WalletQuery;
|
|
296
|
-
exports.WalletTransactionQuery = WalletTransactionQuery;
|