ggez-banking-sdk 0.5.2 → 0.5.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.
@@ -0,0 +1,6 @@
1
+ import { BlockchainAPIConfig, ErrorHandler } from "../types";
2
+ import { BaseBlockchainService } from "./service";
3
+ declare class BlockchainAPI extends BaseBlockchainService {
4
+ constructor(config: BlockchainAPIConfig, errorHandler: ErrorHandler);
5
+ }
6
+ export { BlockchainAPI };
@@ -0,0 +1,7 @@
1
+ import { BaseBlockchainService } from "./service";
2
+ class BlockchainAPI extends BaseBlockchainService {
3
+ constructor(config, errorHandler) {
4
+ super(config, errorHandler);
5
+ }
6
+ }
7
+ export { BlockchainAPI };
@@ -0,0 +1,8 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { BlockchainAPIConfig, ErrorHandler } from "../../types";
3
+ declare abstract class BaseBlockchainService {
4
+ private readonly errorHandler;
5
+ protected readonly axiosInstance: AxiosInstance;
6
+ constructor(config: BlockchainAPIConfig, errorHandler: ErrorHandler);
7
+ }
8
+ export { BaseBlockchainService };
@@ -0,0 +1,14 @@
1
+ import axios from "axios";
2
+ class BaseBlockchainService {
3
+ errorHandler;
4
+ axiosInstance;
5
+ constructor(config, errorHandler) {
6
+ this.errorHandler = errorHandler;
7
+ this.axiosInstance = axios.create({ baseURL: config.baseUrl });
8
+ this.axiosInstance.interceptors.response.use((res) => res, (err) => {
9
+ this.errorHandler(err);
10
+ return Promise.reject(err);
11
+ });
12
+ }
13
+ }
14
+ export { BaseBlockchainService };
@@ -1,6 +1,7 @@
1
1
  export * from "./accountService";
2
2
  export * from "./authService";
3
3
  export * from "./baseService";
4
+ export * from "./baseBlockchainService";
4
5
  export * from "./blockchainService";
5
6
  export * from "./limitedService";
6
7
  export * from "./orderService";
@@ -1,6 +1,7 @@
1
1
  export * from "./accountService";
2
2
  export * from "./authService";
3
3
  export * from "./baseService";
4
+ export * from "./baseBlockchainService";
4
5
  export * from "./blockchainService";
5
6
  export * from "./limitedService";
6
7
  export * from "./orderService";
@@ -3,7 +3,9 @@ import type { ProgramServiceParameter } from "../../types";
3
3
  import type { ProgramData } from "../../types/banking/program";
4
4
  declare class ProgramService extends BaseService {
5
5
  protected endpoint: string;
6
+ private authService;
6
7
  constructor(data: ProgramServiceParameter);
8
+ private onProgramRequest;
7
9
  getSystemFeatures(): Promise<import("../..").ApiResponse<ProgramData>>;
8
10
  getBin(): Promise<import("../..").ApiResponse<ProgramData>>;
9
11
  getSignUp(): Promise<import("../..").ApiResponse<ProgramData>>;
@@ -1,9 +1,19 @@
1
1
  import { BaseService } from "./baseService";
2
2
  import { Endpoints, ProgramEndpoints } from "../../constant/constant";
3
+ import { AxiosHelper } from "../../helper";
4
+ import { AuthService } from "./authService";
3
5
  class ProgramService extends BaseService {
4
6
  endpoint = Endpoints.Program;
7
+ authService;
5
8
  constructor(data) {
6
9
  super(data);
10
+ this.authService = new AuthService(data);
11
+ this.axiosInstance.interceptors.request.use((req) => this.onProgramRequest(req));
12
+ }
13
+ // #region "Interceptors Handlers"
14
+ async onProgramRequest(req) {
15
+ await AxiosHelper.injectLimitedToken(req, this.authService, this.cookiesHelper);
16
+ return req;
7
17
  }
8
18
  //#region "GET"
9
19
  getSystemFeatures() {
@@ -0,0 +1,4 @@
1
+ type BlockchainAPIConfig = {
2
+ baseUrl: string;
3
+ };
4
+ export type { BlockchainAPIConfig };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  export type * from "./api";
2
+ export type * from "./bc-api";
2
3
  export type * from "./context";
3
4
  export type * from "./common";
4
5
  export type * from "./data";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ggez-banking-sdk",
3
- "version": "0.5.2",
3
+ "version": "0.5.6",
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",