UNPKG

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.

49 lines (48 loc) 1.91 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.useDocument = void 0; const dataStructure_1 = __importDefault(require("../helper/dataStructure")); const restApi_1 = __importDefault(require("../restApi")); const helper_1 = __importDefault(require("../helper")); const useDocument = (token, userInfo, userId, baseUrl, geoCoordinates, lang) => { const { dataDocument } = (0, dataStructure_1.default)(); const { checkResponse, headerConfig } = (0, helper_1.default)(userInfo); const { checkGlobalResponse } = checkResponse(); let endPointDocument = `v1/user/document/${userId}`; // Document const CreateDocument = async (values) => { const data = dataDocument({ ...values, geoCoordinates: geoCoordinates }); let headersData = { header: true, isUrlEncoded: false, token: token, lang: lang, }; let headers = headerConfig(headersData); try { const response = await restApi_1.default.restApi(baseUrl, "POST", endPointDocument, headers, data); let { newUserInfo } = checkGlobalResponse(data?.info?.subject, response, "CreateDocument", "createDocument"); return { response: response, newUser: newUserInfo, message: response?.data?.result?.message ?? "Document Created Successfully", status: "success", }; } catch (error) { return { response: error.response, newUser: null, message: error.message, status: "failed", }; } }; return { CreateDocument, }; }; exports.useDocument = useDocument;