UNPKG

inventora-shopify-admin-api

Version:

Shopify Admin API is a NodeJS library built to help developers easily authenticate and make calls against the Shopify API. It was inspired by and borrows heavily from ShopifySharp.

77 lines (76 loc) 2.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Customers = void 0; const infrastructure_1 = require("../infrastructure"); class Customers extends infrastructure_1.BaseService { constructor(shopDomain, accessToken) { super(shopDomain, accessToken, "customers"); } /** * Get a count of all customers */ count() { return this.createRequest("GET", "count.json", "count"); } /** * Get a list of all customers * @param options Options for filtering the results. */ list(options) { return this.createRequest("GET", ".json", "customers", options); } /** * Searches for customers that match a supplied query. * @param options Options for searching customers */ search(options) { return this.createRequest("GET", "search.json", "customers", options); } /** * Get a single customer * @param id The customer's id. * @param options Options for filtering the results. */ get(id, options) { return this.createRequest("GET", `${id}.json`, "customer", options); } /** * Creates a customer. * @param customer The customer being created. * @param options Options for creating the customer. */ create(customer) { return this.createRequest("POST", ".json", "customer", { customer: customer }); } /** * Updates a customer with the given id. * @param id The customer's id. * @param customer The updated customer. */ update(id, customer) { return this.createRequest("PUT", `${id}.json`, "customer", { customer: customer }); } /** * Deletes a customer with the given id. * @param id The customer's id. */ delete(id) { return this.createRequest("DELETE", `${id}.json`); } /** * Generate an account activation URL for a customer whose account is not yet enabled * @param id The customer's ids */ createActivationUrl(id) { return this.createRequest("POST", `${id}/account_activation_url.json`, "account_activation_url"); } /** * Sends an account invite to a customer. * @param invite Optional invitation to send */ invite(invite) { return this.createRequest("POST", "send_invite.json", "customer_invite", { customer_invite: invite }); } } exports.Customers = Customers; exports.default = Customers;