@bunnyapp/api-client 1.0.8 → 1.0.10

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.8",
3
+ "version": "1.0.10",
4
4
  "description": "Node.js client for Bunny CRM",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -16,6 +16,7 @@
16
16
  "keywords": [
17
17
  "crm",
18
18
  "billing",
19
+ "cpq",
19
20
  "saas",
20
21
  "subscriptions"
21
22
  ],
@@ -1,39 +1,59 @@
1
1
  const query = `mutation subscriptionCreate ($attributes: SubscriptionAttributes!) {
2
2
  subscriptionCreate (attributes: $attributes) {
3
- errors
4
- subscription {
5
- id
6
- trialStartDate
7
- trialEndDate
8
- startDate
9
- endDate
10
- state
11
- productPlan {
12
- name
3
+ errors
4
+ subscription {
5
+ id
6
+ account {
7
+ name
8
+ contacts {
9
+ id
10
+ firstName
11
+ lastName
13
12
  }
14
13
  }
14
+ trialStartDate
15
+ trialEndDate
16
+ startDate
17
+ endDate
18
+ state
19
+ productPlan {
20
+ name
21
+ }
22
+ tenant {
23
+ code
24
+ name
25
+ }
26
+ }
15
27
  }
16
28
  }`;
17
29
 
18
- module.exports = async function (
19
- accountName,
20
- firstName,
21
- lastName,
22
- email,
23
- productPlanCode,
24
- options = {}
25
- ) {
30
+ module.exports = async function (productPlanCode, options = {}) {
26
31
  let variables = {
27
32
  attributes: {
28
- accountName: accountName,
29
- firstName: firstName,
30
- lastName: lastName,
31
- email: email,
32
33
  productPlanCode: productPlanCode,
33
- tenantCode: options["tenantCode"]?.toString(),
34
- trialStartDate: options["trialStartDate"],
35
- trial: options["trial"],
34
+ trial: options["trial"] || false,
36
35
  },
37
36
  };
37
+
38
+ if (options["accountId"]) {
39
+ variables.attributes.accountId = options["accountId"];
40
+ } else {
41
+ variables.attributes.account = {
42
+ name: options["accountName"]?.toString(),
43
+ billingContact: {
44
+ firstName: options["firstName"]?.toString(),
45
+ lastName: options["lastName"]?.toString(),
46
+ email: options["email"]?.toString(),
47
+ },
48
+ };
49
+ }
50
+
51
+ if (options["tenantCode"]) {
52
+ variables.attributes.tenant = {
53
+ code: options["tenantCode"]?.toString(),
54
+ name: options["tenantName"]?.toString(),
55
+ };
56
+ }
57
+
38
58
  return this.query(query, variables);
39
59
  };