@simpleview/sv-auth-client 6.11.0 → 6.13.1
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
|
@@ -1,3 +1,107 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { query, nullToUndefined } = require("@simpleview/sv-graphql-client");
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
class ProductInstances {
|
|
4
|
+
constructor({ graphUrl, graphServer }) {
|
|
5
|
+
this._graphUrl = graphUrl;
|
|
6
|
+
this._graphServer = graphServer;
|
|
7
|
+
}
|
|
8
|
+
async find({ filter, options, fields, context, headers }) {
|
|
9
|
+
const method = "product_instances";
|
|
10
|
+
|
|
11
|
+
context = context || this._graphServer.context;
|
|
12
|
+
|
|
13
|
+
const variables = {
|
|
14
|
+
filter,
|
|
15
|
+
options,
|
|
16
|
+
acct_id : context.acct_id
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const response = await query({
|
|
20
|
+
query : `
|
|
21
|
+
query($acct_id: String!, $filter: admin_${method}_filter, $options: admin_${method}_options) {
|
|
22
|
+
admin(acct_id: $acct_id) {
|
|
23
|
+
${method}(filter: $filter, options: $options) {
|
|
24
|
+
${fields}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`,
|
|
29
|
+
variables,
|
|
30
|
+
url : this._graphUrl,
|
|
31
|
+
token : context.token,
|
|
32
|
+
headers
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const returnData = response.admin[method];
|
|
36
|
+
|
|
37
|
+
nullToUndefined(returnData)
|
|
38
|
+
|
|
39
|
+
return returnData;
|
|
40
|
+
}
|
|
41
|
+
async upsert({ input, fields, context, headers }) {
|
|
42
|
+
const method = "product_instances_upsert";
|
|
43
|
+
|
|
44
|
+
context = context || this._graphServer.context;
|
|
45
|
+
|
|
46
|
+
const variables = {
|
|
47
|
+
input,
|
|
48
|
+
acct_id : context.acct_id
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const response = await query({
|
|
52
|
+
query : `
|
|
53
|
+
mutation($acct_id: String!, $input: admin_${method}!) {
|
|
54
|
+
admin(acct_id: $acct_id) {
|
|
55
|
+
${method}(input: $input) {
|
|
56
|
+
${fields}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`,
|
|
61
|
+
variables,
|
|
62
|
+
url : this._graphUrl,
|
|
63
|
+
token : context.token,
|
|
64
|
+
headers
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const returnData = response.admin[method];
|
|
68
|
+
|
|
69
|
+
nullToUndefined(returnData);
|
|
70
|
+
|
|
71
|
+
return returnData;
|
|
72
|
+
}
|
|
73
|
+
async remove({ filter, fields, context, headers }) {
|
|
74
|
+
const method = "product_instances_remove";
|
|
75
|
+
|
|
76
|
+
context = context || this._graphServer.context;
|
|
77
|
+
|
|
78
|
+
const variables = {
|
|
79
|
+
filter,
|
|
80
|
+
acct_id : context.acct_id
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const response = await query({
|
|
84
|
+
query : `
|
|
85
|
+
mutation($acct_id: String!, $filter: admin_${method}_filter!) {
|
|
86
|
+
admin(acct_id: $acct_id) {
|
|
87
|
+
${method}(filter: $filter) {
|
|
88
|
+
${fields}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
`,
|
|
93
|
+
variables,
|
|
94
|
+
url : this._graphUrl,
|
|
95
|
+
token : context.token,
|
|
96
|
+
headers
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const returnData = response.admin[method];
|
|
100
|
+
|
|
101
|
+
nullToUndefined(returnData);
|
|
102
|
+
|
|
103
|
+
return returnData;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
module.exports = ProductInstances;
|