@ikonintegration/mod-license-client 0.4.6 → 2.0.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/README.md CHANGED
@@ -20,7 +20,7 @@ const API = new SMLicense({
20
20
  apiKey: config.examProvider.key, //API token on IDM.AppID format (generate from APIKey at https://runkit.com/gwdp/idm-appid-v1)
21
21
  //Must be specified when using admin or user routes
22
22
  authorizationToken: '', -- optional, IDM JWT for shared module admins and user routes -- Accepts a function to be called async and return the token
23
- namespace: ''
23
+ tenantID: ''
24
24
  });
25
25
 
26
26
  //Revoke License
@@ -52,7 +52,6 @@ The following header must be specified in every request!
52
52
  - API.order.completeOrder(orderObj, provider) - Admin and users
53
53
  - API.order.refundOrder(orderObj, provider) - Admin and users
54
54
  - API.order.cancelOrder(orderObj, provider) - Admin and users
55
- - API.order.getOrderByID(orderID) - Admin, users and services
56
55
  - API.order.getOrder(externalID, orderID) - Admin, users and services
57
56
  - API.order.getOrdersByExternalID(externalID) - Admin, users and services
58
57
  - API.order.getOrdersFromToTimestamp(from, to /*timestamps*/) - Admin and services
@@ -66,6 +65,7 @@ The following header must be specified in every request!
66
65
  - API.license.redeemLicenseByProduct(productID, externalID) - Service only
67
66
  - API.license.revokeLicense(licenseID) - Admin only
68
67
  - API.license.revokeLicenses(licenseIDs) - Admin only
68
+ - API.license.getLicenseByID(licenseID) - Admin, users and services
69
69
  - API.license.getLicense(licenseID, externalID) - Admin, users and services
70
70
  - API.license.getLicensesByExternalID(externalID) - Admin, users and services
71
71
  - API.license.getLicensesByExternalIDs(externalIDs) - Admin and services
@@ -82,13 +82,9 @@ The following header must be specified in every request!
82
82
  - API.voucher.verifyVoucher(voucherID) - Admin, users and services
83
83
  - API.voucher.getVouchers() - Admin only
84
84
 
85
- **Client:**
86
- - API.client.createClient(clientName) - Admin only
87
- - API.client.updateClient(clientName, clientID) - Admin only
88
- - API.client.deleteClient(clientID) - Admin only
89
- - API.client.getClient(clientID) - Admin only
90
- - API.client.getAllClient() - Admin only
91
-
92
85
  **Key:**
93
86
  - API.key.getAvailableKeys(externalID, numberOfLicenses) - Admin, users and services
94
- - API.key.getKey(activationKey) - Service only
87
+ - API.key.getKey(activationKey) - Service only
88
+
89
+ **Vault**
90
+ - API.vault.getVaultNonce(externalID, userInfo) - Sysadmins, Admins and users (no services here)
package/lib/Client.js CHANGED
@@ -5,10 +5,10 @@ import APIRequest from './core/Request';
5
5
  import OperationProduct from './operations/Product';
6
6
  import OperationLicense from './operations/License';
7
7
  import OperationLicenseConsumption from './operations/LicenseConsumption';
8
- import OperationClient from './operations/Client';
9
8
  import OperationOrder from './operations/Order';
10
9
  import OperationVoucher from './operations/Voucher';
11
10
  import OperationKey from './operations/Key';
11
+ import OperationVault from './operations/Vault';
12
12
  //
