@bunnyapp/api-client 2.2.0 → 2.2.2
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 +1 -1
- package/package.json +1 -1
- package/src/helpers/feature-usage-create.js +5 -7
- package/src/helpers/product-create.js +40 -0
- package/src/index.js +0 -2
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -5,10 +5,8 @@ const query = `mutation featureUsageCreate ($attributes: FeatureUsageAttributes!
|
|
|
5
5
|
id
|
|
6
6
|
quantity
|
|
7
7
|
usageAt
|
|
8
|
-
|
|
8
|
+
subscription {
|
|
9
9
|
id
|
|
10
|
-
code
|
|
11
|
-
name
|
|
12
10
|
}
|
|
13
11
|
feature {
|
|
14
12
|
id
|
|
@@ -20,23 +18,23 @@ const query = `mutation featureUsageCreate ($attributes: FeatureUsageAttributes!
|
|
|
20
18
|
}`;
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
|
-
* Record feature usage for a
|
|
21
|
+
* Record feature usage for a subscription
|
|
24
22
|
* @param {string} featureCode Code for the feature that is being used
|
|
25
23
|
* @param {number} quantity Amount of usage to record
|
|
26
|
-
* @param {
|
|
24
|
+
* @param {number} subscriptionId ID of the subscription that has the usage
|
|
27
25
|
* @param {string} usageAt ISO8601 date string. Deafults to now
|
|
28
26
|
* @returns
|
|
29
27
|
*/
|
|
30
28
|
module.exports = async function (
|
|
31
29
|
featureCode,
|
|
32
30
|
quantity,
|
|
33
|
-
|
|
31
|
+
subscriptionId,
|
|
34
32
|
usageAt = null
|
|
35
33
|
) {
|
|
36
34
|
let variables = {
|
|
37
35
|
attributes: {
|
|
38
36
|
quantity: quantity,
|
|
39
|
-
|
|
37
|
+
subscriptionId: subscriptionId,
|
|
40
38
|
featureCode: featureCode,
|
|
41
39
|
},
|
|
42
40
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const query = `mutation productCreate ($attributes: ProductAttributes!) {
|
|
2
|
+
productCreate (attributes: $attributes) {
|
|
3
|
+
errors
|
|
4
|
+
product {
|
|
5
|
+
code
|
|
6
|
+
description
|
|
7
|
+
everythingInPlus
|
|
8
|
+
id
|
|
9
|
+
internalNotes
|
|
10
|
+
name
|
|
11
|
+
platformId
|
|
12
|
+
productCategoryId
|
|
13
|
+
showProductNameOnLineItem
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}`;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {object} attributes Product attributes
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
module.exports = async function (attributes) {
|
|
24
|
+
let variables = {
|
|
25
|
+
attributes: attributes,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const res = await this.query(query, variables);
|
|
29
|
+
const productCreate = res?.data?.productCreate;
|
|
30
|
+
|
|
31
|
+
if (res?.errors) {
|
|
32
|
+
throw new Error(res.errors.map((e) => e.message).join());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (productCreate?.errors) {
|
|
36
|
+
throw new Error(productCreate.errors.join());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return productCreate?.product;
|
|
40
|
+
};
|
package/src/index.js
CHANGED