@bunnyapp/api-client 1.0.15 → 1.0.17
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/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const query = `mutation subscriptionCancel ($ids: [ID!]!) {
|
|
2
|
+
subscriptionCancel (ids: $ids) {
|
|
3
|
+
errors
|
|
4
|
+
}
|
|
5
|
+
}`;
|
|
6
|
+
|
|
7
|
+
module.exports = async function (subscriptionId) {
|
|
8
|
+
let variables = {
|
|
9
|
+
ids: [subscriptionId],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const res = await this.query(query, variables);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
res.data &&
|
|
16
|
+
res.data.subscriptionCancel &&
|
|
17
|
+
res.data.subscriptionCancel.errors == null
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const subscriptionReinstateMutation = `mutation subscriptionReinstate ($ids: [ID!]!) {
|
|
2
|
+
subscriptionReinstate (ids: $ids) {
|
|
3
|
+
quote {
|
|
4
|
+
id
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
}`;
|
|
8
|
+
|
|
9
|
+
const quoteApplyChangesMutation = `mutation quoteApplyChanges ($quoteId: ID!, $persist: Boolean!) {
|
|
10
|
+
quoteApplyChanges (quoteId: $quoteId, persist: $persist, paymentId: $paymentId, taxes: $taxes) {
|
|
11
|
+
errors
|
|
12
|
+
subscriptions {
|
|
13
|
+
id
|
|
14
|
+
state
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}`;
|
|
18
|
+
|
|
19
|
+
module.exports = async function (subscriptionId) {
|
|
20
|
+
const res = await this.query(subscriptionReinstateMutation, {
|
|
21
|
+
ids: [subscriptionId],
|
|
22
|
+
});
|
|
23
|
+
console.log(res.data.subscriptionReinstate.quote);
|
|
24
|
+
|
|
25
|
+
const quoteId = res?.data?.subscriptionReinstate?.quote?.id;
|
|
26
|
+
|
|
27
|
+
if (!quoteId) return false;
|
|
28
|
+
|
|
29
|
+
const res2 = await this.query(quoteApplyChangesMutation, {
|
|
30
|
+
quoteId: quoteId,
|
|
31
|
+
persist: true,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return res2;
|
|
35
|
+
};
|
package/src/index.js
CHANGED
|
@@ -85,6 +85,8 @@ class Bunny {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
Bunny.prototype.createSubscription = require("./helpers/create-subscription.js");
|
|
88
|
+
Bunny.prototype.cancelSubscription = require("./helpers/cancel-subscription.js");
|
|
89
|
+
Bunny.prototype.reinstateSubscription = require("./helpers/reinstate-subscription.js");
|
|
88
90
|
Bunny.prototype.createTenant = require("./helpers/create-tenant.js");
|
|
89
91
|
Bunny.prototype.updateTenant = require("./helpers/update-tenant.js");
|
|
90
92
|
Bunny.prototype.trackUsage = require("./helpers/track-usage.js");
|