13
13
  export default class Client {
14
14
  /* config structure
@@ -16,20 +16,20 @@ export default class Client {
16
16
  endpoint: 'https://localhost',
17
17
  port: 9998,
18
18
  apiKey: '',
19
- namespace: '',
19
+ tenantID: '',
20
20
  authorizationToken: '' -- optional
21
21
  }
22
22
  */
23
23
  constructor(config) {
24
24
  this.config = config;
25
25
  // api operations
26
- this.client = new OperationClient(this);
27
26
  this.license = new OperationLicense(this);
28
27
  this.licenseConsumption = new OperationLicenseConsumption(this);
29
28
  this.product = new OperationProduct(this);
30
29
  this.order = new OperationOrder(this);
31
30
  this.voucher = new OperationVoucher(this);
32
31
  this.key = new OperationKey(this);
32
+ this.vault = new OperationVault(this);
33
33
  }
34
34
 
35
35
  async newBaseRequest(method) {
@@ -46,9 +46,7 @@ export default class Client {
46
46
  }
47
47
  req.appendHeader('Authorization', token);
48
48
  }
49
- if (this.config.namespace) {
50
- req.appendHeader('Namespace', this.config.namespace);
51
- }
49
+ if (this.config.tenantID) req.appendHeader('tenantID', this.config.tenantID);
52
50
  //
53
51
  req.baseURL = this.config.endpoint;
54
52
  if (this.config.port) req.baseURL += `:${this.config.port}`;
@@ -2,10 +2,11 @@ export default class Key {
2
2
  constructor(API) {
3
3
  this.api = API;
4
4
  }
5
- async getAvailableKeys(externalID, licensesCount) {
5
+ async getAvailableKeys(externalID, licensesCount, productID) {
6
6
  const req = await this.api.newBaseRequest('GET');
7
7
  req.path = '/keys/' + externalID;
8
8
  req.appendQueryParam('numberOfLicenses', licensesCount);
9
+ if (productID) req.appendQueryParam('productID', productID);
9
10
  return await req.exec();
10
11
  }
11
12
  async getKey(activationKey) {
@@ -25,6 +25,11 @@ export default class License {
25
25
  req.body = { licenseIDs };
26
26
  return await req.exec();
27
27
  }
28
+ async getLicenseByID(licenseID) {
29
+ const req = await this.api.newBaseRequest('GET');
30
+ req.path = `/license/${licenseID}`;
31
+ return await req.exec();
32
+ }
28
33
  async getLicense(licenseID, externalID) {
29
34
  const req = await this.api.newBaseRequest('GET');
30
35
  req.path = '/license/' + licenseID + '/' + externalID;
@@ -8,6 +8,9 @@ export default class Order {
8
8
  isMonerisEnabledForProduct(product) {
9
9
  return (this.getProviderFromProduct(product).indexOf('moneris') != -1);
10
10
  }
11
+ isBraintreeEnabledForProduct(product) {
12
+ return (this.getProviderFromProduct(product).indexOf('braintree') != -1);
13
+ }
11
14
  //CC/Skip order
12
15
  async preOrder(orderObj) {
13
16
  const req = await this.api.newBaseRequest('POST');
@@ -59,11 +62,6 @@ export default class Order {
59
62
  return await req.exec();
60
63
  }
61
64
  //Get order(s)
62
- async getOrderByID(orderID) {
63
- const req = await this.api.newBaseRequest('GET');
64
- req.path = `/order/${orderID}`;
65
- return await req.exec();
66
- }
67
65
  async getOrder(externalID, orderID) {
68
66
  const req = await this.api.newBaseRequest('GET');
69
67
  req.path = `/order/${externalID}/${orderID}`;
@@ -19,7 +19,7 @@ export default class Product {
19
19
  alternateTaxID: 'any?',
20
20
  //Compatibility
21
21
  id: 'any?',
22
- clientID: 'any?',
22
+ tenantID: 'any?',
23
23
  createdBy: 'any?',
24
24
  updatedBy: 'any?',
25
25
  updatedOn: 'any?',
@@ -0,0 +1,11 @@
1
+ export default class Vault {
2
+ constructor(API) {
3
+ this.api = API;
4
+ }
5
+ async getVaultNonce(externalID, userInfo) {
6
+ const req = await this.api.newBaseRequest('POST');
7
+ req.path = '/vault/nonce/' + (externalID || '');
8
+ req.body = { ...userInfo };
9
+ return await req.exec();
10
+ }
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonintegration/mod-license-client",
3
- "version": "0.4.6",
3
+ "version": "2.0.0",
4
4
  "description": "Shared module license API client",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,32 +0,0 @@
1
- export default class Client {
2
- constructor(API) {
3
- this.api = API;
4
- }
5
- async createClient(clientName) {
6
- const req = await this.api.newBaseRequest('POST');
7
- req.path = '/client/new';
8
- req.body = { name: clientName };
9
- return await req.exec();
10
- }
11
- async updateClient(clientName, clientID) {
12
- const req = await this.api.newBaseRequest('PUT');
13
- req.path = '/client/' + clientID;
14
- req.body = { name: clientName };
15
- return await req.exec();
16
- }
17
- async deleteClient(clientID) {
18
- const req = await this.api.newBaseRequest('DELETE');
19
- req.path = '/client/' + clientID;
20
- return await req.exec();
21
- }
22
- async getClient(clientID) {
23
- const req = await this.api.newBaseRequest('GET');
24
- req.path = '/client/' + clientID;
25
- return await req.exec();
26
- }
27
- async getAllClient() {
28
- const req = await this.api.newBaseRequest('GET');
29
- req.path = '/clients';
30
- return await req.exec();
31
- }
32
- }