ggez-banking-sdk 0.0.4 → 0.0.6
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 +0 -0
- package/dist/bank-system/constants/enum.d.ts +1061 -0
- package/dist/bank-system/constants/enum.js +1115 -0
- package/dist/bank-system/constants/index.d.ts +1 -0
- package/dist/bank-system/constants/index.js +17 -0
- package/dist/bank-system/content/accountCurrencies.d.ts +12 -0
- package/dist/bank-system/content/accountCurrencies.js +37 -0
- package/dist/bank-system/content/countries.d.ts +24 -0
- package/dist/bank-system/content/countries.js +6472 -0
- package/dist/bank-system/content/currencies.d.ts +32 -0
- package/dist/bank-system/content/currencies.js +5836 -0
- package/dist/bank-system/content/index.d.ts +4 -0
- package/dist/bank-system/content/index.js +12 -0
- package/dist/bank-system/content/state.d.ts +6 -0
- package/dist/bank-system/content/state.js +350 -0
- package/dist/bank-system/helper/data.d.ts +46 -0
- package/dist/bank-system/helper/data.js +57 -0
- package/dist/bank-system/helper/dataStructure.d.ts +3220 -0
- package/dist/bank-system/helper/dataStructure.js +1055 -0
- package/dist/bank-system/helper/index.d.ts +28 -0
- package/dist/bank-system/helper/index.js +394 -0
- package/dist/bank-system/interfaces/accountInterface.d.ts +26 -0
- package/dist/bank-system/interfaces/accountInterface.js +2 -0
- package/dist/bank-system/interfaces/bankingSystemInterface.d.ts +306 -0
- package/dist/bank-system/interfaces/bankingSystemInterface.js +2 -0
- package/dist/bank-system/interfaces/deviceInterface.d.ts +34 -0
- package/dist/bank-system/interfaces/deviceInterface.js +2 -0
- package/dist/bank-system/interfaces/index.d.ts +4 -0
- package/dist/bank-system/interfaces/index.js +20 -0
- package/dist/bank-system/interfaces/interface.d.ts +460 -0
- package/dist/bank-system/interfaces/interface.js +2 -0
- package/dist/bank-system/interfaces/organizationInterface.d.ts +118 -0
- package/dist/bank-system/interfaces/organizationInterface.js +2 -0
- package/dist/bank-system/interfaces/signInterface.d.ts +91 -0
- package/dist/bank-system/interfaces/signInterface.js +2 -0
- package/dist/bank-system/interfaces/transactionInterface.d.ts +17 -0
- package/dist/bank-system/interfaces/transactionInterface.js +2 -0
- package/dist/bank-system/restApi/index.d.ts +8 -0
- package/dist/bank-system/restApi/index.js +41 -0
- package/dist/bank-system/services/account.d.ts +33 -0
- package/dist/bank-system/services/account.js +129 -0
- package/dist/bank-system/services/addresses.d.ts +48 -0
- package/dist/bank-system/services/addresses.js +130 -0
- package/dist/bank-system/services/auth.d.ts +71 -0
- package/dist/bank-system/services/auth.js +250 -0
- package/dist/bank-system/services/bankAccount.d.ts +48 -0
- package/dist/bank-system/services/bankAccount.js +131 -0
- package/dist/bank-system/services/device.d.ts +46 -0
- package/dist/bank-system/services/device.js +212 -0
- package/dist/bank-system/services/document.d.ts +15 -0
- package/dist/bank-system/services/document.js +58 -0
- package/dist/bank-system/services/email.d.ts +70 -0
- package/dist/bank-system/services/email.js +175 -0
- package/dist/bank-system/services/history.d.ts +14 -0
- package/dist/bank-system/services/history.js +55 -0
- package/dist/bank-system/services/identification.d.ts +37 -0
- package/dist/bank-system/services/identification.js +107 -0
- package/dist/bank-system/services/index.d.ts +17 -0
- package/dist/bank-system/services/index.js +35 -0
- package/dist/bank-system/services/organization.d.ts +28 -0
- package/dist/bank-system/services/organization.js +129 -0
- package/dist/bank-system/services/personalInfo.d.ts +26 -0
- package/dist/bank-system/services/personalInfo.js +91 -0
- package/dist/bank-system/services/phone.d.ts +70 -0
- package/dist/bank-system/services/phone.js +175 -0
- package/dist/bank-system/services/security.d.ts +114 -0
- package/dist/bank-system/services/security.js +267 -0
- package/dist/bank-system/services/token.d.ts +11 -0
- package/dist/bank-system/services/token.js +83 -0
- package/dist/bank-system/services/transaction.d.ts +9 -0
- package/dist/bank-system/services/transaction.js +62 -0
- package/dist/bank-system/services/verifyAndConfirm.d.ts +116 -0
- package/dist/bank-system/services/verifyAndConfirm.js +308 -0
- package/dist/bank-system/utils/chainAddressMasking.d.ts +2 -0
- package/dist/bank-system/utils/chainAddressMasking.js +12 -0
- package/dist/bank-system/utils/copyText.d.ts +5 -0
- package/dist/bank-system/utils/copyText.js +22 -0
- package/dist/bank-system/utils/countryAndCurrencyData.d.ts +11 -0
- package/dist/bank-system/utils/countryAndCurrencyData.js +22 -0
- package/dist/bank-system/utils/enumToOption.d.ts +4 -0
- package/dist/bank-system/utils/enumToOption.js +18 -0
- package/dist/bank-system/utils/fillDeviceDetails.d.ts +23 -0
- package/dist/bank-system/utils/fillDeviceDetails.js +44 -0
- package/dist/bank-system/utils/generateOneLiner.d.ts +1 -0
- package/dist/bank-system/utils/generateOneLiner.js +16 -0
- package/dist/bank-system/utils/generateSourceId.d.ts +1 -0
- package/dist/bank-system/utils/generateSourceId.js +12 -0
- package/dist/bank-system/utils/getCountryName.d.ts +2 -0
- package/dist/bank-system/utils/getCountryName.js +29 -0
- package/dist/bank-system/utils/getEnumName.d.ts +1 -0
- package/dist/bank-system/utils/getEnumName.js +10 -0
- package/dist/bank-system/utils/getStateByCountryCode.d.ts +1 -0
- package/dist/bank-system/utils/getStateByCountryCode.js +14 -0
- package/dist/bank-system/utils/handleEncryption/decryptData.d.ts +15 -0
- package/dist/bank-system/utils/handleEncryption/decryptData.js +77 -0
- package/dist/bank-system/utils/handleEncryption/encryptData.d.ts +2 -0
- package/dist/bank-system/utils/handleEncryption/encryptData.js +36 -0
- package/dist/bank-system/utils/handleEncryption/index.d.ts +4 -0
- package/dist/bank-system/utils/handleEncryption/index.js +12 -0
- package/dist/bank-system/utils/handleEncryption/key.d.ts +13 -0
- package/dist/bank-system/utils/handleEncryption/key.js +40 -0
- package/dist/bank-system/utils/index.d.ts +15 -0
- package/dist/bank-system/utils/index.js +42 -0
- package/dist/bank-system/utils/info.d.ts +8 -0
- package/dist/bank-system/utils/info.js +79 -0
- package/dist/bank-system/utils/maskingFunction.d.ts +1 -0
- package/dist/bank-system/utils/maskingFunction.js +27 -0
- package/dist/bank-system/utils/regex.d.ts +106 -0
- package/dist/bank-system/utils/regex.js +110 -0
- package/dist/bank-system/utils/sortUserInfo.d.ts +1 -0
- package/dist/bank-system/utils/sortUserInfo.js +42 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +54 -0
- package/dist/keplr-config/chainInfo.d.ts +8 -0
- package/dist/keplr-config/chainInfo.js +111 -0
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
class ApiService {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.bearer = (token) => {
|
|
19
|
+
return `bearer ${token}`;
|
|
20
|
+
};
|
|
21
|
+
this.restApi = (baseURL, method, endpoint, headers, data, params) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const config = {
|
|
23
|
+
method: method,
|
|
24
|
+
url: `${baseURL}/${endpoint}`,
|
|
25
|
+
params: params,
|
|
26
|
+
headers: headers,
|
|
27
|
+
data: data,
|
|
28
|
+
};
|
|
29
|
+
try {
|
|
30
|
+
let response = yield (0, axios_1.default)(config);
|
|
31
|
+
return response;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error("Error making GET request:", error);
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const RestApiService = new ApiService();
|
|
41
|
+
exports.default = RestApiService;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { doTransactionInterface, GetTransactionInterface, GetAccountLimit } from "../interfaces/accountInterface";
|
|
2
|
+
import { IGeoCoordinates, UserInfo } from "../interfaces/interface";
|
|
3
|
+
export declare const useAccount: (token: string, userInfo: UserInfo, userId: string, baseUrl: string, geoCoordinates: IGeoCoordinates, lang?: string) => {
|
|
4
|
+
GetTransactionByUserId: (values: GetTransactionInterface) => Promise<{
|
|
5
|
+
response: import("axios").AxiosResponse<any, any>;
|
|
6
|
+
newUser: any;
|
|
7
|
+
message: any;
|
|
8
|
+
status: string;
|
|
9
|
+
} | {
|
|
10
|
+
response: any;
|
|
11
|
+
newUser: any;
|
|
12
|
+
message: any;
|
|
13
|
+
status: string;
|
|
14
|
+
}>;
|
|
15
|
+
GetAccount: () => Promise<{
|
|
16
|
+
response: any;
|
|
17
|
+
newUser: any;
|
|
18
|
+
message: any;
|
|
19
|
+
status: string;
|
|
20
|
+
}>;
|
|
21
|
+
DoTransaction: (values: doTransactionInterface) => Promise<{
|
|
22
|
+
response: any;
|
|
23
|
+
newUser: any;
|
|
24
|
+
message: any;
|
|
25
|
+
status: string;
|
|
26
|
+
}>;
|
|
27
|
+
GetAccountLimit: (values: GetAccountLimit) => Promise<{
|
|
28
|
+
response: any;
|
|
29
|
+
newUser: any;
|
|
30
|
+
message: any;
|
|
31
|
+
status: string;
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.useAccount = void 0;
|
|
16
|
+
const restApi_1 = __importDefault(require("../restApi"));
|
|
17
|
+
const helper_1 = __importDefault(require("../helper"));
|
|
18
|
+
const dataStructure_1 = __importDefault(require("../helper/dataStructure"));
|
|
19
|
+
const useAccount = (token, userInfo, userId, baseUrl, geoCoordinates, lang) => {
|
|
20
|
+
const { checkResponse, headerConfig } = (0, helper_1.default)(userInfo);
|
|
21
|
+
const { checkGlobalResponse } = checkResponse();
|
|
22
|
+
const { dataAccount } = (0, dataStructure_1.default)();
|
|
23
|
+
const { dataDoTransaction, paramGetTransaction } = dataAccount();
|
|
24
|
+
let endPointTransaction = `v1/transaction`;
|
|
25
|
+
let endPointAccount = `v1/user/account/${userId}`;
|
|
26
|
+
const headerConfigAccount = () => {
|
|
27
|
+
let headersData = {
|
|
28
|
+
header: true,
|
|
29
|
+
isUrlEncoded: false,
|
|
30
|
+
token: token,
|
|
31
|
+
lang: lang,
|
|
32
|
+
};
|
|
33
|
+
let headers = headerConfig(headersData);
|
|
34
|
+
return headers;
|
|
35
|
+
};
|
|
36
|
+
const GetTransactionByUserId = (values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
var _a, _b, _c;
|
|
38
|
+
let params = paramGetTransaction(Object.assign(Object.assign({}, values), { geoCoordinates: geoCoordinates }), userId);
|
|
39
|
+
try {
|
|
40
|
+
const response = yield restApi_1.default.restApi(baseUrl, "GET", `${endPointTransaction}/inquiry`, headerConfigAccount(), null, params);
|
|
41
|
+
let { newUserInfo } = checkGlobalResponse("account", response, "getTransaction", "get");
|
|
42
|
+
return {
|
|
43
|
+
response: response,
|
|
44
|
+
newUser: newUserInfo,
|
|
45
|
+
message: (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.friendly_message) !== null && _c !== void 0 ? _c : "Get Transaction Successfully",
|
|
46
|
+
status: "success",
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return {
|
|
51
|
+
response: error.response,
|
|
52
|
+
newUser: null,
|
|
53
|
+
message: error.message,
|
|
54
|
+
status: "failed",
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const GetAccount = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
var _a, _b, _c, _d;
|
|
60
|
+
try {
|
|
61
|
+
const response = yield restApi_1.default.restApi(baseUrl, "GET", endPointAccount, headerConfigAccount());
|
|
62
|
+
let { newUserInfo } = checkGlobalResponse("account", response, "getAccount", "getAccount");
|
|
63
|
+
return {
|
|
64
|
+
response: (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.account,
|
|
65
|
+
newUser: newUserInfo,
|
|
66
|
+
message: (_d = (_c = (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.result) === null || _c === void 0 ? void 0 : _c.friendly_message) !== null && _d !== void 0 ? _d : "Get Account Successfully",
|
|
67
|
+
status: "success",
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return {
|
|
72
|
+
response: error.response,
|
|
73
|
+
newUser: null,
|
|
74
|
+
message: error.message,
|
|
75
|
+
status: "failed",
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const DoTransaction = (values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
var _a, _b, _c;
|
|
81
|
+
let data = dataDoTransaction(Object.assign(Object.assign({}, values), { geoCoordinates: geoCoordinates }));
|
|
82
|
+
try {
|
|
83
|
+
const response = yield restApi_1.default.restApi(baseUrl, "POST", `${endPointTransaction}`, headerConfigAccount(), data);
|
|
84
|
+
let { newUserInfo } = checkGlobalResponse("account", response, "doTransaction", "doTransaction");
|
|
85
|
+
return {
|
|
86
|
+
response: response === null || response === void 0 ? void 0 : response.data,
|
|
87
|
+
newUser: newUserInfo,
|
|
88
|
+
message: (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.friendly_message) !== null && _c !== void 0 ? _c : "Transaction Successfully",
|
|
89
|
+
status: "success",
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return {
|
|
94
|
+
response: error.response,
|
|
95
|
+
newUser: null,
|
|
96
|
+
message: error.message,
|
|
97
|
+
status: "failed",
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const GetAccountLimit = (values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
var _a, _b, _c;
|
|
103
|
+
try {
|
|
104
|
+
const response = yield restApi_1.default.restApi(baseUrl, "GET", `v1/account/${values.account_id}`, headerConfigAccount());
|
|
105
|
+
let { newUserInfo } = checkGlobalResponse("account", response, "getAccountLimit", "getAccountLimit");
|
|
106
|
+
return {
|
|
107
|
+
response: response === null || response === void 0 ? void 0 : response.data,
|
|
108
|
+
newUser: newUserInfo,
|
|
109
|
+
message: (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.friendly_message) !== null && _c !== void 0 ? _c : "Get Account Limit Successfully",
|
|
110
|
+
status: "success",
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
return {
|
|
115
|
+
response: error.response,
|
|
116
|
+
newUser: null,
|
|
117
|
+
message: error.message,
|
|
118
|
+
status: "failed",
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return {
|
|
123
|
+
GetTransactionByUserId,
|
|
124
|
+
GetAccount,
|
|
125
|
+
DoTransaction,
|
|
126
|
+
GetAccountLimit,
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
exports.useAccount = useAccount;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CreateAddressInterface, DeleteUserAddressInterface, MakeAddressPrimaryInterface, UpdateAddressInterface } from "../interfaces/bankingSystemInterface";
|
|
2
|
+
import { IGeoCoordinates, UserInfo } from "../interfaces/interface";
|
|
3
|
+
export declare const useAddresses: (token: string, userInfo: UserInfo, userId: string, baseUrl: string, geoCoordinates: IGeoCoordinates, lang?: string) => {
|
|
4
|
+
CreateAddress: (values: CreateAddressInterface) => Promise<{
|
|
5
|
+
response: import("axios").AxiosResponse<any, any>;
|
|
6
|
+
newUser: any;
|
|
7
|
+
message: any;
|
|
8
|
+
status: string;
|
|
9
|
+
} | {
|
|
10
|
+
response: any;
|
|
11
|
+
newUser: any;
|
|
12
|
+
message: any;
|
|
13
|
+
status: string;
|
|
14
|
+
}>;
|
|
15
|
+
UpdateUserAddress: (values: UpdateAddressInterface) => Promise<{
|
|
16
|
+
response: import("axios").AxiosResponse<any, any>;
|
|
17
|
+
newUser: any;
|
|
18
|
+
message: any;
|
|
19
|
+
status: string;
|
|
20
|
+
} | {
|
|
21
|
+
response: any;
|
|
22
|
+
newUser: any;
|
|
23
|
+
message: any;
|
|
24
|
+
status: string;
|
|
25
|
+
}>;
|
|
26
|
+
MakeUserAddressPrimary: (values: MakeAddressPrimaryInterface) => Promise<{
|
|
27
|
+
response: import("axios").AxiosResponse<any, any>;
|
|
28
|
+
newUser: any;
|
|
29
|
+
message: any;
|
|
30
|
+
status: string;
|
|
31
|
+
} | {
|
|
32
|
+
response: any;
|
|
33
|
+
newUser: any;
|
|
34
|
+
message: any;
|
|
35
|
+
status: string;
|
|
36
|
+
}>;
|
|
37
|
+
DeleteUserAddress: (values: DeleteUserAddressInterface) => Promise<{
|
|
38
|
+
response: import("axios").AxiosResponse<any, any>;
|
|
39
|
+
newUser: any;
|
|
40
|
+
message: any;
|
|
41
|
+
status: string;
|
|
42
|
+
} | {
|
|
43
|
+
response: any;
|
|
44
|
+
newUser: any;
|
|
45
|
+
message: any;
|
|
46
|
+
status: string;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.useAddresses = void 0;
|
|
16
|
+
const restApi_1 = __importDefault(require("../restApi"));
|
|
17
|
+
const helper_1 = __importDefault(require("../helper"));
|
|
18
|
+
const dataStructure_1 = __importDefault(require("../helper/dataStructure"));
|
|
19
|
+
const useAddresses = (token, userInfo, userId, baseUrl, geoCoordinates, lang) => {
|
|
20
|
+
const { dataAddress } = (0, dataStructure_1.default)();
|
|
21
|
+
const { createDataAddress, deleteDataAddress, primaryDataAddress, updateDataAddress, } = dataAddress();
|
|
22
|
+
const { checkResponse, headerConfig } = (0, helper_1.default)(userInfo);
|
|
23
|
+
const { checkGlobalResponse } = checkResponse();
|
|
24
|
+
let endPointAddress = `v1/user/address/${userId}`;
|
|
25
|
+
const headerConfigAddresses = () => {
|
|
26
|
+
let headersData = {
|
|
27
|
+
header: true,
|
|
28
|
+
isUrlEncoded: false,
|
|
29
|
+
token: token,
|
|
30
|
+
lang: lang,
|
|
31
|
+
};
|
|
32
|
+
let headers = headerConfig(headersData);
|
|
33
|
+
return headers;
|
|
34
|
+
};
|
|
35
|
+
const CreateAddress = (values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
var _a, _b, _c;
|
|
37
|
+
let data = createDataAddress(Object.assign(Object.assign({}, values), { geoCoordinates: geoCoordinates }));
|
|
38
|
+
try {
|
|
39
|
+
const response = yield restApi_1.default.restApi(baseUrl, "POST", endPointAddress, headerConfigAddresses(), data);
|
|
40
|
+
let { newUserInfo } = checkGlobalResponse("addresses", response, "CreateAddress", "create");
|
|
41
|
+
return {
|
|
42
|
+
response: response,
|
|
43
|
+
newUser: newUserInfo,
|
|
44
|
+
message: (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.friendly_message) !== null && _c !== void 0 ? _c : "Address Created Successfully",
|
|
45
|
+
status: "success",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
response: error.response,
|
|
51
|
+
newUser: null,
|
|
52
|
+
message: error.message,
|
|
53
|
+
status: "failed",
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const UpdateUserAddress = (values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
var _a, _b, _c;
|
|
59
|
+
let data = updateDataAddress(Object.assign(Object.assign({}, values), { geoCoordinates: geoCoordinates }));
|
|
60
|
+
try {
|
|
61
|
+
const response = yield restApi_1.default.restApi(baseUrl, "PUT", endPointAddress, headerConfigAddresses(), data);
|
|
62
|
+
let { newUserInfo } = checkGlobalResponse("addresses", response, "UpdateUserAddress", "update");
|
|
63
|
+
return {
|
|
64
|
+
response: response,
|
|
65
|
+
newUser: newUserInfo,
|
|
66
|
+
message: (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.friendly_message) !== null && _c !== void 0 ? _c : "Address Updated Successfully",
|
|
67
|
+
status: "success",
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return {
|
|
72
|
+
response: error.response,
|
|
73
|
+
newUser: null,
|
|
74
|
+
message: error.message,
|
|
75
|
+
status: "failed",
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const DeleteUserAddress = (values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
var _a, _b, _c;
|
|
81
|
+
let data = deleteDataAddress(Object.assign(Object.assign({}, values), { geoCoordinates: geoCoordinates }));
|
|
82
|
+
try {
|
|
83
|
+
const response = yield restApi_1.default.restApi(baseUrl, "DELETE", endPointAddress, headerConfigAddresses(), data);
|
|
84
|
+
let { newUserInfo } = checkGlobalResponse("addresses", response, "DeleteUserAddress", "delete");
|
|
85
|
+
return {
|
|
86
|
+
response: response,
|
|
87
|
+
newUser: newUserInfo,
|
|
88
|
+
message: (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.friendly_message) !== null && _c !== void 0 ? _c : "Address Deleted Successfully",
|
|
89
|
+
status: "success",
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return {
|
|
94
|
+
response: error.response,
|
|
95
|
+
newUser: null,
|
|
96
|
+
message: error.message,
|
|
97
|
+
status: "failed",
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const MakeUserAddressPrimary = (values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
var _a, _b, _c;
|
|
103
|
+
let data = primaryDataAddress(Object.assign(Object.assign({}, values), { geoCoordinates: geoCoordinates }));
|
|
104
|
+
try {
|
|
105
|
+
const response = yield restApi_1.default.restApi(baseUrl, "PUT", endPointAddress, headerConfigAddresses(), data);
|
|
106
|
+
let { newUserInfo } = checkGlobalResponse("addresses", response, "MakeUserAddressPrimary", "updatePrimary");
|
|
107
|
+
return {
|
|
108
|
+
response: response,
|
|
109
|
+
newUser: newUserInfo,
|
|
110
|
+
message: (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.friendly_message) !== null && _c !== void 0 ? _c : "Primary Address Updated Successfully",
|
|
111
|
+
status: "success",
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
return {
|
|
116
|
+
response: error.response,
|
|
117
|
+
newUser: null,
|
|
118
|
+
message: error.message,
|
|
119
|
+
status: "failed",
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
CreateAddress,
|
|
125
|
+
UpdateUserAddress,
|
|
126
|
+
MakeUserAddressPrimary,
|
|
127
|
+
DeleteUserAddress,
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
exports.useAddresses = useAddresses;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { LoginWithGoogleInterface, SignUpInterface, SignUpWithGoogleInterface, LoginRequestInterface, LoginDeviceCredentialInterface } from "../interfaces/signInterface";
|
|
2
|
+
import { IGeoCoordinates, UserInfo } from "../interfaces/interface";
|
|
3
|
+
import { LimitedTokenInterface } from "../interfaces/signInterface";
|
|
4
|
+
export declare const useAuth: (baseUrl: string, nodeUrl: string, userInfo: UserInfo, tokenData: LimitedTokenInterface, programId: string, geoCoordinates?: IGeoCoordinates, lang?: string) => {
|
|
5
|
+
GetUser: (installationId: string, token?: string, userId?: string) => Promise<{
|
|
6
|
+
response: import("axios").AxiosResponse<any, any>;
|
|
7
|
+
newUser: {};
|
|
8
|
+
message: any;
|
|
9
|
+
status: string;
|
|
10
|
+
} | {
|
|
11
|
+
response: any;
|
|
12
|
+
newUser: any;
|
|
13
|
+
message: any;
|
|
14
|
+
status: string;
|
|
15
|
+
}>;
|
|
16
|
+
SignUpApi: (values: SignUpInterface) => Promise<{
|
|
17
|
+
response: import("axios").AxiosResponse<any, any>;
|
|
18
|
+
newUser: {};
|
|
19
|
+
message: any;
|
|
20
|
+
status: string;
|
|
21
|
+
} | {
|
|
22
|
+
response: any;
|
|
23
|
+
newUser: any;
|
|
24
|
+
message: any;
|
|
25
|
+
status: string;
|
|
26
|
+
}>;
|
|
27
|
+
LoginRequest: (values: LoginRequestInterface) => Promise<{
|
|
28
|
+
response: import("axios").AxiosResponse<any, any>;
|
|
29
|
+
newUser: {};
|
|
30
|
+
message: any;
|
|
31
|
+
status: string;
|
|
32
|
+
} | {
|
|
33
|
+
response: any;
|
|
34
|
+
newUser: any;
|
|
35
|
+
message: any;
|
|
36
|
+
status: string;
|
|
37
|
+
}>;
|
|
38
|
+
LoginDeviceCredential: (values: LoginDeviceCredentialInterface) => Promise<{
|
|
39
|
+
response: import("axios").AxiosResponse<any, any>;
|
|
40
|
+
newUser: {};
|
|
41
|
+
message: any;
|
|
42
|
+
status: string;
|
|
43
|
+
} | {
|
|
44
|
+
response: any;
|
|
45
|
+
newUser: any;
|
|
46
|
+
message: any;
|
|
47
|
+
status: string;
|
|
48
|
+
}>;
|
|
49
|
+
SignUpWithGoogle: (values: SignUpWithGoogleInterface) => Promise<{
|
|
50
|
+
response: import("axios").AxiosResponse<any, any>;
|
|
51
|
+
newUser: {};
|
|
52
|
+
message: any;
|
|
53
|
+
status: string;
|
|
54
|
+
} | {
|
|
55
|
+
response: any;
|
|
56
|
+
newUser: any;
|
|
57
|
+
message: any;
|
|
58
|
+
status: string;
|
|
59
|
+
}>;
|
|
60
|
+
LoginWithGoogle: (values: LoginWithGoogleInterface) => Promise<{
|
|
61
|
+
response: import("axios").AxiosResponse<any, any>;
|
|
62
|
+
newUser: {};
|
|
63
|
+
message: any;
|
|
64
|
+
status: string;
|
|
65
|
+
} | {
|
|
66
|
+
response: any;
|
|
67
|
+
newUser: any;
|
|
68
|
+
message: any;
|
|
69
|
+
status: string;
|
|
70
|
+
}>;
|
|
71
|
+
};
|