@studyportals/campaign-management-api-interface 0.32.0 → 0.33.1-1

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.32.0",
3
+ "version": "0.33.1-1",
4
4
  "scripts": {
5
5
  "compile": "rm -fR bin && npx tsc",
6
6
  "test-u": "jest -c jest.config.unit.json --maxWorkers=1",
@@ -0,0 +1,8 @@
1
+ import { LinkType } from "../studies/enums/link-type.enum";
2
+ export declare class CreateLinkDto {
3
+ name?: string;
4
+ url: string;
5
+ description: string;
6
+ type: LinkType;
7
+ active: boolean;
8
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateLinkDto = void 0;
4
+ class CreateLinkDto {
5
+ }
6
+ exports.CreateLinkDto = CreateLinkDto;
7
+ //# sourceMappingURL=create-link.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-link.dto.js","sourceRoot":"","sources":["../../../../src/domain/links/create-link.dto.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;CAMzB;AAND,sCAMC"}
@@ -0,0 +1,5 @@
1
+ export declare enum LinkEntityType {
2
+ STUDY = "study",
3
+ ORGANISATION = "organisation",
4
+ COUNTRY = "country"
5
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LinkEntityType = void 0;
4
+ var LinkEntityType;
5
+ (function (LinkEntityType) {
6
+ LinkEntityType["STUDY"] = "study";
7
+ LinkEntityType["ORGANISATION"] = "organisation";
8
+ LinkEntityType["COUNTRY"] = "country";
9
+ })(LinkEntityType = exports.LinkEntityType || (exports.LinkEntityType = {}));
10
+ //# sourceMappingURL=link-entity-type.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-entity-type.enum.js","sourceRoot":"","sources":["../../../../src/domain/links/link-entity-type.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAIX;AAJD,WAAY,cAAc;IACzB,iCAAe,CAAA;IACf,+CAA6B,CAAA;IAC7B,qCAAmB,CAAA;AACpB,CAAC,EAJW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAIzB"}
@@ -0,0 +1,5 @@
1
+ import { LinkEntityType } from "./link-entity-type.enum";
2
+ export declare class ParentEntityDto {
3
+ id: number;
4
+ type: LinkEntityType;
5
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParentEntityDto = void 0;
4
+ class ParentEntityDto {
5
+ }
6
+ exports.ParentEntityDto = ParentEntityDto;
7
+ //# sourceMappingURL=parent-entity.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parent-entity.dto.js","sourceRoot":"","sources":["../../../../src/domain/links/parent-entity.dto.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAe;CAG3B;AAHD,0CAGC"}
@@ -0,0 +1,4 @@
1
+ import { CreateLinkDto } from "./create-link.dto";
2
+ export declare class UpdateLinkDto extends CreateLinkDto {
3
+ id: string;
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateLinkDto = void 0;
4
+ const create_link_dto_1 = require("./create-link.dto");
5
+ class UpdateLinkDto extends create_link_dto_1.CreateLinkDto {
6
+ }
7
+ exports.UpdateLinkDto = UpdateLinkDto;
8
+ //# sourceMappingURL=update-link.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-link.dto.js","sourceRoot":"","sources":["../../../../src/domain/links/update-link.dto.ts"],"names":[],"mappings":";;;AAAA,uDAAiD;AAEjD,MAAa,aAAc,SAAQ,+BAAa;CAE/C;AAFD,sCAEC"}
@@ -10,6 +10,6 @@ export declare enum LinkType {
10
10
  PIXEL = "pixel",
11
11
  YOUTUBE = "youtube",
12
12
  INSTAGRAM = "instagram",
13
- SWAPPABLE = "swappable",
13
+ MICROSITE = "microsite",
14
14
  TUITION_FEE = "tuition-fee"
15
15
  }
@@ -14,7 +14,7 @@ var LinkType;
14
14
  LinkType["PIXEL"] = "pixel";
15
15
  LinkType["YOUTUBE"] = "youtube";
16
16
  LinkType["INSTAGRAM"] = "instagram";
17
- LinkType["SWAPPABLE"] = "swappable";
17
+ LinkType["MICROSITE"] = "microsite";
18
18
  LinkType["TUITION_FEE"] = "tuition-fee";
19
19
  })(LinkType = exports.LinkType || (exports.LinkType = {}));
20
20
  //# sourceMappingURL=link-type.enum.js.map
@@ -0,0 +1,11 @@
1
+ import "reflect-metadata";
2
+ import { CreateLinkDto } from "./domain/links/create-link.dto";
3
+ import { UpdateLinkDto } from "./domain/links/update-link.dto";
4
+ import { ParentEntityDto } from "./domain/links/parent-entity.dto";
5
+ export declare class LinksCampaignManagementAPIClient {
6
+ private readonly baseUrl;
7
+ constructor(baseUrl: string);
8
+ createOrUpdateLinks(parentEntity: ParentEntityDto, linksToCreate: CreateLinkDto[], linksToUpdate: UpdateLinkDto[], jwt?: string): Promise<void>;
9
+ private postRequest;
10
+ private buildBaseUrl;
11
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LinksCampaignManagementAPIClient = void 0;
13
+ require("reflect-metadata");
14
+ const inversify_1 = require("inversify");
15
+ const superagent = require("superagent");
16
+ let LinksCampaignManagementAPIClient = class LinksCampaignManagementAPIClient {
17
+ constructor(baseUrl) {
18
+ this.baseUrl = baseUrl;
19
+ }
20
+ async createOrUpdateLinks(parentEntity, linksToCreate, linksToUpdate, jwt = "") {
21
+ const sendData = {
22
+ entityType: parentEntity.type,
23
+ entityId: parentEntity.id,
24
+ linksToCreate,
25
+ linksToUpdate
26
+ };
27
+ // update path when decided on the path and if changed
28
+ const path = 'links/create-or-update-links';
29
+ const result = await this.postRequest(path, sendData, jwt);
30
+ if (result.status !== 200) {
31
+ throw new Error("Failed to create or update links");
32
+ }
33
+ }
34
+ async postRequest(relative = "", data, jwt = "") {
35
+ return await superagent.post(this.buildBaseUrl(relative))
36
+ .set("Content-Type", "application/json")
37
+ .set("Authorization", jwt)
38
+ .send(data);
39
+ }
40
+ buildBaseUrl(relative) {
41
+ return `${this.baseUrl}/${relative}`;
42
+ }
43
+ };
44
+ LinksCampaignManagementAPIClient = __decorate([
45
+ (0, inversify_1.injectable)(),
46
+ __metadata("design:paramtypes", [String])
47
+ ], LinksCampaignManagementAPIClient);
48
+ exports.LinksCampaignManagementAPIClient = LinksCampaignManagementAPIClient;
49
+ //# sourceMappingURL=links-campaign-management-api.client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links-campaign-management-api.client.js","sourceRoot":"","sources":["../../src/links-campaign-management-api.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4BAA0B;AAM1B,yCAAuC;AAEvC,yCAAyC;AASlC,IAAM,gCAAgC,GAAtC,MAAM,gCAAgC;IAC5C,YACkB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAC7B,CAAC;IAEE,KAAK,CAAC,mBAAmB,CAC/B,YAA6B,EAC7B,aAA8B,EAC9B,aAA8B,EAC9B,MAAc,EAAE;QAEhB,MAAM,QAAQ,GAAG;YAChB,UAAU,EAAE,YAAY,CAAC,IAAI;YAC7B,QAAQ,EAAE,YAAY,CAAC,EAAE;YACzB,aAAa;YACb,aAAa;SACb,CAAC;QACF,sDAAsD;QACtD,MAAM,IAAI,GAAG,8BAA8B,CAAC;QAC5C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC3D,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACpD;IACF,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,WAAmB,EAAE,EAAE,IAAS,EAAE,GAAG,GAAG,EAAE;QACnE,OAAO,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;aACvD,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC;aACvC,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC;aACzB,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAGO,YAAY,CAAC,QAAgB;QACpC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,EAAE,CAAC;IACtC,CAAC;CACD,CAAA;AApCY,gCAAgC;IAD5C,IAAA,sBAAU,GAAE;;GACA,gCAAgC,CAoC5C;AApCY,4EAAgC"}
@@ -41,12 +41,10 @@ let OrganisationsCampaignManagementAPIClient = class OrganisationsCampaignManage
41
41
  }
42
42
  }
43
43
  async postRequest(relative = "", data, jwt = "") {
44
- const request = superagent.post(this.buildBaseUrl(relative))
45
- .set("Content-Type", "application/json");
46
- if (jwt && jwt.length > 0) {
47
- request.set("Authorization", jwt);
48
- }
49
- return await request.send(data);
44
+ return await superagent.post(this.buildBaseUrl(relative))
45
+ .set("Content-Type", "application/json")
46
+ .set("Authorization", jwt)
47
+ .send(data);
50
48
  }
51
49
  async getRequest(relative = "", jwt = "") {
52
50
  return await superagent.get(this.buildBaseUrl(relative))
@@ -1 +1 @@
1
- {"version":3,"file":"organisations-campaign-management-api.client.js","sourceRoot":"","sources":["../../src/organisations-campaign-management-api.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4BAA0B;AAG1B,yCAAuC;AAEvC,yCAAyC;AAIlC,IAAM,wCAAwC,GAA9C,MAAM,wCAAwC;IACpD,YACkB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAC7B,CAAC;IAEE,KAAK,CAAC,sBAAsB,CAAC,cAAsB,EAAE,GAAG,GAAG,EAAE;QACnE,IAAI;YACH,MAAM,IAAI,GAAG,yBAAyB,cAAc,EAAE,CAAC;YACvD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAEhD,OAAO,MAAM,CAAC,IAA8B,CAAC;SAC7C;QAAC,OAAO,KAAK,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;SAC1D;IACF,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,UAAkB,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,GAAC,EAAE;QACtE,IAAI;YACH,MAAM,IAAI,GAAG,sBAAsB,CAAC;YACpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE;gBAC3C,UAAU,EAAE,UAAU;gBACtB,KAAK,EAAE,KAAK;aACZ,EAAE,GAAG,CAAC,CAAC;YAER,OAAO,MAAM,CAAC,IAAgC,CAAC;SAC/C;QAAC,OAAO,KAAK,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,EAAE,CAAC,CAAC;SACvD;IACF,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,WAAmB,EAAE,EAAE,IAAS,EAAE,MAAc,EAAE;QAC3E,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;aAC1D,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAE1C,IAAG,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE;YACzB,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;SAClC;QAED,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,WAAmB,EAAE,EAAE,GAAG,GAAG,EAAE;QACvD,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;aACtD,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC;aACvC,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC;aACzB,IAAI,EAAE,CAAC;IACV,CAAC;IAGO,YAAY,CAAC,QAAgB;QACpC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,EAAE,CAAC;IACtC,CAAC;CACD,CAAA;AApDY,wCAAwC;IADpD,IAAA,sBAAU,GAAE;;GACA,wCAAwC,CAoDpD;AApDY,4FAAwC"}
1
+ {"version":3,"file":"organisations-campaign-management-api.client.js","sourceRoot":"","sources":["../../src/organisations-campaign-management-api.client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4BAA0B;AAG1B,yCAAuC;AAEvC,yCAAyC;AAIlC,IAAM,wCAAwC,GAA9C,MAAM,wCAAwC;IACpD,YACkB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAC7B,CAAC;IAEE,KAAK,CAAC,sBAAsB,CAAC,cAAsB,EAAE,GAAG,GAAG,EAAE;QACnE,IAAI;YACH,MAAM,IAAI,GAAG,yBAAyB,cAAc,EAAE,CAAC;YACvD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAEhD,OAAO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