@pintahub/shopify-api 2.1.5 → 2.1.6

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.
@@ -2,8 +2,13 @@ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types"
2
2
  import { ActionBuilder } from "../../ActionBuilder";
3
3
  import { PageInfo } from "../../../interfaces/PageInfo";
4
4
  export interface SearchOrdersInput extends Record<string, any> {
5
+ before?: string;
5
6
  after?: string;
6
- limit?: number;
7
+ first?: number;
8
+ last?: number;
9
+ query?: string;
10
+ reverse?: boolean;
11
+ sortKey?: string;
7
12
  }
8
13
  export interface SearchOrdersOutput extends Record<string, any> {
9
14
  items: any[];
@@ -15,14 +15,29 @@ const handleErrors_1 = require("../../../utils/handleErrors");
15
15
  class SearchOrders extends ActionBuilder_1.ActionBuilder {
16
16
  run(args) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
- const { after, limit } = Object.assign({}, args);
19
- const vLimit = !!limit ? parseInt(limit + '', 10) : 10;
18
+ const defaultArgs = {
19
+ first: 100,
20
+ reverse: true
21
+ };
22
+ const vArgs = Object.assign({}, defaultArgs, args);
20
23
  const query = `
21
- {
24
+ query searchOrders(
25
+ $first: Int
26
+ $last: Int
27
+ $query: String
28
+ $before: String
29
+ $after: String
30
+ $reverse: Boolean
31
+ $sortKey: OrderSortKeys
32
+ ) {
22
33
  orders(
23
- first: ${vLimit},
24
- reverse: true,
25
- ${after ? `after: "${after}"` : ''}
34
+ first: $first
35
+ sortKey: $sortKey
36
+ reverse: $reverse
37
+ query: $query
38
+ before: $before
39
+ after: $after
40
+ last: $last
26
41
  ) {
27
42
  nodes {
28
43
  id
@@ -35,7 +50,9 @@ class SearchOrders extends ActionBuilder_1.ActionBuilder {
35
50
  }
36
51
  }
37
52
  `;
38
- const { data, errors } = yield this.client.request(query);
53
+ const { data, errors } = yield this.client.request(query, {
54
+ variables: vArgs
55
+ });
39
56
  yield (0, handleErrors_1.handleErrors)(errors);
40
57
  const { orders } = Object.assign({}, data);
41
58
  const { nodes, pageInfo } = Object.assign({}, orders);
@@ -0,0 +1,10 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface GetOrderInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface GetOrderOutput extends Record<string, any> {
7
+ }
8
+ export declare class GetOrder extends ActionBuilder<AdminApiClient, GetOrderInput, GetOrderOutput> {
9
+ run(args: GetOrderInput): Promise<GetOrderOutput>;
10
+ }
@@ -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.GetOrder = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class GetOrder 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
+ createdAt
26
+ updatedAt
27
+ name
28
+ email
29
+ phone
30
+ shippingAddress {
31
+ name
32
+ countryCodeV2
33
+ }
34
+ displayFulfillmentStatus
35
+ displayFinancialStatus
36
+ totalPriceSet {
37
+ shopMoney {
38
+ amount
39
+ currencyCode
40
+ }
41
+ }
42
+ }
43
+ }
44
+ `;
45
+ const { data, errors, extensions } = yield this.client.request(query);
46
+ yield (0, handleErrors_1.handleErrors)(errors);
47
+ const { order } = Object.assign({}, data);
48
+ return Object.assign({}, order);
49
+ });
50
+ }
51
+ }
52
+ exports.GetOrder = GetOrder;
@@ -0,0 +1,14 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ import { PageInfo } from "../../../interfaces/PageInfo";
4
+ export interface SearchOrdersInput extends Record<string, any> {
5
+ after?: string;
6
+ limit?: number;
7
+ }
8
+ export interface SearchOrdersOutput extends Record<string, any> {
9
+ items: any[];
10
+ pageInfo: PageInfo;
11
+ }
12
+ export declare class SearchOrders extends ActionBuilder<AdminApiClient, SearchOrdersInput, SearchOrdersOutput> {
13
+ run(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
14
+ }
@@ -0,0 +1,50 @@
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, limit } = Object.assign({}, args);
19
+ const vLimit = !!limit ? parseInt(limit + '', 10) : 10;
20
+ const query = `
21
+ {
22
+ orders(
23
+ first: ${vLimit},
24
+ reverse: true,
25
+ ${after ? `after: "${after}"` : ''}
26
+ ) {
27
+ nodes {
28
+ id
29
+ name
30
+ }
31
+ pageInfo {
32
+ hasNextPage
33
+ endCursor
34
+ }
35
+ }
36
+ }
37
+ `;
38
+ const { data, errors } = yield this.client.request(query);
39
+ yield (0, handleErrors_1.handleErrors)(errors);
40
+ const { orders } = Object.assign({}, data);
41
+ const { nodes, pageInfo } = Object.assign({}, orders);
42
+ const items = Array.isArray(nodes) ? nodes : [];
43
+ return {
44
+ items,
45
+ pageInfo
46
+ };
47
+ });
48
+ }
49
+ }
50
+ exports.SearchOrders = SearchOrders;
@@ -0,0 +1,13 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { APIBase } from "../../APIBase";
3
+ import { SearchOrdersInput, SearchOrdersOutput } from "./SearchOrders";
4
+ import { GetOrderInput, GetOrderOutput } from "./GetOrder";
5
+ export interface AdminOrderAPIInterface {
6
+ search(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
7
+ get(args: GetOrderInput): Promise<GetOrderOutput>;
8
+ }
9
+ export declare class AdminOrderAPI extends APIBase<AdminApiClient> implements AdminOrderAPIInterface {
10
+ private _runAction;
11
+ search(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
12
+ get(args?: GetOrderInput): Promise<GetOrderOutput>;
13
+ }
@@ -0,0 +1,34 @@
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
+ const GetOrder_1 = require("./GetOrder");
16
+ class AdminOrderAPI extends APIBase_1.APIBase {
17
+ _runAction(Action, args) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const action = new Action(this.client);
20
+ return action.run(args);
21
+ });
22
+ }
23
+ search(args) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ return this._runAction(SearchOrders_1.SearchOrders, args);
26
+ });
27
+ }
28
+ get(args) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ return this._runAction(GetOrder_1.GetOrder, args);
31
+ });
32
+ }
33
+ }
34
+ exports.AdminOrderAPI = AdminOrderAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",