web3-banking-system-sdk 1.0.4 → 1.0.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.
|
@@ -1,11 +1,18 @@
|
|
|
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
7
|
protected getBaseURL(): string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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;
|
|
14
|
+
getPromotionByCode(promotionCode: string): Promise<ApiResponse<PromotionDetails>>;
|
|
15
|
+
getTwitterSpotlightPostIds(): Promise<ApiResponse<TwitterSpotlightPostIdsResult>>;
|
|
16
|
+
incrementPromotionParticipants(data: GGEZGiftRewards): Promise<ApiResponse<PromotionIncrementResult>>;
|
|
10
17
|
}
|
|
11
18
|
export { PromotionService };
|
|
@@ -8,20 +8,32 @@ class PromotionService extends BaseService {
|
|
|
8
8
|
getBaseURL() {
|
|
9
9
|
return this.context.getNodeUrl();
|
|
10
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 } };
|
|
19
|
+
}
|
|
11
20
|
// #region "GET"
|
|
12
|
-
getPromotionByCode(promotionCode) {
|
|
21
|
+
async getPromotionByCode(promotionCode) {
|
|
13
22
|
const url = this.resolveURL(`/${promotionCode}`);
|
|
14
|
-
|
|
23
|
+
const response = await this.GET(url);
|
|
24
|
+
return PromotionService.flatten(response);
|
|
15
25
|
}
|
|
16
|
-
getTwitterSpotlightPostIds() {
|
|
26
|
+
async getTwitterSpotlightPostIds() {
|
|
17
27
|
const url = this.resolveURL("/spotlight/twitter");
|
|
18
|
-
|
|
28
|
+
const response = await this.GET(url);
|
|
29
|
+
return PromotionService.flatten(response);
|
|
19
30
|
}
|
|
20
31
|
// #endregion
|
|
21
32
|
// #region "PUT"
|
|
22
|
-
incrementPromotionParticipants(data) {
|
|
33
|
+
async incrementPromotionParticipants(data) {
|
|
23
34
|
const url = this.resolveURL();
|
|
24
|
-
|
|
35
|
+
const response = await this.PUT(url, data);
|
|
36
|
+
return PromotionService.flatten(response);
|
|
25
37
|
}
|
|
26
38
|
}
|
|
27
39
|
export { PromotionService };
|
|
@@ -7,7 +7,7 @@ declare const Endpoints: {
|
|
|
7
7
|
readonly Order: "v1/order";
|
|
8
8
|
readonly OpenPayd: "api/v1/openpayd";
|
|
9
9
|
readonly Organization: "v1/organization";
|
|
10
|
-
readonly Promotion: "
|
|
10
|
+
readonly Promotion: "promotion";
|
|
11
11
|
readonly Transaction: "v1/transaction";
|
|
12
12
|
readonly User: "v1/user";
|
|
13
13
|
readonly Program: "v1/program";
|
package/package.json
CHANGED