@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 CHANGED
@@ -86,7 +86,7 @@ const res = await bunny.portalSessionCreate(
86
86
  );
87
87
 
88
88
  // Track usage for billing
89
- const res = await bunny.tenantUsageCreate(
89
+ const res = await bunny.featureUsageCreate(
90
90
  featureCode,
91
91
  quantity,
92
92
  tenantCode,
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.2",
4
4
  "description": "Node.js client for Bunny CRM",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -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
+ };
@@ -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");