@bunnyapp/api-client 2.2.0 → 2.2.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
@@ -89,7 +89,7 @@ const res = await bunny.portalSessionCreate(
89
89
  const res = await bunny.featureUsageCreate(
90
90
  featureCode,
91
91
  quantity,
92
- tenantCode,
92
+ subscriptionId,
93
93
  usageAt
94
94
  );
95
95
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/api-client",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "Node.js client for Bunny CRM",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -5,10 +5,8 @@ const query = `mutation featureUsageCreate ($attributes: FeatureUsageAttributes!
5
5
  id
6
6
  quantity
7
7
  usageAt
8
- tenant {
8
+ subscription {
9
9
  id
10
- code
11
- name
12
10
  }
13
11
  feature {
14
12
  id
@@ -20,23 +18,23 @@ const query = `mutation featureUsageCreate ($attributes: FeatureUsageAttributes!
20
18
  }`;
21
19
 
22
20
  /**
23
- * Record feature usage for a tenant
21
+ * Record feature usage for a subscription
24
22
  * @param {string} featureCode Code for the feature that is being used
25
23
  * @param {number} quantity Amount of usage to record
26
- * @param {string} tenantCode Code for the tenant that has the usage
24
+ * @param {number} subscriptionId ID of the subscription that has the usage
27
25
  * @param {string} usageAt ISO8601 date string. Deafults to now
28
26
  * @returns
29
27
  */
30
28
  module.exports = async function (
31
29
  featureCode,
32
30
  quantity,
33
- tenantCode,
31
+ subscriptionId,
34
32
  usageAt = null
35
33
  ) {
36
34
  let variables = {
37
35
  attributes: {
38
36
  quantity: quantity,
39
- tenantCode: tenantCode,
37
+ subscriptionId: subscriptionId,
40
38
  featureCode: featureCode,
41
39
  },
42
40
  };
@@ -0,0 +1,40 @@
1
+ const query = `mutation productCreate ($attributes: ProductAttributes!) {
2
+ productCreate (attributes: $attributes) {
3
+ errors
4
+ product {
5
+ code
6
+ description
7
+ everythingInPlus
8
+ id
9
+ internalNotes
10
+ name
11
+ platformId
12
+ productCategoryId
13
+ showProductNameOnLineItem
14
+ }
15
+ }
16
+ }`;
17
+
18
+ /**
19
+ *
20
+ * @param {object} attributes Product attributes
21
+ * @returns
22
+ */
23
+ module.exports = async function (attributes) {
24
+ let variables = {
25
+ attributes: attributes,
26
+ };
27
+
28
+ const res = await this.query(query, variables);
29
+ const productCreate = res?.data?.productCreate;
30
+
31
+ if (res?.errors) {
32
+ throw new Error(res.errors.map((e) => e.message).join());
33
+ }
34
+
35
+ if (productCreate?.errors) {
36
+ throw new Error(productCreate.errors.join());
37
+ }
38
+
39
+ return productCreate?.product;
40
+ };
package/src/index.js CHANGED
@@ -41,8 +41,6 @@ class Bunny {
41
41
  return axios.request(error.config);
42
42
  }
43
43
 
44
- console.log("Authorization error: ", error);
45
-
46
44
  if (error.response?.data?.error_description) {
47
45
  return Promise.reject(error.response.data.error_description);
48
46
  }