ggez-banking-sdk 0.4.20 → 0.4.22

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.
@@ -11,7 +11,9 @@ class AuthService extends BaseService {
11
11
  return this.POST(url, data);
12
12
  }
13
13
  generateLimitedToken(data) {
14
- return this.POST(`${this.context.getNodeUrl()}/token/limited-token`, data);
14
+ return this.POST("/token/limited-token", data, {
15
+ baseURL: this.context.getNodeUrl(),
16
+ });
15
17
  }
16
18
  }
17
19
  export { AuthService };
@@ -1,7 +1,6 @@
1
1
  import { AxiosInstance } from "axios";
2
- import type { BaseServiceParameters } from "../../types/api/service/base";
2
+ import type { BaseServiceParameters, ServiceRequestOptions } from "../../types/api/service/base";
3
3
  import type { ClientContextProvider } from "../../types/api/context/clientContext";
4
- import type { RequestFlag } from "../../types/helper/api/requestBuilder";
5
4
  import type { BaseResult } from "../../types/banking/common/baseresult";
6
5
  import { ApiResponse, CookiesHelper, ErrorHandler } from "../..";
7
6
  declare abstract class BaseService {
@@ -14,14 +13,12 @@ declare abstract class BaseService {
14
13
  private onRequest;
15
14
  private onResponse;
16
15
  private onError;
17
- protected GET<T extends BaseResult>(url: string, options?: {
18
- params?: object;
19
- flags?: RequestFlag;
20
- }): Promise<ApiResponse<T>>;
21
- protected POST<T extends BaseResult>(url: string, data: object | string, flags?: RequestFlag): Promise<ApiResponse<T>>;
22
- protected PUT<T extends BaseResult>(url: string, data: object | string, flags?: RequestFlag): Promise<ApiResponse<T>>;
23
- protected DELETE<T extends BaseResult>(url: string, data?: object, flags?: RequestFlag): Promise<ApiResponse<T>>;
16
+ protected GET<T extends BaseResult>(url: string, options?: ServiceRequestOptions): Promise<ApiResponse<T>>;
17
+ protected POST<T extends BaseResult>(url: string, data: object | string, options?: ServiceRequestOptions): Promise<ApiResponse<T>>;
18
+ protected PUT<T extends BaseResult>(url: string, data: object | string, options?: ServiceRequestOptions): Promise<ApiResponse<T>>;
19
+ protected DELETE<T extends BaseResult>(url: string, options?: ServiceRequestOptions): Promise<ApiResponse<T>>;
24
20
  protected resolveURL(path?: string | number): string;
21
+ private buildConfig;
25
22
  private buildFlagHeaders;
26
23
  }
27
24
  export { BaseService };
@@ -17,7 +17,7 @@ class BaseService {
17
17
  }
18
18
  // #region "Interceptors Handlers"
19
19
  async onRequest(req) {
20
- await AxiosHelper.injectBaseHeaders(req, this.context, this.cookiesHelper, this.endpoint);
20
+ await AxiosHelper.injectBaseHeaders(req, this.context, this.cookiesHelper);
21
21
  AxiosHelper.injectBaseBodyProperties(req);
22
22
  return req;
23
23
  }
@@ -30,29 +30,19 @@ class BaseService {
30
30
  }
31
31
  // #endregion
32
32
  async GET(url, options) {
33
- const response = await this.axiosInstance.get(url, {
34
- params: options?.params,
35
- headers: this.buildFlagHeaders(options?.flags),
36
- });
33
+ const response = await this.axiosInstance.get(url, this.buildConfig(options));
37
34
  return ResponseHelper.getApiResponse(response);
38
35
  }
39
- async POST(url, data, flags) {
40
- const response = await this.axiosInstance.post(url, data, {
41
- headers: this.buildFlagHeaders(flags),
42
- });
36
+ async POST(url, data, options) {
37
+ const response = await this.axiosInstance.post(url, data, this.buildConfig(options));
43
38
  return ResponseHelper.getApiResponse(response);
44
39
  }
45
- async PUT(url, data, flags) {
46
- const response = await this.axiosInstance.put(url, data, {
47
- headers: this.buildFlagHeaders(flags),
48
- });
40
+ async PUT(url, data, options) {
41
+ const response = await this.axiosInstance.put(url, data, this.buildConfig(options));
49
42
  return ResponseHelper.getApiResponse(response);
50
43
  }
51
- async DELETE(url, data, flags) {
52
- const response = await this.axiosInstance.delete(url, {
53
- data,
54
- headers: this.buildFlagHeaders(flags),
55
- });
44
+ async DELETE(url, options) {
45
+ const response = await this.axiosInstance.delete(url, this.buildConfig(options));
56
46
  return ResponseHelper.getApiResponse(response);
57
47
  }
58
48
  resolveURL(path = "") {
@@ -60,6 +50,16 @@ class BaseService {
60
50
  const normalized = p && !p.startsWith("/") ? `/${p}` : p;
61
51
  return `${this.endpoint}${normalized}`;
62
52
  }
53
+ // Precedence: caller `headers` > flag-derived headers; interceptor wins over both.
54
+ buildConfig(options) {
55
+ if (!options)
56
+ return {};
57
+ const { flags, headers, ...rest } = options;
58
+ return {
59
+ ...rest,
60
+ headers: { ...this.buildFlagHeaders(flags), ...headers },
61
+ };
62
+ }
63
63
  buildFlagHeaders(flags) {
64
64
  const headers = {};
65
65
  if (flags?.showSensitiveData)
@@ -254,27 +254,27 @@ class UserService extends BaseService {
254
254
  }
255
255
  async deleteAddress(payload) {
256
256
  const url = this.resolveURL(`${UserEndpoints.Address}/${await this.userId()}`);
257
- return this.DELETE(url, payload);
257
+ return this.DELETE(url, { data: payload });
258
258
  }
259
259
  async deleteDevice(payload) {
260
260
  const url = this.resolveURL(`${UserEndpoints.Device}/${await this.userId()}`);
261
- return this.DELETE(url, payload);
261
+ return this.DELETE(url, { data: payload });
262
262
  }
263
263
  async deleteBankAccount(payload) {
264
264
  const url = this.resolveURL(`${UserEndpoints.BankAccount}/${await this.userId()}`);
265
- return this.DELETE(url, payload);
265
+ return this.DELETE(url, { data: payload });
266
266
  }
267
267
  async deleteIdentification(payload) {
268
268
  const url = this.resolveURL(`${UserEndpoints.Identification}/${await this.userId()}`);
269
- return this.DELETE(url, payload);
269
+ return this.DELETE(url, { data: payload });
270
270
  }
271
271
  async deleteEmail(payload) {
272
272
  const url = this.resolveURL(`${UserEndpoints.Email}/${await this.userId()}`);
273
- return this.DELETE(url, payload);
273
+ return this.DELETE(url, { data: payload });
274
274
  }
275
275
  async deletePhone(payload) {
276
276
  const url = this.resolveURL(`${UserEndpoints.Phone}/${await this.userId()}`);
277
- return this.DELETE(url, payload);
277
+ return this.DELETE(url, { data: payload });
278
278
  }
279
279
  async deleteExternalAuth() {
280
280
  const url = this.resolveURL(`${UserEndpoints.ExternalAuth}/${await this.userId()}`);
@@ -2,7 +2,7 @@ import axios from "axios";
2
2
  import { generateSourceID } from "../../utils/data/generation";
3
3
  import { DateTimeHelper } from "../dateTimeHelper";
4
4
  import qs from "qs";
5
- import { Endpoints, HeaderKeys } from "../../constant/constant";
5
+ import { HeaderKeys } from "../../constant/constant";
6
6
  class AxiosHelper {
7
7
  static getAxiosConfig = (token, baseURL, lang, installationId) => {
8
8
  const config = {
@@ -41,13 +41,11 @@ class AxiosHelper {
41
41
  config.headers = {};
42
42
  config.headers[key] = value;
43
43
  };
44
- static injectBaseHeaders = async (req, context, cookiesHelper, endpoint) => {
44
+ static injectBaseHeaders = async (req, context, cookiesHelper) => {
45
45
  const token = await cookiesHelper.getAccessToken();
46
46
  const userId = await cookiesHelper.getUserId();
47
47
  const lang = context.getLang();
48
48
  const iid = await cookiesHelper.getIID();
49
- const baseURL = context.getBaseUrl();
50
- const nodeUrl = context.getNodeUrl();
51
49
  if (token)
52
50
  req.headers.set(HeaderKeys.Authorization, `Bearer ${token}`);
53
51
  if (userId)
@@ -56,10 +54,8 @@ class AxiosHelper {
56
54
  req.headers.set(HeaderKeys.Language, lang);
57
55
  if (iid)
58
56
  req.headers.set(HeaderKeys.InstallationID, iid);
59
- if (endpoint == Endpoints.Limited)
60
- req.baseURL = nodeUrl;
61
- else
62
- req.baseURL = baseURL;
57
+ if (!req.baseURL)
58
+ req.baseURL = context.getBaseUrl();
63
59
  req.headers.set(HeaderKeys.TimeZone, DateTimeHelper.getClientTimeZone());
64
60
  return req;
65
61
  };
@@ -1,8 +1,13 @@
1
+ import type { AxiosRequestConfig } from "axios";
1
2
  import type { ClientContextProvider } from "../context/clientContext";
3
+ import type { RequestFlag } from "../../helper/api/requestBuilder";
2
4
  import { CookiesHelper, ErrorHandler } from "../../..";
3
5
  type BaseServiceParameters = {
4
6
  context: ClientContextProvider;
5
7
  errorHandler: ErrorHandler;
6
8
  cookiesHelper: CookiesHelper;
7
9
  };
8
- export { BaseServiceParameters };
10
+ type ServiceRequestOptions = AxiosRequestConfig & {
11
+ flags?: RequestFlag;
12
+ };
13
+ export { BaseServiceParameters, ServiceRequestOptions };
@@ -6,5 +6,6 @@ type SystemFeatures = {
6
6
  organization_individual_group_verification_requirements: VerificationRequirements;
7
7
  account_options: AccountOptions;
8
8
  security_user_alert: SecurityUserAlert;
9
+ apply_user_verification_requirements_to_organization_users: boolean;
9
10
  };
10
11
  export type { SystemFeatures };
@@ -7,7 +7,7 @@ type TGetAuthAxiosConfig = (baseURL: string, lang: string, installationId: strin
7
7
  type TAddAxiosConfigHeader = (config: AxiosRequestConfig, key: string, value: string) => void;
8
8
  type TInjectRequest<D> = (req: InternalAxiosRequestConfig<D>) => InternalAxiosRequestConfig<D>;
9
9
  type InjectRequiredHeaders<D> = (req: InternalAxiosRequestConfig, userId: number) => InternalAxiosRequestConfig<D>;
10
- type InjectBaseHeaders<D> = (req: InternalAxiosRequestConfig, context: ClientContextProvider, cookiesHelper: CookiesHelper, endpoint: string) => Promise<InternalAxiosRequestConfig<D>>;
10
+ type InjectBaseHeaders<D> = (req: InternalAxiosRequestConfig, context: ClientContextProvider, cookiesHelper: CookiesHelper) => Promise<InternalAxiosRequestConfig<D>>;
11
11
  type TInjectGeoCoordinates = <D extends {
12
12
  geo_coordinates: GeoCoordinates;
13
13
  }>(req: InternalAxiosRequestConfig<D>, geoCoordinates: GeoCoordinates) => InternalAxiosRequestConfig<D>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ggez-banking-sdk",
3
- "version": "0.4.20",
3
+ "version": "0.4.22",
4
4
  "description": "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.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",