@bunnyapp/api-client 1.0.9 → 1.0.11

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
@@ -44,14 +44,14 @@ const bunny = new BunnyClient({
44
44
  This SDK wrappers several of the common Bunny API requests.
45
45
 
46
46
  ```js
47
- bunny.createSubscription(
48
- accountName,
49
- firstName,
50
- lastName,
51
- email,
52
- productPlanCode,
53
- options
54
- );
47
+ bunny.createSubscription("productPlanCode", {
48
+ trial: true,
49
+ accountName: "accountName",
50
+ firstName: "firstName",
51
+ lastName: "lastName",
52
+ email: "email",
53
+ tenantCode: "remoteId",
54
+ });
55
55
  bunny.createTenant(name, code, platformCode, subscriptionId);
56
56
  bunny.trackUsage(featureCode, quantity, tenantCode, usageAt);
57
57
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/api-client",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Node.js client for Bunny CRM",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -1,39 +1,66 @@
1
1
  const query = `mutation subscriptionCreate ($attributes: SubscriptionAttributes!) {
2
2
  subscriptionCreate (attributes: $attributes) {
3
- errors
4
- subscription {
3
+ subscription {
4
+ id
5
+ account {
6
+ id
7
+ name
8
+ contacts {
5
9
  id
6
- trialStartDate
7
- trialEndDate
8
- startDate
9
- endDate
10
- state
11
- productPlan {
12
- name
13
- }
10
+ firstName
11
+ lastName
12
+ }
14
13
  }
14
+ trialStartDate
15
+ trialEndDate
16
+ startDate
17
+ endDate
18
+ state
19
+ plan {
20
+ code
21
+ name
22
+ }
23
+ priceList {
24
+ code
25
+ name
26
+ }
27
+ tenant {
28
+ id
29
+ code
30
+ name
31
+ }
32
+ }
33
+ errors
15
34
  }
16
35
  }`;
17
36
 
18
- module.exports = async function (
19
- accountName,
20
- firstName,
21
- lastName,
22
- email,
23
- productPlanCode,
24
- options = {}
25
- ) {
37
+ module.exports = async function (productPlanCode, options = {}) {
26
38
  let variables = {
27
39
  attributes: {
28
- accountName: accountName,
29
- firstName: firstName,
30
- lastName: lastName,
31
- email: email,
32
40
  productPlanCode: productPlanCode,
33
- tenantCode: options["tenantCode"]?.toString(),
34
- trialStartDate: options["trialStartDate"],
35
- trial: options["trial"],
41
+ trial: options["trial"] || false,
36
42
  },
37
43
  };
44
+
45
+ if (options["accountId"]) {
46
+ variables.attributes.accountId = options["accountId"];
47
+ } else {
48
+ variables.attributes.account = {
49
+ name: options["accountName"]?.toString(),
50
+ billingContact: {
51
+ firstName: options["firstName"]?.toString(),
52
+ lastName: options["lastName"]?.toString(),
53
+ email: options["email"]?.toString(),
54
+ },
55
+ };
56
+ }
57
+
58
+ if (options["tenantCode"]) {
59
+ variables.attributes.tenant = {
60
+ code: options["tenantCode"]?.toString(),
61
+ name: options["tenantName"]?.toString(),
62
+ };
63
+ }
64
+
38
65
  return this.query(query, variables);
39
66
  };