@bunnyapp/api-client 2.0.2 → 2.0.4

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
@@ -92,6 +92,19 @@ const res = await bunny.featureUsageCreate(
92
92
  tenantCode,
93
93
  usageAt
94
94
  );
95
+
96
+ // Update account details including billing address for acount
97
+ const res = await bunny.accountUpdateByTenantCode(
98
+ "tenantCode",
99
+ {
100
+ billingStreet: "123 Main Street",
101
+ billingCity: "Pleasantville",
102
+ billingState: "CA",
103
+ billingZip: "90210",
104
+ billingCountry: "US"
105
+ }
106
+ ).then(console.log).catch(console.error)
107
+
95
108
  ```
96
109
 
97
110
  ## Error handling
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/api-client",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Node.js client for Bunny CRM",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -0,0 +1,58 @@
1
+ const query = `mutation accountUpdate ($id: ID!, $attributes: AccountAttributes!) {
2
+ accountUpdate (id: $id, attributes: $attributes) {
3
+ account {
4
+ accountTypeId
5
+ addressValidated
6
+ annualRevenue
7
+ billingCity
8
+ billingContactId
9
+ billingCountry
10
+ billingDay
11
+ billingState
12
+ billingStreet
13
+ billingZip
14
+ code
15
+ createdAt
16
+ currencyId
17
+ description
18
+ duns
19
+ employees
20
+ entityUseCode
21
+ fax
22
+ groupId
23
+ id
24
+ industryId
25
+ name
26
+ netPaymentDays
27
+ ownerUserId
28
+ phone
29
+ shippingCity
30
+ shippingCountry
31
+ shippingState
32
+ shippingStreet
33
+ shippingZip
34
+ taxNumber
35
+ timezone
36
+ updatedAt
37
+ website
38
+ }
39
+ errors
40
+ }
41
+ }`;
42
+
43
+ module.exports = async function (tenantCode, attributes) {
44
+ let tenant = await this.tenantByCode(tenantCode);
45
+
46
+ let variables = {
47
+ id: tenant.account.id,
48
+ attributes: attributes,
49
+ };
50
+
51
+ const res = await this.query(query, variables);
52
+
53
+ if (res?.errors) {
54
+ throw new Error(res.errors.map((e) => e.message).join());
55
+ }
56
+
57
+ return res?.data?.accountUpdate?.account;
58
+ };
@@ -28,6 +28,11 @@ const query = `mutation subscriptionCreate ($attributes: SubscriptionAttributes!
28
28
  id
29
29
  code
30
30
  name
31
+ account {
32
+ id
33
+ name
34
+ billingDay
35
+ }
31
36
  }
32
37
  }
33
38
  errors
@@ -71,8 +76,6 @@ module.exports = async function (priceListCode, options = {}) {
71
76
 
72
77
  const res = await this.query(query, variables);
73
78
 
74
- console.log(res);
75
-
76
79
  if (res?.errors) {
77
80
  throw new Error(res.errors.map((e) => e.message).join());
78
81
  }
@@ -5,9 +5,40 @@ const query = `query tenant ($code: String!) {
5
5
  name
6
6
  subdomain
7
7
  account {
8
+ accountTypeId
9
+ addressValidated
10
+ annualRevenue
11
+ billingCity
12
+ billingContactId
13
+ billingCountry
14
+ billingDay
15
+ billingState
16
+ billingStreet
17
+ billingZip
18
+ code
19
+ createdAt
20
+ currencyId
21
+ description
22
+ duns
23
+ employees
24
+ entityUseCode
25
+ fax
26
+ groupId
8
27
  id
28
+ industryId
9
29
  name
10
- billingDay
30
+ netPaymentDays
31
+ ownerUserId
32
+ phone
33
+ shippingCity
34
+ shippingCountry
35
+ shippingState
36
+ shippingStreet
37
+ shippingZip
38
+ taxNumber
39
+ timezone
40
+ updatedAt
41
+ website
11
42
  }
12
43
  latestProvisioningChange {
13
44
  change
package/src/index.js CHANGED
@@ -92,5 +92,6 @@ Bunny.prototype.tenantCreate = require("./helpers/tenant-create.js");
92
92
  Bunny.prototype.tenantUpdate = require("./helpers/tenant-update.js");
93
93
  Bunny.prototype.featureUsageCreate = require("./helpers/feature-usage-create.js");
94
94
  Bunny.prototype.portalSessionCreate = require("./helpers/portal-session-create.js");
95
+ Bunny.prototype.accountUpdateByTenantCode = require("./helpers/account-update-by-tenant-code.js");
95
96
 
96
97
  module.exports = Bunny;