@ikonintegration/mod-license-client 2.0.15 → 2.0.17

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/lib/Client.js CHANGED
@@ -1,14 +1,15 @@
1
- import { AppID } from '@ikonintegration/idmclient';
1
+ import { AppID } from "@ikonintegration/idmclient";
2
2
  //
3
- import APIRequest from './core/Request';
3
+ import APIRequest from "./core/Request";
4
4
  // API Compoenents
5
- import OperationProduct from './operations/Product';
6
- import OperationLicense from './operations/License';
7
- import OperationLicenseConsumption from './operations/LicenseConsumption';
8
- import OperationOrder from './operations/Order';
9
- import OperationVoucher from './operations/Voucher';
10
- import OperationKey from './operations/Key';
11
- import OperationVault from './operations/Vault';
5
+ import OperationCategory from "./operations/Category";
6
+ import OperationProduct from "./operations/Product";
7
+ import OperationLicense from "./operations/License";
8
+ import OperationLicenseConsumption from "./operations/LicenseConsumption";
9
+ import OperationOrder from "./operations/Order";
10
+ import OperationVoucher from "./operations/Voucher";
11
+ import OperationKey from "./operations/Key";
12
+ import OperationVault from "./operations/Vault";
12
13
  //
13
14
  export default class Client {
14
15
  /* config structure
@@ -23,6 +24,7 @@ export default class Client {
23
24
  constructor(config) {
24
25
  this.config = config;
25
26
  // api operations
27
+ this.category = new OperationCategory(this);
26
28
  this.license = new OperationLicense(this);
27
29
  this.licenseConsumption = new OperationLicenseConsumption(this);
28
30
  this.product = new OperationProduct(this);
@@ -37,16 +39,16 @@ export default class Client {
37
39
  //Auth
38
40
  if (this.config.apiKey) {
39
41
  const iToken = new AppID(null, this.config.apiKey, this.config.apiKey);
40
- req.appendHeader('API-Key', iToken.getHash());
42
+ req.appendHeader("API-Key", iToken.getHash());
41
43
  }
42
44
  if (this.config.authorizationToken) {
43
45
  let token = this.config.authorizationToken;
44
46
  if (typeof this.config.authorizationToken === "function") {
45
47
  token = await this.config.authorizationToken();
46
48
  }
47
- req.appendHeader('Authorization', token);
49
+ req.appendHeader("Authorization", token);
48
50
  }
49
- if (this.config.tenantID) req.appendHeader('tenantID', this.config.tenantID);
51
+ if (this.config.tenantID) req.appendHeader("tenantID", this.config.tenantID);
50
52
  //
51
53
  req.baseURL = this.config.endpoint;
52
54
  if (this.config.port) req.baseURL += `:${this.config.port}`;
@@ -0,0 +1,50 @@
1
+ export default class Product {
2
+ constructor(API) {
3
+ this.api = API;
4
+ }
5
+ /*
6
+ {
7
+ id: 'string',
8
+ name: 'string',
9
+ //Compatibility
10
+ id: 'any?',
11
+ clientID: 'any?',
12
+ createdBy: 'any?',
13
+ updatedBy: 'any?',
14
+ updatedOn: 'any?',
15
+ createdOn: 'any?',
16
+ }
17
+ */
18
+ async createCategory(categoryObj) {
19
+ const req = await this.api.newBaseRequest("POST");
20
+ req.path = "/category/" + categoryObj.id;
21
+ req.body = categoryObj;
22
+ return await req.exec();
23
+ }
24
+ async updateCategory(categoryObj) {
25
+ const req = await this.api.newBaseRequest("PUT");
26
+ req.path = "/category/" + categoryObj.id;
27
+ req.body = categoryObj;
28
+ return await req.exec();
29
+ }
30
+ async deleteCategory(categoryID) {
31
+ const req = await this.api.newBaseRequest("DELETE");
32
+ req.path = "/category/" + categoryID;
33
+ return await req.exec();
34
+ }
35
+ async getCategory(categoryID) {
36
+ const req = await this.api.newBaseRequest("GET");
37
+ req.path = "/category/" + categoryID;
38
+ return await req.exec();
39
+ }
40
+ async getAllClientCategories() {
41
+ const req = await this.api.newBaseRequest("GET");
42
+ req.path = "/categories/";
43
+ return await req.exec();
44
+ }
45
+ async getAllCategories() {
46
+ const req = await this.api.newBaseRequest("GET");
47
+ req.path = "/categories/all";
48
+ return await req.exec();
49
+ }
50
+ }
@@ -13,6 +13,12 @@ export default class LicenseConsumption {
13
13
  req.path = '/licenses/consumptions';
14
14
  return await req.exec();
15
15
  }
16
+ async getLicenseConsumptionsByLicenseID(licensesID) {
17
+ const req = await this.api.newBaseRequest('POST');
18
+ req.body = { IDs: licensesID };
19
+ req.path = '/licenses/consumptions/licensesID';
20
+ return await req.exec();
21
+ }
16
22
  async searchLicenseConsumption(externalID, from, to) {
17
23
  const req = await this.api.newBaseRequest('POST');
18
24
  req.body = { externalID, from, to };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonintegration/mod-license-client",
3
- "version": "2.0.15",
3
+ "version": "2.0.17",
4
4
  "description": "Shared module license API client",
5
5
  "main": "index.js",
6
6
  "scripts": {