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.
281 lines (280 loc) • 11.5 kB
JavaScript
import { Endpoints, UserEndpoints } from "../../constant/constant";
import { AuthService } from "./authService";
import { AxiosHelper } from "../../helper/api/axiosHelper";
import { BaseService } from "./baseService";
class UserService extends BaseService {
endpoint = Endpoints.User;
authService;
constructor(data) {
super(data);
this.authService = new AuthService(data);
}
async userId() {
return await this.cookiesHelper.getUserId();
}
// #region "GET"
async getUser() {
const url = this.resolveURL(`/${await this.userId()}`);
return this.GET(url, { flags: { showCustomField: true } });
}
async getTermsAndConditions() {
const url = this.resolveURL(`${UserEndpoints.TermsAndConditions}/${await this.userId()}`);
return this.GET(url);
}
async getSecurity() {
const url = this.resolveURL(`${UserEndpoints.Security}/${await this.userId()}`);
return this.GET(url);
}
async getPhone() {
const url = this.resolveURL(`${UserEndpoints.Phone}/${await this.userId()}`);
return this.GET(url);
}
async getPreferences() {
const url = this.resolveURL(`${UserEndpoints.Preferences}/${await this.userId()}`);
return this.GET(url);
}
async getPersonalInfo() {
const url = this.resolveURL(`${UserEndpoints.PersonalInfo}/${await this.userId()}`);
return this.GET(url);
}
async getLatestHistory() {
const url = this.resolveURL(`${UserEndpoints.HistoryLatest}/${await this.userId()}`);
return this.GET(url);
}
async getIdentification() {
const url = this.resolveURL(`${UserEndpoints.Identification}/${await this.userId()}`);
return this.GET(url, { flags: { showSensitiveData: true } });
}
async getHistory() {
const url = this.resolveURL(`${UserEndpoints.HistoryLatest}/${await this.userId()}`);
return this.GET(url);
}
async getGroup() {
const url = this.resolveURL(`${UserEndpoints.Group}/${await this.userId()}`);
return this.GET(url);
}
async getExternalAuth() {
const url = this.resolveURL(`${UserEndpoints.ExternalAuth}/${await this.userId()}`);
return this.GET(url);
}
async getEmail() {
const url = this.resolveURL(`${UserEndpoints.Email}/${await this.userId()}`);
return this.GET(url);
}
async getDocuments() {
const url = this.resolveURL(`${UserEndpoints.Documents}/${await this.userId()}`);
return this.GET(url);
}
async getCurrency() {
const url = this.resolveURL(`${UserEndpoints.Currency}/${await this.userId()}`);
return this.GET(url);
}
async getCreditCard() {
const url = this.resolveURL(`${UserEndpoints.CreditCard}/${await this.userId()}`);
return this.GET(url);
}
async getBankAccount() {
const url = this.resolveURL(`${UserEndpoints.BankAccount}/${await this.userId()}`);
return this.GET(url, { flags: { showSensitiveData: true } });
}
async getAddress() {
const url = this.resolveURL(`${UserEndpoints.Address}/${await this.userId()}`);
return this.GET(url, { flags: { showSensitiveData: true } });
}
async getAccount() {
const url = this.resolveURL(`${UserEndpoints.Account}/${await this.userId()}`);
return this.GET(url);
}
async getDeviceHistory() {
const url = this.resolveURL(`${UserEndpoints.DeviceHistory}/${await this.userId()}`);
return this.GET(url);
}
async getActivity() {
const url = this.resolveURL(`${UserEndpoints.Activity}/${await this.userId()}`);
return this.GET(url);
}
// #endregion
// #region "POST"
async createUser(payload) {
const url = this.resolveURL();
const headers = await AxiosHelper.getLimitedAuthHeaders(this.authService, this.cookiesHelper);
return this.POST(url, payload, { headers });
}
async createPhone(payload) {
const url = this.resolveURL(`${UserEndpoints.Phone}/${await this.userId()}`);
return this.POST(url, payload);
}
async createDevice(payload) {
const url = this.resolveURL(`${UserEndpoints.Device}/${await this.userId()}`);
return this.POST(url, payload);
}
async createIdentification(payload) {
const url = this.resolveURL(`${UserEndpoints.Identification}/${await this.userId()}`);
return this.POST(url, payload);
}
async createExternalAuth(payload) {
const url = this.resolveURL(`${UserEndpoints.ExternalAuth}/${await this.userId()}`);
return this.POST(url, payload);
}
async createEmail(payload) {
const url = this.resolveURL(`${UserEndpoints.Email}/${await this.userId()}`);
return this.POST(url, payload);
}
async createCurrency(payload) {
const url = this.resolveURL(`${UserEndpoints.Currency}/${await this.userId()}`);
return this.POST(url, payload);
}
async createCreditCard(payload) {
const url = this.resolveURL(`${UserEndpoints.CreditCard}/${await this.userId()}`);
return this.POST(url, payload);
}
async createBankAccount(payload) {
const url = this.resolveURL(`${UserEndpoints.BankAccount}/${await this.userId()}`);
return this.POST(url, payload);
}
async createAddress(payload) {
const url = this.resolveURL(`${UserEndpoints.Address}/${await this.userId()}`);
return this.POST(url, payload);
}
async createTicket(payload) {
const url = this.resolveURL(`${UserEndpoints.Ticket}/${await this.userId()}`);
return this.POST(url, payload);
}
async securityAccess(payload) {
const url = this.resolveURL(`${UserEndpoints.SecurityAccess}/${await this.userId()}`);
return this.POST(url, payload);
}
async uploadDocument(payload) {
const url = this.resolveURL(`${UserEndpoints.Document}/${await this.userId()}`);
return this.POST(url, payload);
}
async confirmSecurityData(payload) {
const url = this.resolveURL(`${UserEndpoints.SecurityConfirm}/${await this.userId()}`);
return this.POST(url, payload);
}
async validateSecurityData(payload) {
const url = this.resolveURL(`${UserEndpoints.SecurityValidate}/${await this.userId()}`);
return this.POST(url, payload);
}
async verifySecurityData(payload) {
const url = this.resolveURL(`${UserEndpoints.SecurityVerify}/${await this.userId()}`);
return this.POST(url, payload);
}
async resetSecurityData(payload) {
const url = this.resolveURL(`${UserEndpoints.SecurityReset}/${await this.userId()}`);
return this.POST(url, payload);
}
async enrollGoogleAuth(payload) {
const url = this.resolveURL(`${UserEndpoints.AuthEnroll}/${await this.userId()}`);
return this.POST(url, payload);
}
async activateGoogleAuth(payload) {
const url = this.resolveURL(`${UserEndpoints.AuthActivate}/${await this.userId()}`);
return this.POST(url, payload);
}
async deactivateGoogleAuth(payload) {
const url = this.resolveURL(`${UserEndpoints.AuthDeactivate}/${await this.userId()}`);
return this.POST(url, payload);
}
async deleteGoogleAuth(payload) {
const url = this.resolveURL(`${UserEndpoints.AuthDelete}/${await this.userId()}`);
return this.POST(url, payload);
}
// #endregion
// #region "PUT"
async updateUser(payload) {
const url = this.resolveURL(`/${await this.userId()}`);
return this.PUT(url, payload);
}
async updateSecurity(payload) {
const url = this.resolveURL(`${UserEndpoints.Security}/${await this.userId()}`);
return this.PUT(url, payload);
}
async updatePreferences(payload) {
const url = this.resolveURL(`${UserEndpoints.Preferences}/${await this.userId()}`);
return this.PUT(url, payload);
}
async updateDevice(payload) {
const url = this.resolveURL(`${UserEndpoints.Device}/${await this.userId()}`);
return this.PUT(url, payload);
}
async logoutDevice(payload) {
const url = this.resolveURL(`${UserEndpoints.DeviceLogout}/${await this.userId()}`);
return this.PUT(url, payload);
}
async updatePhone(payload) {
const url = this.resolveURL(`${UserEndpoints.Phone}/${await this.userId()}`);
return this.PUT(url, payload);
}
async updatePersonalInfo(payload) {
const url = this.resolveURL(`${UserEndpoints.PersonalInfo}/${await this.userId()}`);
return this.PUT(url, payload);
}
async updateIdentification(payload) {
const url = this.resolveURL(`${UserEndpoints.Identification}/${await this.userId()}`);
return this.PUT(url, payload);
}
async updateExternalAuth(payload) {
const url = this.resolveURL(`${UserEndpoints.ExternalAuth}/${await this.userId()}`);
return this.PUT(url, payload);
}
async updateEmail(payload) {
const url = this.resolveURL(`${UserEndpoints.Email}/${await this.userId()}`);
return this.PUT(url, payload);
}
async updateCreditCard(payload) {
const url = this.resolveURL(`${UserEndpoints.CreditCard}/${await this.userId()}`);
return this.PUT(url, payload);
}
async updateBankAccount(payload) {
const url = this.resolveURL(`${UserEndpoints.BankAccount}/${await this.userId()}`);
return this.PUT(url, payload);
}
async updateAddress(payload) {
const url = this.resolveURL(`${UserEndpoints.Address}/${await this.userId()}`);
return this.PUT(url, payload);
}
async updateUserType(payload) {
const url = this.resolveURL(`${UserEndpoints.Type}/${await this.userId()}`);
return this.PUT(url, payload);
}
// #endregion
// #region "DELETE"
async deleteUser() {
const url = this.resolveURL(`/${await this.userId()}`);
return this.DELETE(url);
}
async deleteCreditCard() {
const url = this.resolveURL(`${UserEndpoints.CreditCard}/${await this.userId()}`);
return this.DELETE(url);
}
async deleteAddress(payload) {
const url = this.resolveURL(`${UserEndpoints.Address}/${await this.userId()}`);
return this.DELETE(url, { data: payload });
}
async deleteDevice(payload) {
const url = this.resolveURL(`${UserEndpoints.Device}/${await this.userId()}`);
return this.DELETE(url, { data: payload });
}
async deleteBankAccount(payload) {
const url = this.resolveURL(`${UserEndpoints.BankAccount}/${await this.userId()}`);
return this.DELETE(url, { data: payload });
}
async deleteIdentification(payload) {
const url = this.resolveURL(`${UserEndpoints.Identification}/${await this.userId()}`);
return this.DELETE(url, { data: payload });
}
async deleteEmail(payload) {
const url = this.resolveURL(`${UserEndpoints.Email}/${await this.userId()}`);
return this.DELETE(url, { data: payload });
}
async deletePhone(payload) {
const url = this.resolveURL(`${UserEndpoints.Phone}/${await this.userId()}`);
return this.DELETE(url, { data: payload });
}
async deleteExternalAuth() {
const url = this.resolveURL(`${UserEndpoints.ExternalAuth}/${await this.userId()}`);
return this.DELETE(url);
}
}
export { UserService };