@bunnyapp/api-client 2.2.1 → 2.2.3
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 +1 -1
- package/src/helpers/product-create.js +40 -0
- package/src/index.js +1 -0
package/package.json
CHANGED
|
@@ -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
|
@@ -97,5 +97,6 @@ Bunny.prototype.featureUsageCreate = require("./helpers/feature-usage-create.js"
|
|
|
97
97
|
Bunny.prototype.portalSessionCreate = require("./helpers/portal-session-create.js");
|
|
98
98
|
Bunny.prototype.accountUpdateByTenantCode = require("./helpers/account-update-by-tenant-code.js");
|
|
99
99
|
Bunny.prototype.tenantMetricsUpdate = require("./helpers/tenant-metrics-update.js");
|
|
100
|
+
Bunny.prototype.productCreate = require("./helpers/product-create.js");
|
|
100
101
|
|
|
101
102
|
module.exports = Bunny;
|