@pintahub/shopify-api 2.3.2 → 2.3.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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface GetOrderEventsInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetOrderEventsOutput extends Record<string, any> {
|
|
7
|
+
items: any[];
|
|
8
|
+
}
|
|
9
|
+
export declare class GetOrderEvents extends ActionBuilder<AdminApiClient, GetOrderEventsInput, GetOrderEventsOutput> {
|
|
10
|
+
run(args: GetOrderEventsInput): Promise<GetOrderEventsOutput>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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.GetOrderEvents = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
16
|
+
class GetOrderEvents extends ActionBuilder_1.ActionBuilder {
|
|
17
|
+
run(args) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const { id } = args;
|
|
20
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Order');
|
|
21
|
+
const query = `
|
|
22
|
+
{
|
|
23
|
+
order(id: "${globalId}") {
|
|
24
|
+
id
|
|
25
|
+
currencyCode
|
|
26
|
+
events(first: 10, sortKey: CREATED_AT, reverse: false) {
|
|
27
|
+
nodes {
|
|
28
|
+
id
|
|
29
|
+
message
|
|
30
|
+
... on BasicEvent {
|
|
31
|
+
action
|
|
32
|
+
arguments
|
|
33
|
+
subjectType
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
const { data, errors } = yield this.client.request(query);
|
|
41
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
42
|
+
const { order } = Object.assign({}, data);
|
|
43
|
+
const { events } = Object.assign({}, order);
|
|
44
|
+
const { nodes } = Object.assign({}, events);
|
|
45
|
+
const arr = Array.isArray(nodes) ? nodes : [];
|
|
46
|
+
return {
|
|
47
|
+
items: arr
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.GetOrderEvents = GetOrderEvents;
|
|
@@ -2,12 +2,15 @@ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types"
|
|
|
2
2
|
import { APIBase } from "../../APIBase";
|
|
3
3
|
import { SearchOrdersInput, SearchOrdersOutput } from "./SearchOrders";
|
|
4
4
|
import { GetOrderInput, GetOrderOutput } from "./GetOrder";
|
|
5
|
+
import { GetOrderEventsInput, GetOrderEventsOutput } from "./GetOrderEvents";
|
|
5
6
|
export interface AdminOrderAPIInterface {
|
|
6
7
|
search(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
|
|
7
8
|
get(args: GetOrderInput): Promise<GetOrderOutput>;
|
|
9
|
+
getEvents(args: GetOrderEventsInput): Promise<GetOrderEventsOutput>;
|
|
8
10
|
}
|
|
9
11
|
export declare class AdminOrderAPI extends APIBase<AdminApiClient> implements AdminOrderAPIInterface {
|
|
10
12
|
private _runAction;
|
|
11
13
|
search(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
|
|
12
14
|
get(args?: GetOrderInput): Promise<GetOrderOutput>;
|
|
15
|
+
getEvents(args?: GetOrderEventsInput): Promise<GetOrderEventsOutput>;
|
|
13
16
|
}
|
|
@@ -13,6 +13,7 @@ exports.AdminOrderAPI = void 0;
|
|
|
13
13
|
const APIBase_1 = require("../../APIBase");
|
|
14
14
|
const SearchOrders_1 = require("./SearchOrders");
|
|
15
15
|
const GetOrder_1 = require("./GetOrder");
|
|
16
|
+
const GetOrderEvents_1 = require("./GetOrderEvents");
|
|
16
17
|
class AdminOrderAPI extends APIBase_1.APIBase {
|
|
17
18
|
_runAction(Action, args) {
|
|
18
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -30,5 +31,10 @@ class AdminOrderAPI extends APIBase_1.APIBase {
|
|
|
30
31
|
return this._runAction(GetOrder_1.GetOrder, args);
|
|
31
32
|
});
|
|
32
33
|
}
|
|
34
|
+
getEvents(args) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
return this._runAction(GetOrderEvents_1.GetOrderEvents, args);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
exports.AdminOrderAPI = AdminOrderAPI;
|