web3-banking-system-sdk 1.0.5 → 1.0.7

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.
@@ -18,7 +18,6 @@ declare abstract class BaseService {
18
18
  protected PUT<T extends BaseResult>(url: string, data: object | string, options?: ServiceRequestOptions): Promise<ApiResponse<T>>;
19
19
  protected DELETE<T extends BaseResult>(url: string, options?: ServiceRequestOptions): Promise<ApiResponse<T>>;
20
20
  protected resolveURL(path?: string | number): string;
21
- protected getBaseURL(): string | undefined;
22
21
  private buildConfig;
23
22
  private buildFlagHeaders;
24
23
  }
@@ -53,17 +53,12 @@ class BaseService {
53
53
  const normalized = p && !p.startsWith("/") ? `/${p}` : p;
54
54
  return `${this.endpoint}${normalized}`;
55
55
  }
56
- // Override in a subclass to route all its requests to a different host.
57
- // Returning undefined falls back to context.getBaseUrl() in the interceptor.
58
- getBaseURL() {
59
- return undefined;
60
- }
61
56
  // Precedence: caller `headers` > flag-derived headers; interceptor wins over both.
62
- // Caller `baseURL` > service `getBaseURL()` > context base URL.
63
57
  buildConfig(options) {
64
- const { flags, headers, ...rest } = options ?? {};
58
+ if (!options)
59
+ return {};
60
+ const { flags, headers, ...rest } = options;
65
61
  return {
66
- baseURL: this.getBaseURL(),
67
62
  ...rest,
68
63
  headers: { ...this.buildFlagHeaders(flags), ...headers },
69
64
  };
@@ -15,7 +15,8 @@ class ProgramService extends BaseService {
15
15
  await AxiosHelper.injectLimitedToken(req, this.authService, this.cookiesHelper);
16
16
  return req;
17
17
  }
18
- //#region "GET"
18
+ // #endregion
19
+ // #region "GET"
19
20
  get() {
20
21
  const url = this.resolveURL(this.context.getProgramId());
21
22
  return this.GET(url);
@@ -1,11 +1,12 @@
1
1
  import { BaseService } from "./baseService";
2
+ import type { ApiResponse } from "../../types/api/common";
2
3
  import type { GGEZGiftRewards, PromotionDetails, PromotionIncrementResult, PromotionServiceParameters, TwitterSpotlightPostIdsResult } from "../../types";
3
4
  declare class PromotionService extends BaseService {
4
5
  protected endpoint: string;
5
6
  constructor(data: PromotionServiceParameters);
6
- protected getBaseURL(): string;
7
- getPromotionByCode(promotionCode: string): Promise<import("../..").ApiResponse<PromotionDetails>>;
8
- getTwitterSpotlightPostIds(): Promise<import("../..").ApiResponse<TwitterSpotlightPostIdsResult>>;
9
- incrementPromotionParticipants(data: GGEZGiftRewards): Promise<import("../..").ApiResponse<PromotionIncrementResult>>;
7
+ private onPromotionRequest;
8
+ getPromotionByCode(promotionCode: string): Promise<ApiResponse<PromotionDetails>>;
9
+ getTwitterSpotlightPostIds(): Promise<ApiResponse<TwitterSpotlightPostIdsResult>>;
10
+ incrementPromotionParticipants(data: GGEZGiftRewards): Promise<ApiResponse<PromotionIncrementResult>>;
10
11
  }
11
12
  export { PromotionService };
@@ -4,24 +4,31 @@ class PromotionService extends BaseService {
4
4
  endpoint = Endpoints.Promotion;
5
5
  constructor(data) {
6
6
  super(data);
7
+ this.axiosInstance.interceptors.request.use((req) => this.onPromotionRequest(req));
7
8
  }
8
- getBaseURL() {
9
- return this.context.getNodeUrl();
9
+ // #region "Interceptors Handlers"
10
+ async onPromotionRequest(req) {
11
+ req.baseURL = this.context.getNodeUrl();
12
+ return req;
10
13
  }
14
+ // #endregion
11
15
  // #region "GET"
12
- getPromotionByCode(promotionCode) {
16
+ async getPromotionByCode(promotionCode) {
13
17
  const url = this.resolveURL(`/${promotionCode}`);
14
- return this.GET(url);
18
+ const response = await this.GET(url);
19
+ return response;
15
20
  }
16
- getTwitterSpotlightPostIds() {
21
+ async getTwitterSpotlightPostIds() {
17
22
  const url = this.resolveURL("/spotlight/twitter");
18
- return this.GET(url);
23
+ const response = await this.GET(url);
24
+ return response;
19
25
  }
20
26
  // #endregion
21
27
  // #region "PUT"
22
- incrementPromotionParticipants(data) {
28
+ async incrementPromotionParticipants(data) {
23
29
  const url = this.resolveURL();
24
- return this.PUT(url, data);
30
+ const response = await this.PUT(url, data);
31
+ return response;
25
32
  }
26
33
  }
27
34
  export { PromotionService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web3-banking-system-sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "TypeScript SDK used for interacting with the Web3 applications that uses Banking System API. ",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",