@pintahub/shopify-api 1.2.2 → 1.2.4
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/dist/classes/admin/products/UpdateVariant.d.ts +11 -0
- package/dist/classes/admin/products/UpdateVariant.js +44 -0
- package/dist/classes/admin/products/index.d.ts +3 -0
- package/dist/classes/admin/products/index.js +6 -0
- package/dist/classes/storefront/products/GetProduct.js +0 -3
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface UpdateVariantInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
compareAtPrice?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface UpdateVariantOutput extends Record<string, any> {
|
|
8
|
+
}
|
|
9
|
+
export declare class UpdateVariant extends ActionBuilder<AdminApiClient, UpdateVariantInput, UpdateVariantOutput> {
|
|
10
|
+
run(args: UpdateVariantInput): Promise<UpdateVariantOutput>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UpdateVariant = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
class UpdateVariant extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const { id, compareAtPrice } = args;
|
|
19
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'ProductVariant');
|
|
20
|
+
const input = `
|
|
21
|
+
input: {
|
|
22
|
+
id: "${globalId}",
|
|
23
|
+
${compareAtPrice && `compareAtPrice: "${compareAtPrice}"`}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
const query = `
|
|
27
|
+
mutation {
|
|
28
|
+
productVariantUpdate(${input}) {
|
|
29
|
+
productVariant {
|
|
30
|
+
id
|
|
31
|
+
compareAtPrice
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
const { data, errors } = yield this.client.request(query);
|
|
37
|
+
console.log('errors', errors, data);
|
|
38
|
+
const { productVariantUpdate } = Object.assign({}, data);
|
|
39
|
+
const { productVariant } = Object.assign({}, productVariantUpdate);
|
|
40
|
+
return Object.assign({}, productVariant);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.UpdateVariant = UpdateVariant;
|
|
@@ -3,14 +3,17 @@ import { APIBase } from "../../APIBase";
|
|
|
3
3
|
import { GetProductInput, GetProductOutput } from "./GetProduct";
|
|
4
4
|
import { SearchProductsInput, SearchProductsOutput } from "./SearchProducts";
|
|
5
5
|
import { GetPublicationsInput, GetPublicationsOutput } from "./GetPublications";
|
|
6
|
+
import { UpdateVariantInput, UpdateVariantOutput } from "./UpdateVariant";
|
|
6
7
|
export interface AdminProductAPIInterface {
|
|
7
8
|
get(args: GetProductInput): Promise<GetProductOutput>;
|
|
8
9
|
getPublications(args: GetPublicationsInput): Promise<GetPublicationsOutput>;
|
|
9
10
|
search(args?: SearchProductsInput): Promise<SearchProductsOutput>;
|
|
11
|
+
updateVariant(args: UpdateVariantInput): Promise<UpdateVariantOutput>;
|
|
10
12
|
}
|
|
11
13
|
export declare class AdminProductAPI extends APIBase<AdminApiClient> implements AdminProductAPIInterface {
|
|
12
14
|
private _runAction;
|
|
13
15
|
get(args: GetProductInput): Promise<GetProductOutput>;
|
|
14
16
|
getPublications(args: GetPublicationsInput): Promise<GetPublicationsOutput>;
|
|
15
17
|
search(args?: SearchProductsInput): Promise<SearchProductsOutput>;
|
|
18
|
+
updateVariant(args: UpdateVariantInput): Promise<UpdateVariantOutput>;
|
|
16
19
|
}
|
|
@@ -14,6 +14,7 @@ const APIBase_1 = require("../../APIBase");
|
|
|
14
14
|
const GetProduct_1 = require("./GetProduct");
|
|
15
15
|
const SearchProducts_1 = require("./SearchProducts");
|
|
16
16
|
const GetPublications_1 = require("./GetPublications");
|
|
17
|
+
const UpdateVariant_1 = require("./UpdateVariant");
|
|
17
18
|
class AdminProductAPI extends APIBase_1.APIBase {
|
|
18
19
|
_runAction(Action, args) {
|
|
19
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -36,5 +37,10 @@ class AdminProductAPI extends APIBase_1.APIBase {
|
|
|
36
37
|
return this._runAction(SearchProducts_1.SearchProducts, args);
|
|
37
38
|
});
|
|
38
39
|
}
|
|
40
|
+
updateVariant(args) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
return this._runAction(UpdateVariant_1.UpdateVariant, args);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
39
45
|
}
|
|
40
46
|
exports.AdminProductAPI = AdminProductAPI;
|
|
@@ -85,9 +85,6 @@ class GetProduct extends ActionBuilder_1.ActionBuilder {
|
|
|
85
85
|
`;
|
|
86
86
|
const { data } = yield this.client.request(query);
|
|
87
87
|
const { product } = Object.assign({}, data);
|
|
88
|
-
if (!product) {
|
|
89
|
-
throw new Error('Could not find product!');
|
|
90
|
-
}
|
|
91
88
|
return Object.assign({}, product);
|
|
92
89
|
});
|
|
93
90
|
}
|