@bunnyapp/api-client 1.0.13 → 1.0.15

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,6 +44,7 @@ const bunny = new BunnyClient({
44
44
  This SDK wrappers several of the common Bunny API requests.
45
45
 
46
46
  ```js
47
+ // Create a new subscription
47
48
  bunny.createSubscription("priceListCode", {
48
49
  trial: true,
49
50
  accountName: "accountName",
@@ -52,7 +53,17 @@ bunny.createSubscription("priceListCode", {
52
53
  email: "email",
53
54
  tenantCode: "remoteId",
54
55
  });
55
- bunny.createTenant(name, code, platformCode, subscriptionId);
56
+
57
+ // Get a session token for the Bunny customer portal
58
+ bunny.createPortalSession("tenantCode");
59
+
60
+ // Optionally supply a return url to get back to your app
61
+ bunny.createPortalSession("tenantCode", "https://example.com");
62
+
63
+ // Default session length is 24 hours but you can change it. e.g 12 hours
64
+ bunny.createPortalSession("tenantCode", "https://example.com", 12);
65
+
66
+ // Track usage for billing
56
67
  bunny.trackUsage(featureCode, quantity, tenantCode, usageAt);
57
68
  ```
58
69
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/api-client",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Node.js client for Bunny CRM",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -0,0 +1,19 @@
1
+ const query = `mutation portalSessionCreate ($tenantCode: String!, $expiry: Int!, $returnUrl: String!) {
2
+ portalSessionCreate (tenantCode: $tenantCode, expiry: $expiry, returnUrl: $returnUrl) {
3
+ errors
4
+ token
5
+ }
6
+ }`;
7
+
8
+ module.exports = async function (
9
+ tenantCode,
10
+ returnUrl = null,
11
+ expiryInHours = 24
12
+ ) {
13
+ let variables = {
14
+ tenantCode: tenantCode,
15
+ returnUrl: returnUrl,
16
+ expiry: expiryInHours,
17
+ };
18
+ return this.query(query, variables);
19
+ };
package/src/index.js CHANGED
@@ -88,5 +88,6 @@ Bunny.prototype.createSubscription = require("./helpers/create-subscription.js")
88
88
  Bunny.prototype.createTenant = require("./helpers/create-tenant.js");
89
89
  Bunny.prototype.updateTenant = require("./helpers/update-tenant.js");
90
90
  Bunny.prototype.trackUsage = require("./helpers/track-usage.js");
91
+ Bunny.prototype.createPortalSession = require("./helpers/create-portal-session.js");
91
92
 
92
93
  module.exports = Bunny;