@pintahub/shopify-api 1.4.2 → 1.4.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/AdminAPI.d.ts +2 -0
- package/dist/classes/AdminAPI.js +2 -0
- package/dist/classes/admin/orders/SearchOrders.d.ts +12 -0
- package/dist/classes/admin/orders/SearchOrders.js +59 -0
- package/dist/classes/admin/orders/index.d.ts +10 -0
- package/dist/classes/admin/orders/index.js +28 -0
- package/dist/utils/handleErrors.js +3 -3
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AdminProductAPIInterface } from "./admin/products";
|
|
2
2
|
import { AdminCollectionAPIInterface } from "./admin/collections";
|
|
3
3
|
import { AdminMetaObjectAPIInterface } from "./admin/metaobjects";
|
|
4
|
+
import { AdminOrderAPIInterface } from "./admin/orders";
|
|
4
5
|
export interface APIOptions extends Record<string, any> {
|
|
5
6
|
shop: string;
|
|
6
7
|
accessToken: string;
|
|
@@ -11,6 +12,7 @@ export declare class AdminAPI {
|
|
|
11
12
|
readonly product: AdminProductAPIInterface;
|
|
12
13
|
readonly collection: AdminCollectionAPIInterface;
|
|
13
14
|
readonly metaobject: AdminMetaObjectAPIInterface;
|
|
15
|
+
readonly order: AdminOrderAPIInterface;
|
|
14
16
|
constructor(options: APIOptions);
|
|
15
17
|
private _createClient;
|
|
16
18
|
}
|
package/dist/classes/AdminAPI.js
CHANGED
|
@@ -5,6 +5,7 @@ const admin_api_client_1 = require("@shopify/admin-api-client");
|
|
|
5
5
|
const products_1 = require("./admin/products");
|
|
6
6
|
const collections_1 = require("./admin/collections");
|
|
7
7
|
const metaobjects_1 = require("./admin/metaobjects");
|
|
8
|
+
const orders_1 = require("./admin/orders");
|
|
8
9
|
class AdminAPI {
|
|
9
10
|
constructor(options) {
|
|
10
11
|
this.options = options;
|
|
@@ -12,6 +13,7 @@ class AdminAPI {
|
|
|
12
13
|
this.product = new products_1.AdminProductAPI(this.client);
|
|
13
14
|
this.collection = new collections_1.AdminCollectionAPI(this.client);
|
|
14
15
|
this.metaobject = new metaobjects_1.AdminMetaObjectAPI(this.client);
|
|
16
|
+
this.order = new orders_1.AdminOrderAPI(this.client);
|
|
15
17
|
}
|
|
16
18
|
_createClient() {
|
|
17
19
|
const { shop, accessToken } = this.options;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface SearchOrdersInput extends Record<string, any> {
|
|
4
|
+
after?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SearchOrdersOutput extends Record<string, any> {
|
|
7
|
+
items: any[];
|
|
8
|
+
pageInfo: any;
|
|
9
|
+
}
|
|
10
|
+
export declare class SearchOrders extends ActionBuilder<AdminApiClient, SearchOrdersInput, SearchOrdersOutput> {
|
|
11
|
+
run(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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.SearchOrders = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
15
|
+
class SearchOrders extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const { after } = Object.assign({}, args);
|
|
19
|
+
const query = `
|
|
20
|
+
{
|
|
21
|
+
orders(first: 100, reverse: true) {
|
|
22
|
+
nodes {
|
|
23
|
+
id
|
|
24
|
+
createdAt
|
|
25
|
+
updatedAt
|
|
26
|
+
name
|
|
27
|
+
shippingAddress {
|
|
28
|
+
name
|
|
29
|
+
countryCodeV2
|
|
30
|
+
}
|
|
31
|
+
displayFulfillmentStatus
|
|
32
|
+
displayFinancialStatus
|
|
33
|
+
totalPriceSet {
|
|
34
|
+
shopMoney {
|
|
35
|
+
amount
|
|
36
|
+
currencyCode
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
pageInfo {
|
|
41
|
+
hasNextPage
|
|
42
|
+
endCursor
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
const { data, errors, extensions } = yield this.client.request(query);
|
|
48
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
49
|
+
const { orders } = Object.assign({}, data);
|
|
50
|
+
const { nodes, pageInfo } = Object.assign({}, orders);
|
|
51
|
+
const items = Array.isArray(nodes) ? nodes : [];
|
|
52
|
+
return {
|
|
53
|
+
items,
|
|
54
|
+
pageInfo
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.SearchOrders = SearchOrders;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { APIBase } from "../../APIBase";
|
|
3
|
+
import { SearchOrdersInput, SearchOrdersOutput } from "./SearchOrders";
|
|
4
|
+
export interface AdminOrderAPIInterface {
|
|
5
|
+
search(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
|
|
6
|
+
}
|
|
7
|
+
export declare class AdminOrderAPI extends APIBase<AdminApiClient> implements AdminOrderAPIInterface {
|
|
8
|
+
private _runAction;
|
|
9
|
+
search(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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.AdminOrderAPI = void 0;
|
|
13
|
+
const APIBase_1 = require("../../APIBase");
|
|
14
|
+
const SearchOrders_1 = require("./SearchOrders");
|
|
15
|
+
class AdminOrderAPI extends APIBase_1.APIBase {
|
|
16
|
+
_runAction(Action, args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const action = new Action(this.client);
|
|
19
|
+
return action.run(args);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
search(args) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return this._runAction(SearchOrders_1.SearchOrders, args);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.AdminOrderAPI = AdminOrderAPI;
|
|
@@ -14,11 +14,11 @@ const handleErrors = (errors) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
14
14
|
if (!errors)
|
|
15
15
|
return;
|
|
16
16
|
const { message, graphQLErrors } = Object.assign({}, errors);
|
|
17
|
-
if (message) {
|
|
18
|
-
throw new Error(message);
|
|
19
|
-
}
|
|
20
17
|
if (graphQLErrors) {
|
|
21
18
|
console.error('GraphQL Errors:', graphQLErrors);
|
|
22
19
|
}
|
|
20
|
+
if (message) {
|
|
21
|
+
throw new Error(message);
|
|
22
|
+
}
|
|
23
23
|
});
|
|
24
24
|
exports.handleErrors = handleErrors;
|