@pintahub/shopify-api 1.6.7 → 1.6.8

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,12 @@
1
+ import { ActionBuilder } from "../../ActionBuilder";
2
+ import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
3
+ export interface CreateCartInput extends Record<string, any> {
4
+ buyerIdentity?: Record<string, any>;
5
+ metafields?: Record<string, any>[];
6
+ note?: string;
7
+ }
8
+ export interface CreateCartOutput extends Record<string, any> {
9
+ }
10
+ export declare class CreateCart extends ActionBuilder<StorefrontApiClient, CreateCartInput, CreateCartOutput> {
11
+ run(args: CreateCartInput): Promise<CreateCartOutput>;
12
+ }
@@ -0,0 +1,40 @@
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.CreateCart = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const cart_1 = require("../../../fragments/cart");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class CreateCart extends ActionBuilder_1.ActionBuilder {
17
+ run(args) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const query = `
20
+ mutation cartCreate($input: CartInput) {
21
+ cartCreate(input: $input) {
22
+ cart {
23
+ ...cart
24
+ }
25
+ }
26
+ }
27
+ ${cart_1.cartFragment}
28
+ `;
29
+ const { data, errors } = yield this.client.request(query, {
30
+ variables: {
31
+ input: args
32
+ }
33
+ });
34
+ yield (0, handleErrors_1.handleErrors)(errors);
35
+ const { cartCreate } = Object.assign({}, data);
36
+ return Object.assign({}, cartCreate);
37
+ });
38
+ }
39
+ }
40
+ exports.CreateCart = CreateCart;
@@ -2,7 +2,9 @@ import { APIBase } from "../../APIBase";
2
2
  import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
3
3
  import { UpdateBuyerIdentityInput, UpdateBuyerIdentityOutput } from "./UpdateBuyerIdentity";
4
4
  import { GetCartInput, GetCartOutput } from "./GetCart";
5
+ import { CreateCartInput, CreateCartOutput } from "./CreateCart";
5
6
  export interface CartAPIInterface {
7
+ create(args: CreateCartInput): Promise<CreateCartOutput>;
6
8
  get(args: GetCartInput): Promise<GetCartOutput>;
7
9
  updateBuyer(args: UpdateBuyerIdentityInput): Promise<UpdateBuyerIdentityOutput>;
8
10
  }
@@ -10,4 +12,5 @@ export declare class CartAPI extends APIBase<StorefrontApiClient> implements Car
10
12
  private _runAction;
11
13
  updateBuyer(args: UpdateBuyerIdentityInput): Promise<UpdateBuyerIdentityOutput>;
12
14
  get(args: GetCartInput): Promise<GetCartOutput>;
15
+ create(args: CreateCartInput): Promise<CreateCartOutput>;
13
16
  }
@@ -13,6 +13,7 @@ exports.CartAPI = void 0;
13
13
  const APIBase_1 = require("../../APIBase");
14
14
  const UpdateBuyerIdentity_1 = require("./UpdateBuyerIdentity");
15
15
  const GetCart_1 = require("./GetCart");
16
+ const CreateCart_1 = require("./CreateCart");
16
17
  class CartAPI extends APIBase_1.APIBase {
17
18
  _runAction(Action, args) {
18
19
  return __awaiter(this, void 0, void 0, function* () {
@@ -30,5 +31,10 @@ class CartAPI extends APIBase_1.APIBase {
30
31
  return this._runAction(GetCart_1.GetCart, args);
31
32
  });
32
33
  }
34
+ create(args) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return this._runAction(CreateCart_1.CreateCart, args);
37
+ });
38
+ }
33
39
  }
34
40
  exports.CartAPI = CartAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "1.6.7",
3
+ "version": "1.6.8",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",