@pintahub/shopify-api 1.0.6 → 1.0.7

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.
@@ -1,9 +1,11 @@
1
1
  import { StorefrontAPIOptions } from "../interfaces/StorefrontAPI";
2
2
  import { PageAPIInterface } from "./storefront/pages";
3
+ import { ShopAPIInterface } from "./storefront/shop";
3
4
  export declare class StorefrontAPI {
4
5
  private readonly options;
5
6
  private readonly client;
6
7
  readonly page: PageAPIInterface;
8
+ readonly shop: ShopAPIInterface;
7
9
  constructor(options: StorefrontAPIOptions);
8
10
  private _createClient;
9
11
  }
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StorefrontAPI = void 0;
4
4
  const storefront_api_client_1 = require("@shopify/storefront-api-client");
5
5
  const pages_1 = require("./storefront/pages");
6
+ const shop_1 = require("./storefront/shop");
6
7
  class StorefrontAPI {
7
8
  constructor(options) {
8
9
  this.options = options;
9
10
  this.client = this._createClient();
10
11
  this.page = new pages_1.PageAPI(this.client);
12
+ this.shop = new shop_1.ShopAPI(this.client);
11
13
  }
12
14
  _createClient() {
13
15
  const { shop, accessToken } = this.options;
@@ -0,0 +1,9 @@
1
+ import { ActionBuilder } from "../../ActionBuilder";
2
+ import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
3
+ export interface GetShopInput extends Record<string, any> {
4
+ }
5
+ export interface GetShopOutput extends Record<string, any> {
6
+ }
7
+ export declare class GetShop extends ActionBuilder<StorefrontApiClient, GetShopInput, GetShopOutput> {
8
+ run(args?: GetShopInput): Promise<GetShopOutput>;
9
+ }
@@ -0,0 +1,63 @@
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.GetShop = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ class GetShop extends ActionBuilder_1.ActionBuilder {
15
+ run(args) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const query = `
18
+ {
19
+ shop {
20
+ name
21
+ brand {
22
+ slogan
23
+ shortDescription
24
+ logo {
25
+ image {
26
+ altText
27
+ height
28
+ id
29
+ url
30
+ width
31
+ }
32
+ }
33
+ colors {
34
+ primary {
35
+ background
36
+ foreground
37
+ }
38
+ secondary {
39
+ background
40
+ foreground
41
+ }
42
+ }
43
+ }
44
+ description
45
+ paymentSettings {
46
+ acceptedCardBrands
47
+ }
48
+ primaryDomain {
49
+ host
50
+ sslEnabled
51
+ url
52
+ }
53
+ shipsToCountries
54
+ }
55
+ }
56
+ `;
57
+ const { data } = yield this.client.request(query);
58
+ console.log('data', data);
59
+ return {};
60
+ });
61
+ }
62
+ }
63
+ exports.GetShop = GetShop;
@@ -0,0 +1,10 @@
1
+ import { APIBase } from "../../APIBase";
2
+ import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
3
+ import { GetShopInput, GetShopOutput } from "./GetShop";
4
+ export interface ShopAPIInterface {
5
+ get(args?: GetShopInput): Promise<GetShopOutput>;
6
+ }
7
+ export declare class ShopAPI extends APIBase<StorefrontApiClient> implements ShopAPIInterface {
8
+ private _runAction;
9
+ get(args?: GetShopInput): Promise<GetShopOutput>;
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.ShopAPI = void 0;
13
+ const APIBase_1 = require("../../APIBase");
14
+ const GetShop_1 = require("./GetShop");
15
+ class ShopAPI 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
+ get(args) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return this._runAction(GetShop_1.GetShop, args);
25
+ });
26
+ }
27
+ }
28
+ exports.ShopAPI = ShopAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",