ggez-banking-sdk
Version:
A Node.js package to handle GGEZ Banking API endpoints, Simplify the process of managing CRUD operations with this efficient and easy-to-use package.
77 lines (76 loc) • 2.47 kB
JavaScript
import qs from "qs";
import { GrantType, SecurityLoginType } from "../../constant";
import { DeviceHelper } from "../../helper/deviceHelper";
const createDefaultTokenData = (overrides) => ({
result: null,
notes: null,
last_activity: null,
authentication: null,
validate: null,
function_code: null,
response_time: null,
time_zone: null,
time_zone_name: null,
access_token: "",
token_type: "",
expires_in: 0,
cluster_id: "",
program_id: "",
user_id: "",
device_id: "",
role: "",
role_type: "",
user_type: "",
ip_address: "",
jwt_token: "",
installation_id: "",
device_status: "",
device_verification_status: "",
device_encryption_key: "",
error: "",
...overrides,
});
const fillLoginUserCredentialsData = (programId, data) => {
const credentials = qs.stringify({
grant_type: GrantType.UserCredential,
user_name: data.email,
password: data.password,
program_id: programId,
language: "en",
generate_jwt: "true",
installation_id: data.installationId,
device_details: DeviceHelper.getDeviceDetails(true),
}, { allowDots: true });
return credentials;
};
const fillLoginDeviceCredentialsData = (programId, data) => {
const credentials = qs.stringify({
grant_type: GrantType.DeviceCredential,
device_security_code: data.device_security_code,
user_Id: data.user_id,
device_Id: data.device_id,
program_Id: programId,
language: "en",
generate_jwt: "true",
device_details: DeviceHelper.getDeviceDetails(true),
}, { allowDots: true });
return credentials;
};
const fillLoginGoogleCredentialsData = (programId, data) => {
const credentials = qs.stringify({
grant_type: GrantType.UserCredential,
token: data.token,
token_id: data.token_id,
program_Id: programId,
language: "en",
token_type: SecurityLoginType.Google,
generate_jwt: "true",
installation_id: data.installationId,
device_details: DeviceHelper.getDeviceDetails(true),
}, { allowDots: true });
return credentials;
};
const fillGenerateLimitedTokenData = (data) => {
return { installationId: data.installationId };
};
export { createDefaultTokenData, fillLoginUserCredentialsData, fillLoginDeviceCredentialsData, fillLoginGoogleCredentialsData, fillGenerateLimitedTokenData, };