squarefi-bff-api-module 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/README.md +36 -0
- package/dist/api/auth.d.ts +27 -0
- package/dist/api/auth.js +38 -0
- package/dist/api/config.d.ts +37 -0
- package/dist/api/config.js +40 -0
- package/dist/api/developer.d.ts +12 -0
- package/dist/api/developer.js +15 -0
- package/dist/api/exchange.d.ts +35 -0
- package/dist/api/exchange.js +27 -0
- package/dist/api/fetch_api.d.ts +1 -0
- package/dist/api/fetch_api.js +122 -0
- package/dist/api/fiat_accounts.d.ts +32 -0
- package/dist/api/fiat_accounts.js +51 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/api/index.js +17 -0
- package/dist/api/issuing.d.ts +31 -0
- package/dist/api/issuing.js +68 -0
- package/dist/api/kyc.d.ts +6 -0
- package/dist/api/kyc.js +9 -0
- package/dist/api/list.d.ts +10 -0
- package/dist/api/list.js +13 -0
- package/dist/api/orders.d.ts +12 -0
- package/dist/api/orders.js +34 -0
- package/dist/api/types.d.ts +945 -0
- package/dist/api/types.js +2 -0
- package/dist/api/user.d.ts +18 -0
- package/dist/api/user.js +21 -0
- package/dist/api/wallets.d.ts +18 -0
- package/dist/api/wallets.js +42 -0
- package/dist/constants.d.ts +149 -0
- package/dist/constants.js +172 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +22 -0
- package/dist/utils/apiClientFactory.d.ts +13 -0
- package/dist/utils/apiClientFactory.js +132 -0
- package/dist/utils/storage.d.ts +3 -0
- package/dist/utils/storage.js +30 -0
- package/dist/utils/tokensFactory.d.ts +12 -0
- package/dist/utils/tokensFactory.js +53 -0
- package/package.json +35 -0
- package/src/api/auth.ts +50 -0
- package/src/api/developer.ts +18 -0
- package/src/api/exchange.ts +32 -0
- package/src/api/fiat_accounts.ts +69 -0
- package/src/api/index.ts +16 -0
- package/src/api/issuing.ts +66 -0
- package/src/api/kyc.ts +10 -0
- package/src/api/list.ts +18 -0
- package/src/api/orders.ts +32 -0
- package/src/api/types.ts +1141 -0
- package/src/api/user.ts +24 -0
- package/src/api/wallets.ts +39 -0
- package/src/constants.ts +180 -0
- package/src/index.ts +7 -0
- package/src/utils/apiClientFactory.ts +154 -0
- package/src/utils/storage.ts +29 -0
- package/src/utils/tokensFactory.ts +50 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.setTokens = setTokens;
|
|
13
|
+
exports.deleteTokens = deleteTokens;
|
|
14
|
+
exports.refreshTokens = refreshTokens;
|
|
15
|
+
exports.getTokens = getTokens;
|
|
16
|
+
const sdk_react_1 = require("@telegram-apps/sdk-react");
|
|
17
|
+
const storage_1 = require("./storage");
|
|
18
|
+
const auth_1 = require("../api/auth");
|
|
19
|
+
function setTokens({ access_token, refresh_token }) {
|
|
20
|
+
access_token && (0, storage_1.setToLocalStorage)('access_token', access_token);
|
|
21
|
+
refresh_token && (0, storage_1.setToLocalStorage)('refresh_token', refresh_token);
|
|
22
|
+
}
|
|
23
|
+
function deleteTokens() {
|
|
24
|
+
(0, storage_1.deleteFromLocalStorage)('access_token');
|
|
25
|
+
(0, storage_1.deleteFromLocalStorage)('refresh_token');
|
|
26
|
+
}
|
|
27
|
+
function refreshTokens() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const refreshToken = (0, storage_1.getFromLocalStorage)('refresh_token');
|
|
30
|
+
if (!refreshToken && !(0, sdk_react_1.isTMA)()) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const refreshHandler = () => {
|
|
34
|
+
var _a;
|
|
35
|
+
return (0, sdk_react_1.isTMA)()
|
|
36
|
+
? auth_1.auth.signin.telegram({
|
|
37
|
+
tg_id: (_a = sdk_react_1.initData.user()) === null || _a === void 0 ? void 0 : _a.id,
|
|
38
|
+
hash: sdk_react_1.initData.hash(),
|
|
39
|
+
init_data_raw: sdk_react_1.initData.raw(),
|
|
40
|
+
})
|
|
41
|
+
: auth_1.auth.refresh.refresh_token(refreshToken);
|
|
42
|
+
};
|
|
43
|
+
const { data } = yield refreshHandler();
|
|
44
|
+
setTokens(data);
|
|
45
|
+
return data;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function getTokens() {
|
|
49
|
+
return {
|
|
50
|
+
access_token: (0, storage_1.getFromLocalStorage)('access_token'),
|
|
51
|
+
refresh_token: (0, storage_1.getFromLocalStorage)('refresh_token'),
|
|
52
|
+
};
|
|
53
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "squarefi-bff-api-module",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Squarefi BFF API client module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepare": "npm run build",
|
|
10
|
+
"test": "jest"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"squarefi",
|
|
14
|
+
"api",
|
|
15
|
+
"client",
|
|
16
|
+
"typescript"
|
|
17
|
+
],
|
|
18
|
+
"author": "Your Name",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"axios": "1.6.7",
|
|
22
|
+
"@telegram-apps/sdk-react": "3.1.2",
|
|
23
|
+
"react-icons": "5.0.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^20.x.x",
|
|
27
|
+
"typescript": "^5.x.x",
|
|
28
|
+
"@types/jest": "^29.x.x",
|
|
29
|
+
"jest": "^29.x.x",
|
|
30
|
+
"ts-jest": "^29.x.x"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": "^18.x.x"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/api/auth.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { API } from './types';
|
|
2
|
+
|
|
3
|
+
import { apiClientV2 } from '.';
|
|
4
|
+
|
|
5
|
+
export const telegramSignInPath = '/auth/sign-in/telegram';
|
|
6
|
+
export const telegramSignUpPath = '/auth/sign-up/telegram';
|
|
7
|
+
export const refreshTokenPath = '/auth/refresh/refresh-token';
|
|
8
|
+
|
|
9
|
+
export const auth = {
|
|
10
|
+
otp: {
|
|
11
|
+
verify: {
|
|
12
|
+
email: (email: string, token: string) =>
|
|
13
|
+
apiClientV2.postRequest<API.Auth.VerifyOtp.Response>('/auth/verify/email/otp', {
|
|
14
|
+
data: { email, token, type: 'email' },
|
|
15
|
+
}),
|
|
16
|
+
phone: (phone: string, token: string) =>
|
|
17
|
+
apiClientV2.postRequest<API.Auth.VerifyOtp.Response>('/auth/verify/phone/otp', {
|
|
18
|
+
data: { phone, token, type: 'sms' },
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
signin: {
|
|
23
|
+
omni: {
|
|
24
|
+
email: (data: API.Auth.SignIn.Email.OTP.Request) =>
|
|
25
|
+
apiClientV2.postRequest('/auth/sign-in/omni/email/otp', { data }),
|
|
26
|
+
phone: (data: API.Auth.SignIn.Phone.OTP.Request) =>
|
|
27
|
+
apiClientV2.postRequest('/auth/sign-in/omni/phone/otp', { data }),
|
|
28
|
+
},
|
|
29
|
+
telegram: (data: API.Auth.Telegram.Signin) =>
|
|
30
|
+
apiClientV2.postRequest<API.Auth.Tokens>(telegramSignInPath, { data }),
|
|
31
|
+
password: (
|
|
32
|
+
email: string,
|
|
33
|
+
password: string, // check on backend V2
|
|
34
|
+
) =>
|
|
35
|
+
apiClientV2.postRequest<API.Auth.SupabaseGetSessionResponse>('/auth/sign-in/password', {
|
|
36
|
+
data: { email, password },
|
|
37
|
+
}),
|
|
38
|
+
},
|
|
39
|
+
signup: {
|
|
40
|
+
password: (email: string, password: string) =>
|
|
41
|
+
apiClientV2.postRequest<API.Auth.SupabaseGetSessionResponse>('/auth/sign-up/password', {
|
|
42
|
+
data: { email, password },
|
|
43
|
+
}),
|
|
44
|
+
telegram: (data: API.Auth.Telegram.Signup) => apiClientV2.postRequest(telegramSignUpPath, { data }),
|
|
45
|
+
},
|
|
46
|
+
refresh: {
|
|
47
|
+
refresh_token: (refresh_token: string) =>
|
|
48
|
+
apiClientV2.postRequest<API.Auth.Tokens>(refreshTokenPath, { data: { refresh_token } }),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { API } from './types';
|
|
2
|
+
|
|
3
|
+
import { apiClientV1 } from '.';
|
|
4
|
+
|
|
5
|
+
export const developer = {
|
|
6
|
+
apiKeys: {
|
|
7
|
+
getAll: () => apiClientV1.getRequest<API.Developer.ApiCode.ApiCode[]>('/developer/access/list'),
|
|
8
|
+
create: (data: API.Developer.ApiCode.Create.Request) =>
|
|
9
|
+
apiClientV1.postRequest<API.Developer.ApiCode.Create.Response>('/developer/access/create', { data }),
|
|
10
|
+
rotate: (data: API.Developer.ApiCode.Rotate.Request) =>
|
|
11
|
+
apiClientV1.postRequest<API.Developer.ApiCode.Rotate.Response>(`/developer/access/rotate`, { data }),
|
|
12
|
+
update: (data: API.Developer.ApiCode.Update.Request) =>
|
|
13
|
+
apiClientV1.postRequest(`/developer/access/update`, { data }),
|
|
14
|
+
},
|
|
15
|
+
vendors: {
|
|
16
|
+
list: () => apiClientV1.getRequest<API.Developer.Vendors.Vendor[]>('/developer/vendors/list'),
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { API } from './types';
|
|
2
|
+
|
|
3
|
+
import { apiClientV1 } from '.';
|
|
4
|
+
|
|
5
|
+
import { OrderType } from '../constants';
|
|
6
|
+
|
|
7
|
+
const createOrderTypeMethods = (orderType: OrderType) => ({
|
|
8
|
+
getByFromCurrency: (from_uuid: string) =>
|
|
9
|
+
apiClientV1
|
|
10
|
+
.getRequest<API.Exchange.Exchange[]>('/exchange/', { params: { from_uuid, order_type: orderType } })
|
|
11
|
+
.then(({ data }) => data),
|
|
12
|
+
getByToCurrency: (to_uuid: string) =>
|
|
13
|
+
apiClientV1
|
|
14
|
+
.getRequest<API.Exchange.Exchange[]>('/exchange/', { params: { to_uuid, order_type: orderType } })
|
|
15
|
+
.then(({ data }) => data),
|
|
16
|
+
getByOrderType: () =>
|
|
17
|
+
apiClientV1
|
|
18
|
+
.getRequest<API.Exchange.Exchange[]>('/exchange/', { params: { order_type: orderType } })
|
|
19
|
+
.then(({ data }) => data),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const exchange = {
|
|
23
|
+
byOrderType: {
|
|
24
|
+
[OrderType.DEPOSIT_FIAT_SEPA]: createOrderTypeMethods(OrderType.DEPOSIT_FIAT_SEPA),
|
|
25
|
+
[OrderType.DEPOSIT_FIAT_SWIFT]: createOrderTypeMethods(OrderType.DEPOSIT_FIAT_SWIFT),
|
|
26
|
+
[OrderType.WITHDRAWAL_FIAT_SEPA]: createOrderTypeMethods(OrderType.WITHDRAWAL_FIAT_SEPA),
|
|
27
|
+
// [OrderType.TRANSFER_CARD_PREPAID]: createOrderTypeMethods(OrderType.TRANSFER_CARD_PREPAID), // DO not used
|
|
28
|
+
[OrderType.TRANSFER_CARD_SUBACCOUNT]: createOrderTypeMethods(OrderType.TRANSFER_CARD_SUBACCOUNT),
|
|
29
|
+
[OrderType.WITHDRAWAL_CRYPTO]: createOrderTypeMethods(OrderType.WITHDRAWAL_CRYPTO),
|
|
30
|
+
[OrderType.EXCHANGE_CRYPTO_INTERNAL]: createOrderTypeMethods(OrderType.EXCHANGE_CRYPTO_INTERNAL),
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { API } from './types';
|
|
2
|
+
|
|
3
|
+
import { apiClientV2, apiClientV1 } from '.';
|
|
4
|
+
|
|
5
|
+
export const fiat_accounts_v2 = {
|
|
6
|
+
list: {
|
|
7
|
+
withCards: {
|
|
8
|
+
getAll: (wallet_uuid: string, limit: number, offset: number) =>
|
|
9
|
+
apiClientV2.getRequest<API.FiatAccountsV2.FiatAccountsListWithCards>(`/fiat-accounts/${wallet_uuid}`, {
|
|
10
|
+
params: { limit, offset, show_cards: true },
|
|
11
|
+
}),
|
|
12
|
+
},
|
|
13
|
+
withoutCards: {
|
|
14
|
+
getAll: (wallet_uuid: string, limit: number, offset: number) =>
|
|
15
|
+
apiClientV2.getRequest<API.FiatAccountsV2.FiatAccountsListWithoutCards>(`/fiat-accounts/${wallet_uuid}`, {
|
|
16
|
+
params: { limit, offset },
|
|
17
|
+
}),
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
getByUuid: ({ wallet_uuid, fiat_account_id }: API.FiatAccountsV2.ExtendedFiatAccount.Request) =>
|
|
22
|
+
apiClientV2.getRequest<API.FiatAccountsV2.ExtendedFiatAccount.Response>(
|
|
23
|
+
`/fiat-accounts/${wallet_uuid}/${fiat_account_id}`,
|
|
24
|
+
),
|
|
25
|
+
create: ({ wallet_id, program_id }: API.FiatAccountsV2.CreateFiatAccount.Request) =>
|
|
26
|
+
apiClientV2.postRequest<API.FiatAccountsV2.CreateFiatAccount.Response>(`/fiat-accounts/${wallet_id}`, {
|
|
27
|
+
data: { program_id },
|
|
28
|
+
}),
|
|
29
|
+
transactions: {
|
|
30
|
+
get: ({ fiat_account_id, wallet_uuid, limit, offset }: API.FiatAccountsV2.Transactions.TransactionList.Request) =>
|
|
31
|
+
apiClientV2.getRequest<API.FiatAccountsV2.Transactions.TransactionList.Response>(
|
|
32
|
+
`/fiat-accounts/${wallet_uuid}/${fiat_account_id}/transactions`,
|
|
33
|
+
{
|
|
34
|
+
params: { limit, offset },
|
|
35
|
+
},
|
|
36
|
+
),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const fiat_accounts = {
|
|
41
|
+
list: {
|
|
42
|
+
withCards: {
|
|
43
|
+
getSinglecards: (wallet_uuid: string, limit: number, offset: number) =>
|
|
44
|
+
apiClientV1.getRequest<API.FiatAccounts.FiatAccountWithCards[]>(`/fiat_accounts/list/${wallet_uuid}`, {
|
|
45
|
+
params: { limit, offset, lt_cards_limit: 2, gt_cards_limit: 0, show_cards: true },
|
|
46
|
+
}),
|
|
47
|
+
getAll: (wallet_uuid: string, limit: number, offset: number) =>
|
|
48
|
+
apiClientV1.getRequest<API.FiatAccounts.FiatAccountWithCards[]>(`/fiat_accounts/list/${wallet_uuid}`, {
|
|
49
|
+
params: { limit, offset, show_cards: true },
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
withoutCards: {
|
|
53
|
+
getAll: (wallet_uuid: string, limit: number, offset: number) =>
|
|
54
|
+
apiClientV1.getRequest<API.FiatAccounts.FiatAccount[]>(`/fiat_accounts/list/${wallet_uuid}`, {
|
|
55
|
+
params: { limit, offset },
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
getByUuid: (uuid: string) => apiClientV1.getRequest<API.FiatAccounts.FiatAccount>(`/fiat_accounts/${uuid}`),
|
|
61
|
+
create: (wallet_id: string, program_id: string) =>
|
|
62
|
+
apiClientV1.postRequest<API.FiatAccounts.FiatAccount>(`/fiat_accounts`, { data: { wallet_id, program_id } }),
|
|
63
|
+
transactions: {
|
|
64
|
+
get: (fiat_account_id: string, limit?: number, offset?: number) =>
|
|
65
|
+
apiClientV1.getRequest<API.FiatAccounts.TransactionList>(`/fiat_accounts/${fiat_account_id}/transactions`, {
|
|
66
|
+
params: { limit, offset },
|
|
67
|
+
}),
|
|
68
|
+
},
|
|
69
|
+
};
|
package/src/api/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createApiClient } from '../utils/apiClientFactory';
|
|
2
|
+
|
|
3
|
+
const apiV1BaseURL = process.env.API_URL ?? 'ENV variable API_URL is not defined';
|
|
4
|
+
const apiV2BaseURL = process.env.API_V2_URL ?? 'ENV variable API_V2_URL is not defined';
|
|
5
|
+
const envTenantId = process.env.TENANT_ID ?? 'ENV variable TENANT_ID is not defined';
|
|
6
|
+
|
|
7
|
+
export const apiClientV1 = createApiClient({
|
|
8
|
+
baseURL: apiV1BaseURL,
|
|
9
|
+
tenantId: envTenantId,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const apiClientV2 = createApiClient({
|
|
13
|
+
baseURL: apiV2BaseURL,
|
|
14
|
+
isBearerToken: true,
|
|
15
|
+
tenantId: envTenantId,
|
|
16
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
|
|
3
|
+
import { fiat_accounts } from './fiat_accounts';
|
|
4
|
+
import { API } from './types';
|
|
5
|
+
|
|
6
|
+
import { apiClientV1 } from '.';
|
|
7
|
+
|
|
8
|
+
import { defaultPaginationParams } from '../constants';
|
|
9
|
+
|
|
10
|
+
export const issuing = {
|
|
11
|
+
cards: {
|
|
12
|
+
create: {
|
|
13
|
+
standAloneCard: (data: API.Cards.Create.StandAloneRequest) =>
|
|
14
|
+
apiClientV1.postRequest<API.Cards.Create.StandAloneResponse>('/issuing/cards/create', { data }),
|
|
15
|
+
fiatAccountCard: (data: API.Cards.Create.FiatAccountRequest) =>
|
|
16
|
+
apiClientV1.postRequest<API.Cards.Create.FiatAccountResponse>('/issuing/cards/balance', { data }),
|
|
17
|
+
},
|
|
18
|
+
getByWalletUuid: (params: API.Cards.CardsList.Request.ByWalletUuid) =>
|
|
19
|
+
apiClientV1.getRequest<API.Cards.CardsList.Response>('/issuing/cards', { params }),
|
|
20
|
+
getByFiatAccountAndWalletId: (params: API.Cards.CardsList.Request.ByFiatAccountAndWalletId) =>
|
|
21
|
+
apiClientV1.getRequest<API.Cards.CardsList.Response>('/issuing/cards', { params }),
|
|
22
|
+
getById: async (card_id: string): Promise<AxiosResponse<API.Cards.CardDetailItem, any>> => {
|
|
23
|
+
const { data: card, ...rest } = await apiClientV1.getRequest<API.Cards.CardDetailItem>(
|
|
24
|
+
`/issuing/cards/${card_id}`
|
|
25
|
+
);
|
|
26
|
+
const { data: fiatAccountData } = await fiat_accounts.getByUuid(card.fiat_account.id);
|
|
27
|
+
|
|
28
|
+
// const { data: fiatAccountData } = await fiat_accounts.getByUuid({ V2 API FIAT ACCOUNTS
|
|
29
|
+
// wallet_uuid: card.fiat_account.wallet_id,
|
|
30
|
+
// fiat_account_id: card.fiat_account.id,
|
|
31
|
+
// });
|
|
32
|
+
return { ...rest, data: { ...card, fiat_account: { ...fiatAccountData, type: card.fiat_account.type } } };
|
|
33
|
+
},
|
|
34
|
+
sensitiveData: {
|
|
35
|
+
get: (card_id: string) => apiClientV1.getRequest<API.Cards.SensitiveData>(`/issuing/cards/${card_id}/sensitive`),
|
|
36
|
+
otp: {
|
|
37
|
+
// have to update
|
|
38
|
+
get: (card_id: string) => apiClientV1.getRequest<API.Cards.OTP>(`/vcards/cards/${card_id}/sensitive/otp`),
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
close: (card_id: string) => apiClientV1.deleteRequest(`/issuing/cards/${card_id}`),
|
|
42
|
+
freeze: (card_id: string) => apiClientV1.patchRequest<API.Cards.CardDetailItem>(`/issuing/cards/${card_id}/freeze`),
|
|
43
|
+
unfreeze: (card_id: string) =>
|
|
44
|
+
apiClientV1.patchRequest<API.Cards.CardDetailItem>(`/issuing/cards/${card_id}/unfreeze`),
|
|
45
|
+
},
|
|
46
|
+
transactions: {
|
|
47
|
+
getByCardId: (card_id: string, limit = defaultPaginationParams.limit, offset = defaultPaginationParams.offset) =>
|
|
48
|
+
apiClientV1.getRequest<API.Cards.TransactionsList>(`/issuing/transactions/`, {
|
|
49
|
+
params: { limit, offset, card_id, new_scheme: true },
|
|
50
|
+
}),
|
|
51
|
+
getByFiatAccountId: (
|
|
52
|
+
fiat_account_id: string,
|
|
53
|
+
limit = defaultPaginationParams.limit,
|
|
54
|
+
offset = defaultPaginationParams.offset
|
|
55
|
+
) =>
|
|
56
|
+
apiClientV1.getRequest<API.Cards.TransactionsList>(`/issuing/transactions/`, {
|
|
57
|
+
params: { limit, offset, fiat_account_id, new_scheme: true },
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
config: {
|
|
61
|
+
programs: {
|
|
62
|
+
getAll: () =>
|
|
63
|
+
apiClientV1.getRequest<API.Issuing.Programs.Response>('/issuing/config/programs').then(({ data }) => data),
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
package/src/api/kyc.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { API } from './types';
|
|
2
|
+
|
|
3
|
+
import { apiClientV1 } from '.';
|
|
4
|
+
|
|
5
|
+
export const kyc = {
|
|
6
|
+
sumsub: {
|
|
7
|
+
generate_token: (data: API.KYC.Sumsub.GenerateToken.Request) =>
|
|
8
|
+
apiClientV1.postRequest<API.KYC.Sumsub.GenerateToken.Response>('/kyc/sumsub/generate_token', { data }),
|
|
9
|
+
},
|
|
10
|
+
};
|
package/src/api/list.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
|
|
3
|
+
import { AxiosRequestConfig } from 'axios';
|
|
4
|
+
|
|
5
|
+
import { API } from './types';
|
|
6
|
+
|
|
7
|
+
import { apiClientV2 } from '.';
|
|
8
|
+
|
|
9
|
+
export const list = {
|
|
10
|
+
currencies: {
|
|
11
|
+
getAll: (params?: AxiosRequestConfig) =>
|
|
12
|
+
apiClientV2.getRequest<API.Currencies.CurrencyList>('/currencies', params).then(({ data }) => data),
|
|
13
|
+
},
|
|
14
|
+
chains: {
|
|
15
|
+
getAll: (params?: AxiosRequestConfig) =>
|
|
16
|
+
apiClientV2.getRequest<API.Chains.ChainList>('/chains', params).then(({ data }) => data),
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { API } from './types';
|
|
2
|
+
|
|
3
|
+
import { apiClientV1 } from '.';
|
|
4
|
+
|
|
5
|
+
import { OrderType } from '../constants';
|
|
6
|
+
|
|
7
|
+
export const orders = {
|
|
8
|
+
calc: ({ signal, ...params }: API.Orders.Calc.Request) =>
|
|
9
|
+
apiClientV1.getRequest<API.Orders.Calc.Response>('/orders/calc', { params, signal }).then((res) => res.data),
|
|
10
|
+
create: {
|
|
11
|
+
byOrderType: {
|
|
12
|
+
[OrderType.TRANSFER_CARD_SUBACCOUNT]: (data: API.Orders.Create.ByOrderType.TRANSFER_CARD_SUBACCOUNT.Request) =>
|
|
13
|
+
apiClientV1.postRequest<API.Orders.Create.ByOrderType.TRANSFER_CARD_SUBACCOUNT.Response>(
|
|
14
|
+
'/orders/TRANSFER_CARD_SUBACCOUNT',
|
|
15
|
+
{
|
|
16
|
+
data,
|
|
17
|
+
}
|
|
18
|
+
),
|
|
19
|
+
[OrderType.WITHDRAWAL_CRYPTO]: (data: API.Orders.Create.ByOrderType.WITHDRAWAL_CRYPTO.Request) =>
|
|
20
|
+
apiClientV1.postRequest<API.Orders.Create.ByOrderType.WITHDRAWAL_CRYPTO.Response>('/orders/WITHDRAWAL_CRYPTO', {
|
|
21
|
+
data,
|
|
22
|
+
}),
|
|
23
|
+
[OrderType.EXCHANGE_CRYPTO_INTERNAL]: (data: API.Orders.Create.ByOrderType.EXCHANGE_CRYPTO_INTERNAL.Request) =>
|
|
24
|
+
apiClientV1.postRequest<API.Orders.Create.ByOrderType.EXCHANGE_CRYPTO_INTERNAL.Response>(
|
|
25
|
+
'/orders/EXCHANGE_CRYPTO_INTERNAL',
|
|
26
|
+
{ data }
|
|
27
|
+
),
|
|
28
|
+
[OrderType.TRANSFER_CARD_WHOLESALE]: (data: API.Orders.Create.ByOrderType.TRANSFER_CARD_WHOLESALE.Request) =>
|
|
29
|
+
apiClientV1.postRequest<null>('/orders/TRANSFER_CARD_WHOLESALE', { data }),
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|