@pintahub/shopify-api 1.2.5 → 1.2.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.
- package/dist/classes/admin/shop/GetPolicyPage.d.ts +10 -0
- package/dist/classes/admin/shop/GetPolicyPage.js +47 -0
- package/dist/classes/admin/shop/index.d.ts +7 -0
- package/dist/classes/admin/shop/index.js +22 -0
- package/dist/classes/storefront/shop/GetPolicyPage.d.ts +10 -0
- package/dist/classes/storefront/shop/GetPolicyPage.js +48 -0
- package/dist/classes/storefront/shop/index.d.ts +3 -0
- package/dist/classes/storefront/shop/index.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface GetPolicyPageInput extends Record<string, any> {
|
|
4
|
+
handle: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetPolicyPageOutput extends Record<string, any> {
|
|
7
|
+
}
|
|
8
|
+
export declare class GetPolicyPage extends ActionBuilder<AdminApiClient, GetPolicyPageInput, GetPolicyPageOutput> {
|
|
9
|
+
run(args: GetPolicyPageInput): Promise<GetPolicyPageOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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.GetPolicyPage = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const mapPages = {
|
|
15
|
+
'privacy-policy': 'privacyPolicy',
|
|
16
|
+
'terms-of-service': 'termsOfService',
|
|
17
|
+
'refund-policy': 'refundPolicy',
|
|
18
|
+
'shipping-policy': 'shippingPolicy',
|
|
19
|
+
};
|
|
20
|
+
class GetPolicyPage extends ActionBuilder_1.ActionBuilder {
|
|
21
|
+
run(args) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const { handle } = args;
|
|
24
|
+
const vHandle = (handle || '').toLowerCase().trim();
|
|
25
|
+
const page = mapPages[vHandle];
|
|
26
|
+
if (!page) {
|
|
27
|
+
throw new Error(`Invalid page handle: ${handle}`);
|
|
28
|
+
}
|
|
29
|
+
const query = `
|
|
30
|
+
{
|
|
31
|
+
shop {
|
|
32
|
+
${page} {
|
|
33
|
+
body
|
|
34
|
+
title
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
const { data, errors } = yield this.client.request(query);
|
|
40
|
+
console.log('data', data);
|
|
41
|
+
console.log('data', errors);
|
|
42
|
+
const { shop } = Object.assign({}, data);
|
|
43
|
+
return Object.assign({}, shop);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.GetPolicyPage = GetPolicyPage;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { APIBase } from "../../APIBase";
|
|
3
|
+
export interface AdminShopAPIInterface {
|
|
4
|
+
}
|
|
5
|
+
export declare class AdminShopAPI extends APIBase<AdminApiClient> implements AdminShopAPIInterface {
|
|
6
|
+
private _runAction;
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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.AdminShopAPI = void 0;
|
|
13
|
+
const APIBase_1 = require("../../APIBase");
|
|
14
|
+
class AdminShopAPI extends APIBase_1.APIBase {
|
|
15
|
+
_runAction(Action, args) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const action = new Action(this.client);
|
|
18
|
+
return action.run(args);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.AdminShopAPI = AdminShopAPI;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
2
|
+
import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
|
|
3
|
+
export interface GetPolicyPageInput extends Record<string, any> {
|
|
4
|
+
handle: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetPolicyPageOutput extends Record<string, any> {
|
|
7
|
+
}
|
|
8
|
+
export declare class GetPolicyPage extends ActionBuilder<StorefrontApiClient, GetPolicyPageInput, GetPolicyPageOutput> {
|
|
9
|
+
run(args: GetPolicyPageInput): Promise<GetPolicyPageOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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.GetPolicyPage = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const mapPages = {
|
|
15
|
+
'privacy-policy': 'privacyPolicy',
|
|
16
|
+
'terms-of-service': 'termsOfService',
|
|
17
|
+
'refund-policy': 'refundPolicy',
|
|
18
|
+
'shipping-policy': 'shippingPolicy',
|
|
19
|
+
};
|
|
20
|
+
class GetPolicyPage extends ActionBuilder_1.ActionBuilder {
|
|
21
|
+
run(args) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const { handle } = args;
|
|
24
|
+
const vHandle = (handle || '').toLowerCase().trim();
|
|
25
|
+
const page = mapPages[vHandle];
|
|
26
|
+
if (!page) {
|
|
27
|
+
throw new Error(`Invalid page handle: ${handle}`);
|
|
28
|
+
}
|
|
29
|
+
const query = `
|
|
30
|
+
{
|
|
31
|
+
shop {
|
|
32
|
+
${page} {
|
|
33
|
+
id
|
|
34
|
+
handle
|
|
35
|
+
body
|
|
36
|
+
title
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
const { data } = yield this.client.request(query);
|
|
42
|
+
const { shop } = Object.assign({}, data);
|
|
43
|
+
const { [page]: pageObj } = Object.assign({}, shop);
|
|
44
|
+
return Object.assign({}, pageObj);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.GetPolicyPage = GetPolicyPage;
|
|
@@ -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 { GetShopInput, GetShopOutput } from "./GetShop";
|
|
4
|
+
import { GetPolicyPageInput, GetPolicyPageOutput } from "./GetPolicyPage";
|
|
4
5
|
export interface ShopAPIInterface {
|
|
5
6
|
get(args?: GetShopInput): Promise<GetShopOutput>;
|
|
7
|
+
getPolicyPage(args?: GetPolicyPageInput): Promise<GetPolicyPageOutput>;
|
|
6
8
|
}
|
|
7
9
|
export declare class ShopAPI extends APIBase<StorefrontApiClient> implements ShopAPIInterface {
|
|
8
10
|
private _runAction;
|
|
9
11
|
get(args?: GetShopInput): Promise<GetShopOutput>;
|
|
12
|
+
getPolicyPage(args?: GetPolicyPageInput): Promise<GetPolicyPageOutput>;
|
|
10
13
|
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ShopAPI = void 0;
|
|
13
13
|
const APIBase_1 = require("../../APIBase");
|
|
14
14
|
const GetShop_1 = require("./GetShop");
|
|
15
|
+
const GetPolicyPage_1 = require("./GetPolicyPage");
|
|
15
16
|
class ShopAPI extends APIBase_1.APIBase {
|
|
16
17
|
_runAction(Action, args) {
|
|
17
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -24,5 +25,10 @@ class ShopAPI extends APIBase_1.APIBase {
|
|
|
24
25
|
return this._runAction(GetShop_1.GetShop, args);
|
|
25
26
|
});
|
|
26
27
|
}
|
|
28
|
+
getPolicyPage(args) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return this._runAction(GetPolicyPage_1.GetPolicyPage, args);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
27
33
|
}
|
|
28
34
|
exports.ShopAPI = ShopAPI;
|