@bunnyapp/api-client 2.0.0 → 2.0.2
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 +1 -1
- package/package.json +1 -1
- package/src/helpers/tenant-by-code.js +39 -0
- package/src/helpers/tenant-create.js +0 -1
- package/src/index.js +2 -0
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const query = `query tenant ($code: String!) {
|
|
2
|
+
tenant (code: $code) {
|
|
3
|
+
id
|
|
4
|
+
code
|
|
5
|
+
name
|
|
6
|
+
subdomain
|
|
7
|
+
account {
|
|
8
|
+
id
|
|
9
|
+
name
|
|
10
|
+
billingDay
|
|
11
|
+
}
|
|
12
|
+
latestProvisioningChange {
|
|
13
|
+
change
|
|
14
|
+
createdAt
|
|
15
|
+
features
|
|
16
|
+
id
|
|
17
|
+
updatedAt
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}`;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param {string} code Unique code for the tenant
|
|
25
|
+
* @returns {object} Tenant object
|
|
26
|
+
*/
|
|
27
|
+
module.exports = async function (code) {
|
|
28
|
+
let variables = {
|
|
29
|
+
code: code,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const res = await this.query(query, variables);
|
|
33
|
+
|
|
34
|
+
if (res?.errors) {
|
|
35
|
+
throw new Error(res.errors.map((e) => e.message).join());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return res?.data?.tenant;
|
|
39
|
+
};
|
package/src/index.js
CHANGED
|
@@ -41,6 +41,7 @@ class Bunny {
|
|
|
41
41
|
return axios.request(error.config);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
console.log("Authorization error: ", error);
|
|
44
45
|
return Promise.reject("Invalid access token");
|
|
45
46
|
});
|
|
46
47
|
|
|
@@ -86,6 +87,7 @@ class Bunny {
|
|
|
86
87
|
|
|
87
88
|
Bunny.prototype.subscriptionCreate = require("./helpers/subscription-create.js");
|
|
88
89
|
Bunny.prototype.subscriptionCancel = require("./helpers/subscription-cancel.js");
|
|
90
|
+
Bunny.prototype.tenantByCode = require("./helpers/tenant-by-code.js");
|
|
89
91
|
Bunny.prototype.tenantCreate = require("./helpers/tenant-create.js");
|
|
90
92
|
Bunny.prototype.tenantUpdate = require("./helpers/tenant-update.js");
|
|
91
93
|
Bunny.prototype.featureUsageCreate = require("./helpers/feature-usage-create.js");
|