@bunnyapp/api-client 2.0.0 → 2.0.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": "@bunnyapp/api-client",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Node.js client for Bunny CRM",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -0,0 +1,34 @@
1
+ const query = `query tenant ($code: String!) {
2
+ tenant (code: $code) {
3
+ id
4
+ code
5
+ name
6
+ subdomain
7
+ latestProvisioningChange {
8
+ change
9
+ createdAt
10
+ features
11
+ id
12
+ updatedAt
13
+ }
14
+ }
15
+ }`;
16
+
17
+ /**
18
+ *
19
+ * @param {string} code Unique code for the tenant
20
+ * @returns {object} Tenant object
21
+ */
22
+ module.exports = async function (code) {
23
+ let variables = {
24
+ code: code,
25
+ };
26
+
27
+ const res = await this.query(query, variables);
28
+
29
+ if (res?.errors) {
30
+ throw new Error(res.errors.map((e) => e.message).join());
31
+ }
32
+
33
+ return res?.data?.tenant;
34
+ };
@@ -42,7 +42,6 @@ module.exports = async function (
42
42
 
43
43
  const res = await this.query(query, variables);
44
44
 
45
- console.log(res);
46
45
  if (res?.errors) {
47
46
  throw new Error(res.errors.map((e) => e.message).join());
48
47
  }
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");