@cuenca-mx/cuenca-js 0.0.1-dev.23 → 0.0.1-dev.26

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