squarefi-bff-api-module 1.5.0 → 1.5.2

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/api/auth.js CHANGED
@@ -23,12 +23,12 @@ exports.auth = {
23
23
  },
24
24
  telegram: (data) => apiClientFactory_1.apiClientV2.postRequest(exports.telegramSignInPath, { data }),
25
25
  password: (email, password // check on backend V2
26
- ) => apiClientFactory_1.apiClientV2.postRequest('/auth/sign-in/password', {
26
+ ) => apiClientFactory_1.apiClientV2.postRequest('/auth/sign-in/password/email', {
27
27
  data: { email, password },
28
28
  }),
29
29
  },
30
30
  signup: {
31
- password: (email, password) => apiClientFactory_1.apiClientV2.postRequest('/auth/sign-up/password', {
31
+ password: (email, password) => apiClientFactory_1.apiClientV2.postRequest('/auth/sign-up/password/email', {
32
32
  data: { email, password },
33
33
  }),
34
34
  telegram: (data) => apiClientFactory_1.apiClientV2.postRequest(exports.telegramSignUpPath, { data }),
@@ -2,21 +2,28 @@ import { API } from './types';
2
2
  export declare const issuing: {
3
3
  cards: {
4
4
  create: {
5
- standAloneCard: (data: API.Cards.Create.StandAloneRequest) => Promise<API.Cards.CardDetailItem>;
6
- fiatAccountCard: (data: API.Cards.Create.FiatAccountRequest) => Promise<API.Cards.CardDetailItem>;
5
+ standAloneCard: (data: API.Cards.Create.StandAloneRequest) => Promise<API.Cards.IssuingCardDetailItem>;
6
+ fiatAccountCard: (data: API.Cards.Create.FiatAccountRequest) => Promise<API.Cards.IssuingCardDetailItem>;
7
7
  };
8
- getByWalletUuid: (params: API.Cards.CardsList.Request.ByWalletUuid) => Promise<API.Cards.CardsList.Response>;
9
- getByFiatAccountAndWalletId: (params: API.Cards.CardsList.Request.ByFiatAccountAndWalletId) => Promise<API.Cards.CardsList.Response>;
10
- getById: (card_id: string) => Promise<API.Cards.CardDetailItem>;
8
+ byWalletUuid: {
9
+ getAll: (params: API.Cards.CardsList.Request.ByWalletUuid) => Promise<API.Cards.CardsList.Response>;
10
+ getBySubaccountType: (params: API.Cards.CardsList.Request.BySubaccountAndWalletUuid) => Promise<API.Cards.CardsList.Response>;
11
+ getByFiatAccount: (params: API.Cards.CardsList.Request.ByFiatAccountAndWalletId) => Promise<API.Cards.CardsList.Response>;
12
+ };
13
+ getById: (card_id: string) => Promise<API.Cards.IssuingCardDetailItem>;
11
14
  sensitiveData: {
12
15
  get: (card_id: string) => Promise<API.Cards.SensitiveData>;
13
16
  otp: {
14
17
  get: (card_id: string) => Promise<API.Cards.OTP>;
15
18
  };
16
19
  };
20
+ freeze: (card_id: string) => Promise<API.Cards.IssuingCardDetailItem>;
21
+ unfreeze: (card_id: string) => Promise<API.Cards.IssuingCardDetailItem>;
17
22
  close: (card_id: string) => Promise<any>;
18
- freeze: (card_id: string) => Promise<API.Cards.CardDetailItem>;
19
- unfreeze: (card_id: string) => Promise<API.Cards.CardDetailItem>;
23
+ limits: {
24
+ update: (card_id: string, data: API.Cards.Limits.UpdateRequest) => Promise<API.Cards.IssuingCardDetailItem>;
25
+ };
26
+ rename: (card_id: string, nick_name: string) => Promise<API.Cards.IssuingCardDetailItem>;
20
27
  };
21
28
  transactions: {
22
29
  getByCardId: (card_id: string, limit?: number, offset?: number) => Promise<API.Cards.TransactionsList>;
@@ -24,7 +31,7 @@ export declare const issuing: {
24
31
  };
25
32
  config: {
26
33
  programs: {
27
- getAll: () => Promise<API.Issuing.Programs.Response>;
34
+ getAll: () => Promise<API.Cards.Config.Program[]>;
28
35
  };
29
36
  };
30
37
  };
@@ -1,16 +1,6 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.issuing = void 0;
13
- const fiat_accounts_1 = require("./fiat_accounts");
14
4
  const apiClientFactory_1 = require("../utils/apiClientFactory");
15
5
  const constants_1 = require("../constants");
16
6
  exports.issuing = {
@@ -19,17 +9,14 @@ exports.issuing = {
19
9
  standAloneCard: (data) => apiClientFactory_1.apiClientV1.postRequest('/issuing/cards/create', { data }),
20
10
  fiatAccountCard: (data) => apiClientFactory_1.apiClientV1.postRequest('/issuing/cards/balance', { data }),
21
11
  },
22
- getByWalletUuid: (params) => apiClientFactory_1.apiClientV1.getRequest('/issuing/cards', { params }),
23
- getByFiatAccountAndWalletId: (params) => apiClientFactory_1.apiClientV1.getRequest('/issuing/cards', { params }),
24
- getById: (card_id) => __awaiter(void 0, void 0, void 0, function* () {
25
- const card = yield apiClientFactory_1.apiClientV1.getRequest(`/issuing/cards/${card_id}`);
26
- const fiatAccountData = yield fiat_accounts_1.fiat_accounts.getByUuid(card.fiat_account.id);
27
- // const { data: fiatAccountData } = await fiat_accounts.getByUuid({ V2 API FIAT ACCOUNTS
28
- // wallet_uuid: card.fiat_account.wallet_id,
29
- // fiat_account_id: card.fiat_account.id,
30
- // });
31
- return Object.assign(Object.assign({}, card), { fiat_account: Object.assign(Object.assign({}, fiatAccountData), { type: card.fiat_account.type }) });
32
- }),
12
+ byWalletUuid: {
13
+ getAll: (params) => apiClientFactory_1.apiClientV1.getRequest('/issuing/cards', { params }),
14
+ getBySubaccountType: (params) => apiClientFactory_1.apiClientV1.getRequest('/issuing/cards', {
15
+ params,
16
+ }),
17
+ getByFiatAccount: (params) => apiClientFactory_1.apiClientV1.getRequest('/issuing/cards', { params }),
18
+ },
19
+ getById: (card_id) => apiClientFactory_1.apiClientV1.getRequest(`/issuing/cards/${card_id}`),
33
20
  sensitiveData: {
34
21
  get: (card_id) => apiClientFactory_1.apiClientV1.getRequest(`/issuing/cards/${card_id}/sensitive`),
35
22
  otp: {
@@ -37,9 +24,15 @@ exports.issuing = {
37
24
  get: (card_id) => apiClientFactory_1.apiClientV1.getRequest(`/vcards/cards/${card_id}/sensitive/otp`),
38
25
  },
39
26
  },
40
- close: (card_id) => apiClientFactory_1.apiClientV1.deleteRequest(`/issuing/cards/${card_id}`),
41
27
  freeze: (card_id) => apiClientFactory_1.apiClientV1.patchRequest(`/issuing/cards/${card_id}/freeze`),
42
28
  unfreeze: (card_id) => apiClientFactory_1.apiClientV1.patchRequest(`/issuing/cards/${card_id}/unfreeze`),
29
+ close: (card_id) => apiClientFactory_1.apiClientV1.deleteRequest(`/issuing/cards/${card_id}`),
30
+ limits: {
31
+ update: (card_id, data) => apiClientFactory_1.apiClientV1.patchRequest(`/issuing/cards/${card_id}/limits`, { data }),
32
+ },
33
+ rename: (card_id, nick_name) => apiClientFactory_1.apiClientV1.patchRequest(`/issuing/cards/${card_id}/update`, {
34
+ data: { nick_name, request_id: crypto.randomUUID() },
35
+ }),
43
36
  },
44
37
  transactions: {
45
38
  getByCardId: (card_id, limit = constants_1.defaultPaginationParams.limit, offset = constants_1.defaultPaginationParams.offset) => apiClientFactory_1.apiClientV1.getRequest(`/issuing/transactions/`, {
@@ -51,7 +44,7 @@ exports.issuing = {
51
44
  },
52
45
  config: {
53
46
  programs: {
54
- getAll: () => apiClientFactory_1.apiClientV1.getRequest('/issuing/config/programs'),
47
+ getAll: () => apiClientFactory_1.apiClientV1.getRequest('/issuing/config/programs').then(({ data }) => data),
55
48
  },
56
49
  },
57
50
  };
@@ -1,4 +1,4 @@
1
- import { APIKeyRole, CardFormFactor, CardStatus, CardTransactionType, CardType, CurrencyType, KYCStatuses, OrderStatuses, OrderType, SubAccountType, WalletTransactionMethod, WalletTransactionRecordType, WalletTransactionType } from '../constants';
1
+ import { APIKeyRole, CardFormFactor, CardTransactionType, CardType, CurrencyType, KYCStatuses, OrderStatuses, OrderType, SortingDirection, SubAccountType, WalletTransactionMethod, WalletTransactionRecordType, WalletTransactionType } from '../constants';
2
2
  import { WalletType } from '../';
3
3
  export declare namespace API {
4
4
  namespace Auth {
@@ -105,9 +105,6 @@ export declare namespace API {
105
105
  id: string;
106
106
  account_currency: string;
107
107
  brand: string;
108
- card_issuing_fee: number | null;
109
- card_monthly_fee: number | null;
110
- initial_topup: number | null;
111
108
  form_factor: CardFormFactor | string;
112
109
  name: string;
113
110
  card_limit: number;
@@ -150,61 +147,56 @@ export declare namespace API {
150
147
  };
151
148
  };
152
149
  }
153
- interface Limit {
154
- interval?: string;
155
- amount: number;
156
- }
157
- interface Limits {
158
- single: Limit;
159
- daily: Limit;
160
- weekly: Limit;
161
- monthly: Limit;
162
- lifetime: Limit;
150
+ namespace Limits {
151
+ interface Limits {
152
+ all_time_enabled: boolean;
153
+ all_time_cap: number;
154
+ all_time_spent: number;
155
+ daily_enabled: boolean;
156
+ daily_cap: number;
157
+ daily_spent: number;
158
+ weekly_enabled: boolean;
159
+ weekly_cap: number;
160
+ weekly_spent: number;
161
+ monthly_enabled: boolean;
162
+ monthly_cap: number;
163
+ monthly_spent: number;
164
+ yearly_enabled: boolean;
165
+ yearly_cap: number;
166
+ yearly_spent: number;
167
+ per_transaction_enabled: boolean;
168
+ per_transaction_cap: number;
169
+ per_transaction_spent: number;
170
+ }
171
+ interface UpdateRequest {
172
+ all_time_cap?: number;
173
+ daily_cap?: number;
174
+ weekly_cap?: number;
175
+ monthly_cap?: number;
176
+ yearly_cap?: number;
177
+ per_transaction_cap?: number;
178
+ }
163
179
  }
164
- interface CardDetailItem {
180
+ interface IssuingCardListItem {
165
181
  brand: string;
166
182
  card_id: string;
167
- last4: string;
168
- card_status: CardStatus | string;
169
- form_factor: string;
170
- name_on_card: string;
171
- nick_name: string;
172
- program_id: string;
183
+ card_status: string;
184
+ created_at: string;
185
+ nick_name: string | null;
173
186
  wallet_id: string;
174
- type: CardType | string;
175
- transaction_limits: {
176
- amount: number;
177
- interval: string;
178
- }[];
179
- authorization_controls: {
180
- id: string;
181
- card_id: string;
182
- allowed_transaction_count: string;
183
- allowed_merchant_categories: string | null;
184
- };
187
+ program_id: string;
185
188
  fiat_account: {
186
189
  id: string;
187
- currency: API.Currencies.FiatCurrency;
188
190
  type: SubAccountType | string;
191
+ status: string;
189
192
  balance: number;
193
+ currency: API.Currencies.Currency;
190
194
  nick_name: string;
191
195
  wallet_id: string;
192
196
  created_at: string;
193
- payment_types: Array<{
194
- order_type: OrderType;
195
- }>;
196
- account_details?: API.FiatAccounts.FiatAccountDetails;
197
+ program_id: string;
198
+ account_currency: string;
197
199
  };
198
- }
199
- interface IssuingCardListItem {
200
- brand: string;
201
- card_id: string;
202
- card_status: string;
203
- created_at: string;
204
- nick_name: string | null;
205
- wallet_id: string;
206
- program_id: string;
207
- fiat_account: API.FiatAccounts.FiatAccount;
208
200
  last4: string;
209
201
  request_id: string;
210
202
  name_on_card: string | null;
@@ -212,6 +204,33 @@ export declare namespace API {
212
204
  form_factor: CardFormFactor | string;
213
205
  tokenizable: boolean;
214
206
  }
207
+ interface IssuingCardDetailItem {
208
+ id: string;
209
+ brand: string;
210
+ card_id: string;
211
+ fiat_account: {
212
+ id: string;
213
+ type: string;
214
+ status: string;
215
+ balance: number;
216
+ currency: API.Currencies.Currency;
217
+ nick_name: string | null;
218
+ wallet_id: string;
219
+ created_at: string;
220
+ program_id: string;
221
+ account_currency: string;
222
+ };
223
+ last4: string;
224
+ card_status: string;
225
+ form_factor: string;
226
+ name_on_card: string | null;
227
+ nick_name: string;
228
+ wallet_id: string;
229
+ type: string;
230
+ tokenizable: boolean;
231
+ issuing_programs: API.Cards.Config.Program;
232
+ limits: API.Cards.Limits.Limits;
233
+ }
215
234
  interface FiatAccountCardListItem {
216
235
  type: string;
217
236
  brand: string;
@@ -223,6 +242,7 @@ export declare namespace API {
223
242
  created_at: string;
224
243
  program_id: string;
225
244
  request_id: string;
245
+ card_number: string;
226
246
  card_status: string;
227
247
  expiry_year: number;
228
248
  form_factor: string;
@@ -233,11 +253,15 @@ export declare namespace API {
233
253
  }
234
254
  namespace CardsList {
235
255
  namespace Request {
236
- type ByWalletUuid = {
256
+ type CardsListSortingFields = Partial<Pick<IssuingCardListItem, 'created_at' | 'card_status' | 'last4' | 'nick_name' | 'name_on_card' | 'card_id'>>;
257
+ type CardsListFilteringFields = Partial<IssuingCardListItem>;
258
+ type CardsListRequestCommonParams = API.Common.Pagination.Request & API.Common.Sorting.Request<CardsListSortingFields> & API.Common.Filtering.Request<CardsListFilteringFields>;
259
+ interface ByWalletUuid extends CardsListRequestCommonParams {
237
260
  wallet_uuid: string;
238
- limit: number;
239
- offset: number;
240
- };
261
+ }
262
+ interface BySubaccountAndWalletUuid extends ByWalletUuid {
263
+ filter: Array<Partial<Record<'fiat_account', Record<'type', SubAccountType>>>>;
264
+ }
241
265
  type ByFiatAccountAndWalletId = ByWalletUuid & {
242
266
  fiat_account_id: string;
243
267
  };
@@ -283,7 +307,6 @@ export declare namespace API {
283
307
  cvv: string;
284
308
  expiry_month: number;
285
309
  expiry_year: number;
286
- security_code?: string | null;
287
310
  }
288
311
  interface OTP {
289
312
  created_at: number;
@@ -300,34 +323,41 @@ export declare namespace API {
300
323
  interval: string;
301
324
  };
302
325
  namespace Create {
303
- interface CommonRequest {
326
+ interface StandAloneRequest {
327
+ authorization_controls: AuthorizationControls;
328
+ nick_name: string;
329
+ purpose?: string;
330
+ request_id: string;
331
+ program_id: string;
332
+ wallet_id: string;
333
+ }
334
+ interface FiatAccountRequest {
335
+ sub_account_id: string;
304
336
  program_id: string;
305
337
  request_id: string;
306
338
  nick_name: string;
307
339
  wallet_id: string;
308
- initial_topup?: number;
309
- currency_id?: string;
310
340
  }
311
- interface StandAloneRequest extends CommonRequest {
312
- authorization_controls: AuthorizationControls;
313
- transaction_limits: TransactionLimit[];
314
- purpose?: string;
341
+ type StandAloneResponse = IssuingCardDetailItem;
342
+ type FiatAccountResponse = IssuingCardDetailItem;
343
+ }
344
+ }
345
+ namespace Common {
346
+ namespace Pagination {
347
+ interface Request {
348
+ limit: number;
349
+ offset: number;
315
350
  }
316
- interface FiatAccountRequest extends CommonRequest {
317
- sub_account_id: string;
351
+ }
352
+ namespace Sorting {
353
+ interface Request<T> {
354
+ sort_by?: keyof Partial<T>;
355
+ sort_order?: SortingDirection;
318
356
  }
319
- type StandAloneResponse = CardDetailItem;
320
- type FiatAccountResponse = CardDetailItem;
321
357
  }
322
- namespace Update {
323
- interface DeprecatedRequest {
324
- status: string;
325
- cardName: string;
326
- limits: Limits;
327
- autoTopUp: {
328
- thresholdAmount: number;
329
- topUpAmount: number;
330
- };
358
+ namespace Filtering {
359
+ interface Request<T> {
360
+ filter: Partial<Record<keyof T, any>>[];
331
361
  }
332
362
  }
333
363
  }
@@ -147,3 +147,7 @@ export declare enum APIKeyRole {
147
147
  DEVELOPER = "DEVELOPER",
148
148
  PRODUCTION = "PRODUCTION"
149
149
  }
150
+ export declare enum SortingDirection {
151
+ ASC = "ASC",
152
+ DESC = "DESC"
153
+ }
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.APIKeyRole = exports.OrderType = exports.CurrencyType = exports.SubAccountType = exports.FiatAccountStatus = exports.CardStatus = exports.OrderStatuses = exports.KYCStatuses = exports.defaultPaginationParams = exports.walletType = exports.WalletTypeValues = exports.ResponseStatus = exports.RequestLoadingType = exports.RequestStatus = exports.WalletTransactionRecordType = exports.WalletTransactionMethod = exports.WalletTransactionType = exports.CardTransactionType = exports.CardType = exports.CardFormFactor = exports.AppEnviroment = exports.falsyValues = void 0;
3
+ exports.SortingDirection = exports.APIKeyRole = exports.OrderType = exports.CurrencyType = exports.SubAccountType = exports.FiatAccountStatus = exports.CardStatus = exports.OrderStatuses = exports.KYCStatuses = exports.defaultPaginationParams = exports.walletType = exports.WalletTypeValues = exports.ResponseStatus = exports.RequestLoadingType = exports.RequestStatus = exports.WalletTransactionRecordType = exports.WalletTransactionMethod = exports.WalletTransactionType = exports.CardTransactionType = exports.CardType = exports.CardFormFactor = exports.AppEnviroment = exports.falsyValues = void 0;
4
4
  exports.falsyValues = ['false', '0', '', 'FALSE', false, null, undefined, NaN, 0];
5
5
  var AppEnviroment;
6
6
  (function (AppEnviroment) {
@@ -170,3 +170,8 @@ var APIKeyRole;
170
170
  APIKeyRole["DEVELOPER"] = "DEVELOPER";
171
171
  APIKeyRole["PRODUCTION"] = "PRODUCTION";
172
172
  })(APIKeyRole || (exports.APIKeyRole = APIKeyRole = {}));
173
+ var SortingDirection;
174
+ (function (SortingDirection) {
175
+ SortingDirection["ASC"] = "ASC";
176
+ SortingDirection["DESC"] = "DESC";
177
+ })(SortingDirection || (exports.SortingDirection = SortingDirection = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarefi-bff-api-module",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Squarefi BFF API client module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/api/auth.ts CHANGED
@@ -32,13 +32,13 @@ export const auth = {
32
32
  email: string,
33
33
  password: string // check on backend V2
34
34
  ) =>
35
- apiClientV2.postRequest<API.Auth.SupabaseGetSessionResponse>('/auth/sign-in/password', {
35
+ apiClientV2.postRequest<API.Auth.SupabaseGetSessionResponse>('/auth/sign-in/password/email', {
36
36
  data: { email, password },
37
37
  }),
38
38
  },
39
39
  signup: {
40
40
  password: (email: string, password: string) =>
41
- apiClientV2.postRequest<API.Auth.SupabaseGetSessionResponse>('/auth/sign-up/password', {
41
+ apiClientV2.postRequest<API.Auth.SupabaseGetSessionResponse>('/auth/sign-up/password/email', {
42
42
  data: { email, password },
43
43
  }),
44
44
  telegram: (data: API.Auth.Telegram.Signup) => apiClientV2.postRequest(telegramSignUpPath, { data }),
@@ -1,4 +1,3 @@
1
- import { fiat_accounts } from './fiat_accounts';
2
1
  import { API } from './types';
3
2
 
4
3
  import { apiClientV1 } from '../utils/apiClientFactory';
@@ -13,20 +12,17 @@ export const issuing = {
13
12
  fiatAccountCard: (data: API.Cards.Create.FiatAccountRequest) =>
14
13
  apiClientV1.postRequest<API.Cards.Create.FiatAccountResponse>('/issuing/cards/balance', { data }),
15
14
  },
16
- getByWalletUuid: (params: API.Cards.CardsList.Request.ByWalletUuid) =>
17
- apiClientV1.getRequest<API.Cards.CardsList.Response>('/issuing/cards', { params }),
18
- getByFiatAccountAndWalletId: (params: API.Cards.CardsList.Request.ByFiatAccountAndWalletId) =>
19
- apiClientV1.getRequest<API.Cards.CardsList.Response>('/issuing/cards', { params }),
20
- getById: async (card_id: string): Promise<API.Cards.CardDetailItem> => {
21
- const card = await apiClientV1.getRequest<API.Cards.CardDetailItem>(`/issuing/cards/${card_id}`);
22
- const fiatAccountData = await fiat_accounts.getByUuid(card.fiat_account.id);
23
-
24
- // const { data: fiatAccountData } = await fiat_accounts.getByUuid({ V2 API FIAT ACCOUNTS
25
- // wallet_uuid: card.fiat_account.wallet_id,
26
- // fiat_account_id: card.fiat_account.id,
27
- // });
28
- return { ...card, fiat_account: { ...fiatAccountData, type: card.fiat_account.type } };
15
+ byWalletUuid: {
16
+ getAll: (params: API.Cards.CardsList.Request.ByWalletUuid) =>
17
+ apiClientV1.getRequest<API.Cards.CardsList.Response>('/issuing/cards', { params }),
18
+ getBySubaccountType: (params: API.Cards.CardsList.Request.BySubaccountAndWalletUuid) =>
19
+ apiClientV1.getRequest<API.Cards.CardsList.Response>('/issuing/cards', {
20
+ params,
21
+ }),
22
+ getByFiatAccount: (params: API.Cards.CardsList.Request.ByFiatAccountAndWalletId) =>
23
+ apiClientV1.getRequest<API.Cards.CardsList.Response>('/issuing/cards', { params }),
29
24
  },
25
+ getById: (card_id: string) => apiClientV1.getRequest<API.Cards.IssuingCardDetailItem>(`/issuing/cards/${card_id}`),
30
26
  sensitiveData: {
31
27
  get: (card_id: string) => apiClientV1.getRequest<API.Cards.SensitiveData>(`/issuing/cards/${card_id}/sensitive`),
32
28
  otp: {
@@ -34,10 +30,19 @@ export const issuing = {
34
30
  get: (card_id: string) => apiClientV1.getRequest<API.Cards.OTP>(`/vcards/cards/${card_id}/sensitive/otp`),
35
31
  },
36
32
  },
37
- close: (card_id: string) => apiClientV1.deleteRequest(`/issuing/cards/${card_id}`),
38
- freeze: (card_id: string) => apiClientV1.patchRequest<API.Cards.CardDetailItem>(`/issuing/cards/${card_id}/freeze`),
33
+ freeze: (card_id: string) =>
34
+ apiClientV1.patchRequest<API.Cards.IssuingCardDetailItem>(`/issuing/cards/${card_id}/freeze`),
39
35
  unfreeze: (card_id: string) =>
40
- apiClientV1.patchRequest<API.Cards.CardDetailItem>(`/issuing/cards/${card_id}/unfreeze`),
36
+ apiClientV1.patchRequest<API.Cards.IssuingCardDetailItem>(`/issuing/cards/${card_id}/unfreeze`),
37
+ close: (card_id: string) => apiClientV1.deleteRequest(`/issuing/cards/${card_id}`),
38
+ limits: {
39
+ update: (card_id: string, data: API.Cards.Limits.UpdateRequest) =>
40
+ apiClientV1.patchRequest<API.Cards.IssuingCardDetailItem>(`/issuing/cards/${card_id}/limits`, { data }),
41
+ },
42
+ rename: (card_id: string, nick_name: string) =>
43
+ apiClientV1.patchRequest<API.Cards.IssuingCardDetailItem>(`/issuing/cards/${card_id}/update`, {
44
+ data: { nick_name, request_id: crypto.randomUUID() },
45
+ }),
41
46
  },
42
47
  transactions: {
43
48
  getByCardId: (card_id: string, limit = defaultPaginationParams.limit, offset = defaultPaginationParams.offset) =>
@@ -55,7 +60,8 @@ export const issuing = {
55
60
  },
56
61
  config: {
57
62
  programs: {
58
- getAll: () => apiClientV1.getRequest<API.Issuing.Programs.Response>('/issuing/config/programs'),
63
+ getAll: () =>
64
+ apiClientV1.getRequest<API.Issuing.Programs.Response>('/issuing/config/programs').then(({ data }) => data),
59
65
  },
60
66
  },
61
67
  };
package/src/api/types.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  KYCStatuses,
9
9
  OrderStatuses,
10
10
  OrderType,
11
+ SortingDirection,
11
12
  SubAccountType,
12
13
  WalletTransactionMethod,
13
14
  WalletTransactionRecordType,
@@ -125,9 +126,6 @@ export namespace API {
125
126
  id: string;
126
127
  account_currency: string;
127
128
  brand: string;
128
- card_issuing_fee: number | null;
129
- card_monthly_fee: number | null;
130
- initial_topup: number | null;
131
129
  form_factor: CardFormFactor | string;
132
130
  name: string;
133
131
  card_limit: number;
@@ -171,62 +169,58 @@ export namespace API {
171
169
  };
172
170
  }
173
171
 
174
- export interface Limit {
175
- interval?: string;
176
- amount: number;
177
- }
178
-
179
- export interface Limits {
180
- single: Limit;
181
- daily: Limit;
182
- weekly: Limit;
183
- monthly: Limit;
184
- lifetime: Limit;
172
+ export namespace Limits {
173
+ export interface Limits {
174
+ all_time_enabled: boolean;
175
+ all_time_cap: number;
176
+ all_time_spent: number;
177
+ daily_enabled: boolean;
178
+ daily_cap: number;
179
+ daily_spent: number;
180
+ weekly_enabled: boolean;
181
+ weekly_cap: number;
182
+ weekly_spent: number;
183
+ monthly_enabled: boolean;
184
+ monthly_cap: number;
185
+ monthly_spent: number;
186
+ yearly_enabled: boolean;
187
+ yearly_cap: number;
188
+ yearly_spent: number;
189
+ per_transaction_enabled: boolean;
190
+ per_transaction_cap: number;
191
+ per_transaction_spent: number;
192
+ }
193
+ export interface UpdateRequest {
194
+ all_time_cap?: number;
195
+ daily_cap?: number;
196
+ weekly_cap?: number;
197
+ monthly_cap?: number;
198
+ yearly_cap?: number;
199
+ per_transaction_cap?: number;
200
+ }
185
201
  }
186
202
 
187
- export interface CardDetailItem {
203
+ export interface IssuingCardListItem {
188
204
  brand: string;
189
205
  card_id: string;
190
- // card_number: string;
191
- last4: string;
192
- card_status: CardStatus | string;
193
- form_factor: string;
194
- name_on_card: string;
195
- nick_name: string;
196
- program_id: string;
206
+ card_status: string;
207
+ created_at: string;
208
+ nick_name: string | null;
197
209
  wallet_id: string;
198
- type: CardType | string;
199
- transaction_limits: {
200
- amount: number;
201
- interval: string;
202
- }[];
203
- authorization_controls: {
204
- id: string;
205
- card_id: string;
206
- allowed_transaction_count: string;
207
- allowed_merchant_categories: string | null;
208
- };
210
+ program_id: string;
211
+
209
212
  fiat_account: {
210
213
  id: string;
211
- currency: API.Currencies.FiatCurrency;
212
214
  type: SubAccountType | string;
215
+ status: string;
213
216
  balance: number;
217
+ currency: API.Currencies.Currency;
214
218
  nick_name: string;
215
219
  wallet_id: string;
216
220
  created_at: string;
217
- payment_types: Array<{ order_type: OrderType }>;
218
- account_details?: API.FiatAccounts.FiatAccountDetails;
221
+ program_id: string;
222
+ account_currency: string;
219
223
  };
220
- }
221
- export interface IssuingCardListItem {
222
- brand: string;
223
- card_id: string;
224
- card_status: string;
225
- created_at: string;
226
- nick_name: string | null;
227
- wallet_id: string;
228
- program_id: string;
229
- fiat_account: API.FiatAccounts.FiatAccount;
230
224
  last4: string;
231
225
  request_id: string;
232
226
  name_on_card: string | null;
@@ -235,6 +229,34 @@ export namespace API {
235
229
  tokenizable: boolean;
236
230
  }
237
231
 
232
+ export interface IssuingCardDetailItem {
233
+ id: string;
234
+ brand: string;
235
+ card_id: string;
236
+ fiat_account: {
237
+ id: string;
238
+ type: string;
239
+ status: string;
240
+ balance: number;
241
+ currency: API.Currencies.Currency;
242
+ nick_name: string | null;
243
+ wallet_id: string;
244
+ created_at: string;
245
+ program_id: string;
246
+ account_currency: string;
247
+ };
248
+ last4: string;
249
+ card_status: string;
250
+ form_factor: string;
251
+ name_on_card: string | null;
252
+ nick_name: string;
253
+ wallet_id: string;
254
+ type: string;
255
+ tokenizable: boolean;
256
+ issuing_programs: API.Cards.Config.Program;
257
+ limits: API.Cards.Limits.Limits;
258
+ }
259
+
238
260
  export interface FiatAccountCardListItem {
239
261
  type: string;
240
262
  brand: string;
@@ -246,7 +268,7 @@ export namespace API {
246
268
  created_at: string;
247
269
  program_id: string;
248
270
  request_id: string;
249
- // card_number: string;
271
+ card_number: string;
250
272
  card_status: string;
251
273
  expiry_year: number;
252
274
  form_factor: string;
@@ -258,11 +280,22 @@ export namespace API {
258
280
 
259
281
  export namespace CardsList {
260
282
  export namespace Request {
261
- export type ByWalletUuid = {
283
+ export type CardsListSortingFields = Partial<
284
+ Pick<IssuingCardListItem, 'created_at' | 'card_status' | 'last4' | 'nick_name' | 'name_on_card' | 'card_id'>
285
+ >;
286
+ export type CardsListFilteringFields = Partial<IssuingCardListItem>;
287
+
288
+ export type CardsListRequestCommonParams = API.Common.Pagination.Request &
289
+ API.Common.Sorting.Request<CardsListSortingFields> &
290
+ API.Common.Filtering.Request<CardsListFilteringFields>;
291
+
292
+ export interface ByWalletUuid extends CardsListRequestCommonParams {
262
293
  wallet_uuid: string;
263
- limit: number;
264
- offset: number;
265
- };
294
+ }
295
+
296
+ export interface BySubaccountAndWalletUuid extends ByWalletUuid {
297
+ filter: Array<Partial<Record<'fiat_account', Record<'type', SubAccountType>>>>;
298
+ }
266
299
 
267
300
  export type ByFiatAccountAndWalletId = ByWalletUuid & {
268
301
  fiat_account_id: string;
@@ -313,7 +346,6 @@ export namespace API {
313
346
  cvv: string;
314
347
  expiry_month: number;
315
348
  expiry_year: number;
316
- security_code?: string | null;
317
349
  }
318
350
 
319
351
  export interface OTP {
@@ -334,37 +366,48 @@ export namespace API {
334
366
  };
335
367
 
336
368
  export namespace Create {
337
- export interface CommonRequest {
369
+ export interface StandAloneRequest {
370
+ authorization_controls: AuthorizationControls;
371
+
372
+ // name_on_card: string; hide cardholder name
373
+ nick_name: string;
374
+ purpose?: string;
375
+ request_id: string;
376
+ program_id: string;
377
+ wallet_id: string;
378
+ }
379
+
380
+ export interface FiatAccountRequest {
381
+ sub_account_id: string;
338
382
  program_id: string;
339
383
  request_id: string;
340
384
  nick_name: string;
341
385
  wallet_id: string;
342
- initial_topup?: number;
343
- currency_id?: string;
344
- }
345
- export interface StandAloneRequest extends CommonRequest {
346
- authorization_controls: AuthorizationControls;
347
- transaction_limits: TransactionLimit[];
348
- purpose?: string;
349
386
  }
350
387
 
351
- export interface FiatAccountRequest extends CommonRequest {
352
- sub_account_id: string;
388
+ export type StandAloneResponse = IssuingCardDetailItem;
389
+ export type FiatAccountResponse = IssuingCardDetailItem;
390
+ }
391
+ }
392
+
393
+ export namespace Common {
394
+ export namespace Pagination {
395
+ export interface Request {
396
+ limit: number;
397
+ offset: number;
353
398
  }
399
+ }
354
400
 
355
- export type StandAloneResponse = CardDetailItem;
356
- export type FiatAccountResponse = CardDetailItem;
401
+ export namespace Sorting {
402
+ export interface Request<T> {
403
+ sort_by?: keyof Partial<T>;
404
+ sort_order?: SortingDirection;
405
+ }
357
406
  }
358
407
 
359
- export namespace Update {
360
- export interface DeprecatedRequest {
361
- status: string;
362
- cardName: string;
363
- limits: Limits;
364
- autoTopUp: {
365
- thresholdAmount: number;
366
- topUpAmount: number;
367
- };
408
+ export namespace Filtering {
409
+ export interface Request<T> {
410
+ filter: Partial<Record<keyof T, any>>[];
368
411
  }
369
412
  }
370
413
  }
package/src/constants.ts CHANGED
@@ -178,3 +178,8 @@ export enum APIKeyRole {
178
178
  DEVELOPER = 'DEVELOPER',
179
179
  PRODUCTION = 'PRODUCTION',
180
180
  }
181
+
182
+ export enum SortingDirection {
183
+ ASC = 'ASC',
184
+ DESC = 'DESC',
185
+ }