@pintahub/shopify-api 2.2.9 → 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.
|
@@ -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;
|
|
@@ -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) {
|