@pintahub/shopify-api 1.5.3 → 1.5.5

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,10 @@
1
+ import { ActionBuilder } from "../../ActionBuilder";
2
+ import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
3
+ export interface GetCartInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface GetCartOutput extends Record<string, any> {
7
+ }
8
+ export declare class GetCart extends ActionBuilder<StorefrontApiClient, GetCartInput, GetCartOutput> {
9
+ run(args: GetCartInput): Promise<GetCartOutput>;
10
+ }
@@ -0,0 +1,37 @@
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.GetCart = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const cart_1 = require("../../../fragments/cart");
16
+ const handleErrors_1 = require("../../../utils/handleErrors");
17
+ class GetCart extends ActionBuilder_1.ActionBuilder {
18
+ run(args) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const { id } = Object.assign({}, args);
21
+ const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Cart');
22
+ const query = `
23
+ {
24
+ cart(id: "${globalId}") {
25
+ ...cart
26
+ }
27
+ }
28
+ ${cart_1.cartFragment}
29
+ `;
30
+ const { data, errors } = yield this.client.request(query);
31
+ yield (0, handleErrors_1.handleErrors)(errors);
32
+ const { cart } = Object.assign({}, data);
33
+ return Object.assign({}, cart);
34
+ });
35
+ }
36
+ }
37
+ exports.GetCart = GetCart;
@@ -1,10 +1,13 @@
1
1
  import { APIBase } from "../../APIBase";
2
2
  import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
3
3
  import { UpdateBuyerIdentityInput, UpdateBuyerIdentityOutput } from "./UpdateBuyerIdentity";
4
+ import { GetCartInput, GetCartOutput } from "./GetCart";
4
5
  export interface CartAPIInterface {
6
+ get(args: GetCartInput): Promise<GetCartOutput>;
5
7
  updateBuyer(args: UpdateBuyerIdentityInput): Promise<UpdateBuyerIdentityOutput>;
6
8
  }
7
9
  export declare class CartAPI extends APIBase<StorefrontApiClient> implements CartAPIInterface {
8
10
  private _runAction;
9
11
  updateBuyer(args: UpdateBuyerIdentityInput): Promise<UpdateBuyerIdentityOutput>;
12
+ get(args: GetCartInput): Promise<GetCartOutput>;
10
13
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CartAPI = void 0;
13
13
  const APIBase_1 = require("../../APIBase");
14
14
  const UpdateBuyerIdentity_1 = require("./UpdateBuyerIdentity");
15
+ const GetCart_1 = require("./GetCart");
15
16
  class CartAPI extends APIBase_1.APIBase {
16
17
  _runAction(Action, args) {
17
18
  return __awaiter(this, void 0, void 0, function* () {
@@ -24,5 +25,10 @@ class CartAPI extends APIBase_1.APIBase {
24
25
  return this._runAction(UpdateBuyerIdentity_1.UpdateBuyerIdentity, args);
25
26
  });
26
27
  }
28
+ get(args) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ return this._runAction(GetCart_1.GetCart, args);
31
+ });
32
+ }
27
33
  }
28
34
  exports.CartAPI = CartAPI;
@@ -0,0 +1 @@
1
+ export declare const cartFragment = "\nfragment cart on Cart {\n id\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n }\n totalQuantity\n lines(first: 250, reverse: false) {\n nodes {\n id\n quantity\n attributes {\n value\n key\n }\n merchandise {\n ... on ProductVariant {\n title\n selectedOptions {\n name\n value\n }\n price {\n amount\n currencyCode\n }\n compareAtPrice {\n amount\n currencyCode\n }\n image {\n url(transform: {maxWidth: 300})\n altText\n width\n height\n }\n product {\n id\n title\n handle\n }\n id\n }\n }\n discountAllocations {\n discountedAmount {\n amount\n currencyCode\n }\n ... on CartAutomaticDiscountAllocation {\n __typename\n title\n }\n }\n }\n }\n discountAllocations {\n discountedAmount {\n amount\n currencyCode\n }\n ... on CartAutomaticDiscountAllocation {\n __typename\n title\n }\n }\n buyerIdentity {\n countryCode\n }\n checkoutUrl\n}\n";
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cartFragment = void 0;
4
+ exports.cartFragment = `
5
+ fragment cart on Cart {
6
+ id
7
+ cost {
8
+ subtotalAmount {
9
+ amount
10
+ currencyCode
11
+ }
12
+ totalAmount {
13
+ amount
14
+ currencyCode
15
+ }
16
+ }
17
+ totalQuantity
18
+ lines(first: 250, reverse: false) {
19
+ nodes {
20
+ id
21
+ quantity
22
+ attributes {
23
+ value
24
+ key
25
+ }
26
+ merchandise {
27
+ ... on ProductVariant {
28
+ title
29
+ selectedOptions {
30
+ name
31
+ value
32
+ }
33
+ price {
34
+ amount
35
+ currencyCode
36
+ }
37
+ compareAtPrice {
38
+ amount
39
+ currencyCode
40
+ }
41
+ image {
42
+ url(transform: {maxWidth: 300})
43
+ altText
44
+ width
45
+ height
46
+ }
47
+ product {
48
+ id
49
+ title
50
+ handle
51
+ }
52
+ id
53
+ }
54
+ }
55
+ discountAllocations {
56
+ discountedAmount {
57
+ amount
58
+ currencyCode
59
+ }
60
+ ... on CartAutomaticDiscountAllocation {
61
+ __typename
62
+ title
63
+ }
64
+ }
65
+ }
66
+ }
67
+ discountAllocations {
68
+ discountedAmount {
69
+ amount
70
+ currencyCode
71
+ }
72
+ ... on CartAutomaticDiscountAllocation {
73
+ __typename
74
+ title
75
+ }
76
+ }
77
+ buyerIdentity {
78
+ countryCode
79
+ }
80
+ checkoutUrl
81
+ }
82
+ `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",