@pintahub/shopify-api 1.9.1 → 1.9.2
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/AdminAPI.d.ts +2 -0
- package/dist/classes/AdminAPI.js +2 -0
- package/dist/classes/admin/customers/CreateCustomer.d.ts +10 -0
- package/dist/classes/admin/customers/CreateCustomer.js +46 -0
- package/dist/classes/admin/customers/index.d.ts +10 -0
- package/dist/classes/admin/customers/index.js +28 -0
- package/dist/input/CustomerEmailMarketingConsentInput.d.ts +18 -0
- package/dist/input/CustomerEmailMarketingConsentInput.js +17 -0
- package/dist/input/CustomerInput.d.ts +6 -0
- package/dist/input/CustomerInput.js +2 -0
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ import { APIOptions } from "../interfaces/APIOptions";
|
|
|
6
6
|
import { AdminFileAPIInterface } from "./admin/files";
|
|
7
7
|
import { AdminMenuAPIInterface } from "./admin/menus";
|
|
8
8
|
import { AdminProductsAPIInterface } from "./admin/products-v2";
|
|
9
|
+
import { AdminCustomersAPIInterface } from "./admin/customers";
|
|
9
10
|
export declare class AdminAPI {
|
|
10
11
|
private readonly options;
|
|
11
12
|
private readonly client;
|
|
@@ -16,6 +17,7 @@ export declare class AdminAPI {
|
|
|
16
17
|
readonly files: AdminFileAPIInterface;
|
|
17
18
|
readonly menus: AdminMenuAPIInterface;
|
|
18
19
|
readonly products: AdminProductsAPIInterface;
|
|
20
|
+
readonly customers: AdminCustomersAPIInterface;
|
|
19
21
|
constructor(options: APIOptions);
|
|
20
22
|
private _createClient;
|
|
21
23
|
}
|
package/dist/classes/AdminAPI.js
CHANGED
|
@@ -9,6 +9,7 @@ const orders_1 = require("./admin/orders");
|
|
|
9
9
|
const files_1 = require("./admin/files");
|
|
10
10
|
const menus_1 = require("./admin/menus");
|
|
11
11
|
const products_v2_1 = require("./admin/products-v2");
|
|
12
|
+
const customers_1 = require("./admin/customers");
|
|
12
13
|
class AdminAPI {
|
|
13
14
|
constructor(options) {
|
|
14
15
|
this.options = options;
|
|
@@ -20,6 +21,7 @@ class AdminAPI {
|
|
|
20
21
|
this.files = new files_1.AdminFileAPI(this.client); //Start migration with plurality
|
|
21
22
|
this.menus = new menus_1.AdminMenuAPI(this._createClient('2024-07'));
|
|
22
23
|
this.products = new products_v2_1.AdminProductsAPI(this._createClient('2024-10'));
|
|
24
|
+
this.customers = new customers_1.AdminCustomersAPI(this._createClient('2024-10'));
|
|
23
25
|
}
|
|
24
26
|
_createClient(apiVersion = '2023-10') {
|
|
25
27
|
const { shop, accessToken } = this.options;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
import { CustomerInput } from "../../../input/CustomerInput";
|
|
4
|
+
export interface CreateCustomerInput extends CustomerInput {
|
|
5
|
+
}
|
|
6
|
+
export interface CreateCustomerOutput extends Record<string, any> {
|
|
7
|
+
}
|
|
8
|
+
export declare class CreateCustomer extends ActionBuilder<AdminApiClient, CreateCustomerInput, CreateCustomerOutput> {
|
|
9
|
+
run(args: CreateCustomerInput): Promise<CreateCustomerOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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.CreateCustomer = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
15
|
+
class CreateCustomer extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const query = `
|
|
19
|
+
mutation createCustomerMetafields($input: CustomerInput!) {
|
|
20
|
+
customerCreate(input: $input) {
|
|
21
|
+
customer {
|
|
22
|
+
id
|
|
23
|
+
email
|
|
24
|
+
phone
|
|
25
|
+
}
|
|
26
|
+
userErrors {
|
|
27
|
+
message
|
|
28
|
+
field
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
const result = yield this.client.request(query, {
|
|
34
|
+
variables: {
|
|
35
|
+
input: args
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const { data, errors } = Object.assign({}, result);
|
|
39
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
40
|
+
const { customerCreate } = data;
|
|
41
|
+
const { customer } = Object.assign({}, customerCreate);
|
|
42
|
+
return Object.assign({}, customer);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.CreateCustomer = CreateCustomer;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { APIBase } from "../../APIBase";
|
|
3
|
+
import { CreateCustomerInput, CreateCustomerOutput } from "./CreateCustomer";
|
|
4
|
+
export interface AdminCustomersAPIInterface {
|
|
5
|
+
create(args: CreateCustomerInput): Promise<CreateCustomerOutput>;
|
|
6
|
+
}
|
|
7
|
+
export declare class AdminCustomersAPI extends APIBase<AdminApiClient> implements AdminCustomersAPIInterface {
|
|
8
|
+
private _runAction;
|
|
9
|
+
create(args: CreateCustomerInput): Promise<CreateCustomerOutput>;
|
|
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.AdminCustomersAPI = void 0;
|
|
13
|
+
const APIBase_1 = require("../../APIBase");
|
|
14
|
+
const CreateCustomer_1 = require("./CreateCustomer");
|
|
15
|
+
class AdminCustomersAPI 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
|
+
create(args) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return this._runAction(CreateCustomer_1.CreateCustomer, args);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.AdminCustomersAPI = AdminCustomersAPI;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare enum CustomerEmailMarketingState {
|
|
2
|
+
INVALID = "INVALID",
|
|
3
|
+
NOT_SUBSCRIBED = "NOT_SUBSCRIBED",
|
|
4
|
+
PENDING = "PENDING",
|
|
5
|
+
REDACTED = "REDACTED",
|
|
6
|
+
SUBSCRIBED = "SUBSCRIBED",
|
|
7
|
+
UNSUBSCRIBED = "UNSUBSCRIBED"
|
|
8
|
+
}
|
|
9
|
+
declare enum CustomerMarketingOptInLevel {
|
|
10
|
+
UNKNOWN = "UNKNOWN",
|
|
11
|
+
SINGLE_OPT_IN = "SINGLE_OPT_IN",
|
|
12
|
+
CONFIRMED_OPT_IN = "CONFIRMED_OPT_IN"
|
|
13
|
+
}
|
|
14
|
+
export interface CustomerEmailMarketingConsentInput extends Record<string, any> {
|
|
15
|
+
marketingState?: CustomerEmailMarketingState;
|
|
16
|
+
marketingOptInLevel?: CustomerMarketingOptInLevel;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var CustomerEmailMarketingState;
|
|
4
|
+
(function (CustomerEmailMarketingState) {
|
|
5
|
+
CustomerEmailMarketingState["INVALID"] = "INVALID";
|
|
6
|
+
CustomerEmailMarketingState["NOT_SUBSCRIBED"] = "NOT_SUBSCRIBED";
|
|
7
|
+
CustomerEmailMarketingState["PENDING"] = "PENDING";
|
|
8
|
+
CustomerEmailMarketingState["REDACTED"] = "REDACTED";
|
|
9
|
+
CustomerEmailMarketingState["SUBSCRIBED"] = "SUBSCRIBED";
|
|
10
|
+
CustomerEmailMarketingState["UNSUBSCRIBED"] = "UNSUBSCRIBED";
|
|
11
|
+
})(CustomerEmailMarketingState || (CustomerEmailMarketingState = {}));
|
|
12
|
+
var CustomerMarketingOptInLevel;
|
|
13
|
+
(function (CustomerMarketingOptInLevel) {
|
|
14
|
+
CustomerMarketingOptInLevel["UNKNOWN"] = "UNKNOWN";
|
|
15
|
+
CustomerMarketingOptInLevel["SINGLE_OPT_IN"] = "SINGLE_OPT_IN";
|
|
16
|
+
CustomerMarketingOptInLevel["CONFIRMED_OPT_IN"] = "CONFIRMED_OPT_IN";
|
|
17
|
+
})(CustomerMarketingOptInLevel || (CustomerMarketingOptInLevel = {}));
|