@studyportals/campaign-management-api-interface 0.4.2 → 0.5.0
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studyportals/campaign-management-api-interface",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"compile": "rm -fR bin && npx tsc",
|
|
6
6
|
"test-u": "jest -c jest.config.unit.json --silent --maxWorkers=1",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"eslint": "^8.33.0",
|
|
23
23
|
"jest": "^29.4.2",
|
|
24
24
|
"jest-mock-extended": "^3.0.1",
|
|
25
|
+
"superagent-mocker": "^0.5.2",
|
|
25
26
|
"ts-jest": "^29.0.5",
|
|
26
27
|
"ts-node": "^10.2.1"
|
|
27
28
|
},
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import { IRequestSender } from "@studyportals/mb-platform-http-requests";
|
|
3
|
-
import { ISuperAgentRequestFactory } from "@studyportals/mb-platform-http-requests/src/i-super-agent-request-factory.interface";
|
|
4
2
|
import { GetAuditorDto } from "./domain/auditor/get-auditor.dto";
|
|
5
3
|
import { AuditorOperation } from "./domain/auditor/enums/auditor-operation.enum";
|
|
6
4
|
export declare class AuditorCampaignManagementAPIClient {
|
|
7
|
-
private readonly superAgentRequestFactory;
|
|
8
|
-
private readonly requestSender;
|
|
9
5
|
private readonly baseUrl;
|
|
10
|
-
constructor(
|
|
6
|
+
constructor(baseUrl: string);
|
|
11
7
|
getCampaignAuditorData(campaignID: number): Promise<GetAuditorDto[]>;
|
|
12
8
|
storeCampaignAuditorData(operation: AuditorOperation, campaignID: number, username: string, isUserAction: boolean, data: any): Promise<GetAuditorDto>;
|
|
13
|
-
private
|
|
14
|
-
private
|
|
9
|
+
private getRequest;
|
|
10
|
+
private postRequest;
|
|
15
11
|
private buildBaseUrl;
|
|
16
12
|
}
|
|
@@ -12,16 +12,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.AuditorCampaignManagementAPIClient = void 0;
|
|
13
13
|
require("reflect-metadata");
|
|
14
14
|
const inversify_1 = require("inversify");
|
|
15
|
+
const superagent = require("superagent");
|
|
15
16
|
let AuditorCampaignManagementAPIClient = class AuditorCampaignManagementAPIClient {
|
|
16
|
-
constructor(
|
|
17
|
-
this.superAgentRequestFactory = superAgentRequestFactory;
|
|
18
|
-
this.requestSender = requestSender;
|
|
17
|
+
constructor(baseUrl) {
|
|
19
18
|
this.baseUrl = baseUrl;
|
|
20
19
|
}
|
|
21
20
|
async getCampaignAuditorData(campaignID) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
return
|
|
21
|
+
const result = await this.getRequest(`auditor/campaigns/${campaignID}`);
|
|
22
|
+
const getAuditorDtos = result.body;
|
|
23
|
+
return getAuditorDtos;
|
|
25
24
|
}
|
|
26
25
|
async storeCampaignAuditorData(operation, campaignID, username, isUserAction, data) {
|
|
27
26
|
const sendData = {
|
|
@@ -31,15 +30,14 @@ let AuditorCampaignManagementAPIClient = class AuditorCampaignManagementAPIClien
|
|
|
31
30
|
"isUserAction": isUserAction,
|
|
32
31
|
"data": data
|
|
33
32
|
};
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
return await this.requestSender.sendAndExtractBody(request);
|
|
33
|
+
const result = await this.postRequest(`auditor/campaigns`, sendData);
|
|
34
|
+
return result.body;
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
return
|
|
36
|
+
async getRequest(relative = "") {
|
|
37
|
+
return await superagent.get(this.buildBaseUrl(relative)).set("Content-Type", "application/json");
|
|
40
38
|
}
|
|
41
|
-
|
|
42
|
-
return
|
|
39
|
+
async postRequest(relative = "", data) {
|
|
40
|
+
return await superagent.post(this.buildBaseUrl(relative)).set("Content-Type", "application/json").send(data);
|
|
43
41
|
}
|
|
44
42
|
buildBaseUrl(relative) {
|
|
45
43
|
return `${this.baseUrl}/${relative}`;
|
|
@@ -47,7 +45,7 @@ let AuditorCampaignManagementAPIClient = class AuditorCampaignManagementAPIClien
|
|
|
47
45
|
};
|
|
48
46
|
AuditorCampaignManagementAPIClient = __decorate([
|
|
49
47
|
(0, inversify_1.injectable)(),
|
|
50
|
-
__metadata("design:paramtypes", [
|
|
48
|
+
__metadata("design:paramtypes", [String])
|
|
51
49
|
], AuditorCampaignManagementAPIClient);
|
|
52
50
|
exports.AuditorCampaignManagementAPIClient = AuditorCampaignManagementAPIClient;
|
|
53
51
|
//# sourceMappingURL=auditor-campaign-management-api.client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auditor-campaign-management-api.client.js","sourceRoot":"","sources":["../../src/auditor-campaign-management-api.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4BAA0B;
|
|
1
|
+
{"version":3,"file":"auditor-campaign-management-api.client.js","sourceRoot":"","sources":["../../src/auditor-campaign-management-api.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4BAA0B;AAK1B,yCAAuC;AAEvC,yCAAyC;AAGlC,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IAC3C,YACe,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAC1B,CAAC;IAEE,KAAK,CAAC,sBAAsB,CAAC,UAAkB;QAClD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC;QACxE,MAAM,cAAc,GAAG,MAAM,CAAC,IAAuB,CAAC;QAEtD,OAAO,cAAc,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,wBAAwB,CAAC,SAA2B,EAAE,UAAkB,EAAE,QAAgB,EAAE,YAAqB,EAAE,IAAS;QACrI,MAAM,QAAQ,GAAG;YACb,WAAW,EAAE,SAAS;YACtB,UAAU,EAAE,UAAU;YACtB,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