@pintahub/shopify-api 2.2.8 → 2.3.0
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-v2/CreateProduct.d.ts +2 -7
- package/dist/classes/admin/products-v2/CreateProduct.js +3 -5
- package/dist/classes/admin/products-v2/CreateVariants.d.ts +14 -0
- package/dist/classes/admin/products-v2/CreateVariants.js +73 -0
- package/dist/classes/admin/products-v2/index.js +1 -1
- package/dist/classes/rest/orders/GetOrderTransaction.d.ts +1 -0
- package/dist/classes/rest/orders/GetOrderTransaction.js +9 -1
- package/dist/input/ProductCreateInput.d.ts +6 -0
- package/dist/input/ProductCreateInput.js +2 -0
- package/package.json +1 -1
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
2
|
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
import { ProductCreateInput } from "../../../input/ProductCreateInput";
|
|
3
4
|
export interface CreateProductInput extends Record<string, any> {
|
|
4
|
-
|
|
5
|
-
descriptionHtml?: string;
|
|
6
|
-
status?: string;
|
|
7
|
-
tags?: string | Array<string>;
|
|
8
|
-
productType?: string;
|
|
9
|
-
options?: Array<string>;
|
|
10
|
-
variants?: Array<Record<string, any>>;
|
|
5
|
+
product: ProductCreateInput;
|
|
11
6
|
}
|
|
12
7
|
export interface CreateProductOutput extends Record<string, any> {
|
|
13
8
|
}
|
|
@@ -16,8 +16,8 @@ class CreateProduct extends ActionBuilder_1.ActionBuilder {
|
|
|
16
16
|
run(args) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
const query = `
|
|
19
|
-
mutation productCreate($
|
|
20
|
-
productCreate(
|
|
19
|
+
mutation productCreate($product: ProductCreateInput!) {
|
|
20
|
+
productCreate(product: $product) {
|
|
21
21
|
product {
|
|
22
22
|
id
|
|
23
23
|
title
|
|
@@ -34,9 +34,7 @@ class CreateProduct extends ActionBuilder_1.ActionBuilder {
|
|
|
34
34
|
}
|
|
35
35
|
`;
|
|
36
36
|
const result = yield this.client.request(query, {
|
|
37
|
-
variables:
|
|
38
|
-
input: args
|
|
39
|
-
}
|
|
37
|
+
variables: args,
|
|
40
38
|
});
|
|
41
39
|
const { data, errors } = Object.assign({}, result);
|
|
42
40
|
yield (0, handleErrors_1.handleErrors)(errors);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
import { ProductVariantsBulkInput } from "../../../input/ProductVariantsBulkInput";
|
|
4
|
+
export interface UpdateVariantsInput extends Record<string, any> {
|
|
5
|
+
productId: string;
|
|
6
|
+
variants: Array<ProductVariantsBulkInput>;
|
|
7
|
+
}
|
|
8
|
+
export interface UpdateVariantsOutput extends Record<string, any> {
|
|
9
|
+
id: string;
|
|
10
|
+
variants: Array<Record<string, any>>;
|
|
11
|
+
}
|
|
12
|
+
export declare class CreateVariants extends ActionBuilder<AdminApiClient, UpdateVariantsInput, UpdateVariantsOutput> {
|
|
13
|
+
run(args: UpdateVariantsInput): Promise<UpdateVariantsOutput>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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.CreateVariants = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
16
|
+
class CreateVariants extends ActionBuilder_1.ActionBuilder {
|
|
17
|
+
run(args) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const { productId, variants } = args;
|
|
20
|
+
const vVariants = variants.map(variant => {
|
|
21
|
+
const { id } = variant;
|
|
22
|
+
return Object.assign(Object.assign({}, variant), { id: (0, getGlobalID_1.getGlobalID)(id, 'ProductVariant') });
|
|
23
|
+
});
|
|
24
|
+
const vArgs = Object.assign({}, args, {
|
|
25
|
+
productId: (0, getGlobalID_1.getGlobalID)(productId, 'Product'),
|
|
26
|
+
variants: vVariants
|
|
27
|
+
});
|
|
28
|
+
const query = `
|
|
29
|
+
mutation productVariantsBulkUpdate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {
|
|
30
|
+
productVariantsBulkUpdate(productId: $productId, variants: $variants) {
|
|
31
|
+
product {
|
|
32
|
+
id
|
|
33
|
+
}
|
|
34
|
+
productVariants {
|
|
35
|
+
id
|
|
36
|
+
title
|
|
37
|
+
availableForSale
|
|
38
|
+
price
|
|
39
|
+
compareAtPrice
|
|
40
|
+
inventoryItem {
|
|
41
|
+
id
|
|
42
|
+
measurement {
|
|
43
|
+
weight {
|
|
44
|
+
value
|
|
45
|
+
unit
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
taxable
|
|
50
|
+
position
|
|
51
|
+
createdAt
|
|
52
|
+
updatedAt
|
|
53
|
+
}
|
|
54
|
+
userErrors {
|
|
55
|
+
message
|
|
56
|
+
field
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
const { data, errors } = yield this.client.request(query, {
|
|
62
|
+
variables: vArgs
|
|
63
|
+
});
|
|
64
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
65
|
+
const { productVariantsBulkUpdate } = Object.assign({}, data);
|
|
66
|
+
const { product, productVariants } = Object.assign({}, productVariantsBulkUpdate);
|
|
67
|
+
return Object.assign({}, product, {
|
|
68
|
+
variants: productVariants
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.CreateVariants = CreateVariants;
|
|
@@ -21,7 +21,7 @@ const DeleteProduct_1 = require("./DeleteProduct");
|
|
|
21
21
|
const UpdateProductOption_1 = require("./UpdateProductOption");
|
|
22
22
|
const GetProductOptions_1 = require("./GetProductOptions");
|
|
23
23
|
const ReorderMedia_1 = require("./ReorderMedia");
|
|
24
|
-
const CreateProduct_1 = require("
|
|
24
|
+
const CreateProduct_1 = require("./CreateProduct");
|
|
25
25
|
class AdminProductsAPI extends APIBase_1.APIBase {
|
|
26
26
|
_runAction(Action, args) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -7,6 +7,7 @@ export interface GetOrderTransactionOutput extends Record<string, any> {
|
|
|
7
7
|
}
|
|
8
8
|
export declare class GetOrderTransaction extends ActionBuilder<AxiosInstance, GetOrderTransactionInput, GetOrderTransactionOutput> {
|
|
9
9
|
private _parseFee;
|
|
10
|
+
private _parsePaymentMethod;
|
|
10
11
|
private _parseTransaction;
|
|
11
12
|
run(args: GetOrderTransactionInput): Promise<GetOrderTransactionOutput>;
|
|
12
13
|
}
|
|
@@ -33,6 +33,12 @@ class GetOrderTransaction extends ActionBuilder_1.ActionBuilder {
|
|
|
33
33
|
}
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
|
+
_parsePaymentMethod(transaction) {
|
|
37
|
+
const { payment_details } = Object.assign({}, transaction);
|
|
38
|
+
const { payment_method_name } = Object.assign({}, payment_details);
|
|
39
|
+
const method = (payment_method_name || '').trim().toLowerCase();
|
|
40
|
+
return method || '';
|
|
41
|
+
}
|
|
36
42
|
_parseTransaction(transactions = []) {
|
|
37
43
|
const arr = Array.isArray(transactions) ? transactions : [];
|
|
38
44
|
const saleTransaction = arr.find(transaction => {
|
|
@@ -44,10 +50,12 @@ class GetOrderTransaction extends ActionBuilder_1.ActionBuilder {
|
|
|
44
50
|
}
|
|
45
51
|
const { receipt, gateway, currency } = Object.assign({}, saleTransaction);
|
|
46
52
|
const fee_amount = this._parseFee(receipt, gateway);
|
|
53
|
+
const paymentMethod = this._parsePaymentMethod(saleTransaction);
|
|
47
54
|
return {
|
|
48
55
|
gateway,
|
|
49
56
|
fee_amount,
|
|
50
|
-
currency
|
|
57
|
+
currency,
|
|
58
|
+
payment_method: paymentMethod
|
|
51
59
|
};
|
|
52
60
|
}
|
|
53
61
|
run(args) {
|