web3-banking-system-sdk 1.0.6 → 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);
@@ -4,13 +4,7 @@ import type { GGEZGiftRewards, PromotionDetails, PromotionIncrementResult, Promo
4
4
  declare class PromotionService extends BaseService {
5
5
  protected endpoint: string;
6
6
  constructor(data: PromotionServiceParameters);
7
- protected getBaseURL(): string;
8
- /**
9
- * Every endpoint on this service nests its payload under `data` instead of
10
- * returning it flat — the same shape `BlockchainAPI.getBalanceAndFee` works
11
- * around. Hoist it here so every caller sees one flat result.
12
- */
13
- private static flatten;
7
+ private onPromotionRequest;
14
8
  getPromotionByCode(promotionCode: string): Promise<ApiResponse<PromotionDetails>>;
15
9
  getTwitterSpotlightPostIds(): Promise<ApiResponse<TwitterSpotlightPostIdsResult>>;
16
10
  incrementPromotionParticipants(data: GGEZGiftRewards): Promise<ApiResponse<PromotionIncrementResult>>;
@@ -4,36 +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();
10
- }
11
- /**
12
- * Every endpoint on this service nests its payload under `data` instead of
13
- * returning it flat — the same shape `BlockchainAPI.getBalanceAndFee` works
14
- * around. Hoist it here so every caller sees one flat result.
15
- */
16
- static flatten(response) {
17
- const { data: nested, ...flat } = response.data;
18
- return { ...response, data: { ...flat, ...nested } };
9
+ // #region "Interceptors Handlers"
10
+ async onPromotionRequest(req) {
11
+ req.baseURL = this.context.getNodeUrl();
12
+ return req;
19
13
  }
14
+ // #endregion
20
15
  // #region "GET"
21
16
  async getPromotionByCode(promotionCode) {
22
17
  const url = this.resolveURL(`/${promotionCode}`);
23
18
  const response = await this.GET(url);
24
- return PromotionService.flatten(response);
19
+ return response;
25
20
  }
26
21
  async getTwitterSpotlightPostIds() {
27
22
  const url = this.resolveURL("/spotlight/twitter");
28
23
  const response = await this.GET(url);
29
- return PromotionService.flatten(response);
24
+ return response;
30
25
  }
31
26
  // #endregion
32
27
  // #region "PUT"
33
28
  async incrementPromotionParticipants(data) {
34
29
  const url = this.resolveURL();
35
30
  const response = await this.PUT(url, data);
36
- return PromotionService.flatten(response);
31
+ return response;
37
32
  }
38
33
  }
39
34
  export { PromotionService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web3-banking-system-sdk",
3
- "version": "1.0.6",
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",