node-shopify
Advanced tools
Comparing version 4.4.0 to 5.0.0
@@ -1,4 +0,4 @@ | ||
import { Result } from 'node-result'; | ||
import { CarrierServiceId, CarrierService, CarrierServicesCreate } from './types/carrier_service'; | ||
import { ScriptTag, ScriptTagCreate, ScriptTagId } from './types/script_tag'; | ||
import { ResultOK, ResultFAIL } from 'node-result'; | ||
import { CarrierServiceId, CarrierService, CreateCarrierServices } from './types/carrier_service'; | ||
import { ScriptTag, CreateScriptTag, ScriptTagId } from './types/script_tag'; | ||
import { WebHook, WebHookId, CreateWebHook } from './types/webhook'; | ||
@@ -8,47 +8,49 @@ import { Shop } from './types/shop'; | ||
import { CreateCheckout, UpdateCheckout, CheckoutToken, Checkout, CheckoutShippingRates } from './types/checkout'; | ||
import { ProductId, Product, CreateProduct, UpdateProduct, ProductListing, ProductListingId } from './types/product'; | ||
import { ProductId, Product, CreateProduct, UpdateProduct, ProductListing } from './types/product'; | ||
declare type ReturnAsync<T> = Promise<ResultOK<T> | ResultFAIL<Error>>; | ||
export declare class Shopify { | ||
private readonly instance; | ||
constructor(baseUrl: string, timeout?: number); | ||
getApiToken(appApiKey: string, appSecret: string, code: string): Promise<Result<Error, { | ||
getApiToken(appApiKey: string, appSecret: string, code: string): Promise<ResultOK<{ | ||
accessToken: string; | ||
scope: string[]; | ||
}>>; | ||
getShop(): Promise<Result<Error, Shop>>; | ||
getCarrierServices(): Promise<Result<Error, CarrierService[]>>; | ||
createCarrierService(carrierServicesCreate: CarrierServicesCreate): Promise<Result<Error, CarrierService>>; | ||
getCarrierService(id: CarrierServiceId): Promise<Result<Error, CarrierService>>; | ||
deleteCarrierService(id: CarrierServiceId): Promise<Result<Error, null>>; | ||
getScriptTags(): Promise<Result<Error, ScriptTag[]>>; | ||
createScriptTag(scriptTagCreate: ScriptTagCreate): Promise<Result<Error, ScriptTag>>; | ||
getScriptTag(id: ScriptTagId): Promise<Result<Error, ScriptTag>>; | ||
deleteScriptTag(id: ScriptTagId): Promise<Result<Error, ScriptTag>>; | ||
getWebHooks(): Promise<Result<Error, WebHook[]>>; | ||
createWebHook(webHookCreate: CreateWebHook): Promise<Result<Error, WebHook>>; | ||
getWebHook(id: WebHookId): Promise<Result<Error, WebHook>>; | ||
deleteWebHook(id: WebHookId): Promise<Result<Error, null>>; | ||
getOrders(): Promise<Result<Error, Order[]>>; | ||
getOrder(id: OrderId): Promise<Result<Error, Order>>; | ||
updateOrder(id: OrderId, updateData: UpdateOrder): Promise<Result<Error, null>>; | ||
deleteOrder(id: OrderId): Promise<Result<Error, null>>; | ||
getOrderMetafields(id: OrderId): Promise<Result<Error, OrderMetafield[]>>; | ||
getOrderMetafield(orderId: OrderId, metafieldId: OrderMetafieldId): Promise<Result<Error, OrderMetafield>>; | ||
updateOrderMetafield(orderId: OrderId, metafieldId: OrderMetafieldId, updateOrderMetafield: UpdateOrderMetafield): Promise<Result<Error, OrderMetafield>>; | ||
deleteOrderMetafield(orderId: OrderId, metafieldId: OrderMetafieldId): Promise<Result<Error, null>>; | ||
createCheckout(checkoutCreate: CreateCheckout): Promise<Result<Error, Checkout>>; | ||
getCheckout(checkoutToken: CheckoutToken): Promise<Result<Error, Checkout>>; | ||
getCheckoutShippingRates(checkoutToken: CheckoutToken): Promise<Result<Error, CheckoutShippingRates[]>>; | ||
updateCheckout(checkoutToken: CheckoutToken, checkoutUpdate: UpdateCheckout): Promise<Result<Error, Checkout>>; | ||
completeCheckout(checkoutToken: CheckoutToken): Promise<Result<Error, Checkout>>; | ||
getProducts(): Promise<Result<Error, Product[]>>; | ||
getProductsCount(): Promise<Result<Error, number>>; | ||
getProduct(productId: ProductId): Promise<Result<Error, Product>>; | ||
createProduct(createProduct: CreateProduct): Promise<Result<Error, Product>>; | ||
updateProduct(productId: ProductId, updateProduct: UpdateProduct): Promise<Result<Error, Product>>; | ||
deleteProduct(productId: ProductId): Promise<Result<Error, null>>; | ||
getProductListings(): Promise<Result<Error, ProductListing[]>>; | ||
getProductListingIds(): Promise<Result<Error, ProductListingId[]>>; | ||
createProductListing(productId: ProductId): Promise<Result<Error, ProductListing>>; | ||
getProductListing(productId: ProductId): Promise<Result<Error, ProductListing>>; | ||
deleteProductListing(productId: ProductId): Promise<Result<Error, null>>; | ||
}> | ResultFAIL<Error>>; | ||
getShop(): Promise<ResultOK<Shop> | ResultFAIL<Error>>; | ||
getCarrierServices(): Promise<ResultOK<CarrierService[]> | ResultFAIL<Error>>; | ||
createCarrierService(carrierServicesCreate: CreateCarrierServices): Promise<ResultOK<CarrierService> | ResultFAIL<Error>>; | ||
getCarrierService(id: CarrierServiceId): Promise<ResultOK<CarrierService> | ResultFAIL<Error>>; | ||
deleteCarrierService(id: CarrierServiceId): ReturnAsync<null>; | ||
getScriptTags(): ReturnAsync<ScriptTag[]>; | ||
createScriptTag(scriptTagCreate: CreateScriptTag): ReturnAsync<ScriptTag>; | ||
getScriptTag(id: ScriptTagId): ReturnAsync<ScriptTag>; | ||
deleteScriptTag(id: ScriptTagId): ReturnAsync<null>; | ||
getWebHooks(): ReturnAsync<WebHook[]>; | ||
createWebHook(webHookCreate: CreateWebHook): ReturnAsync<WebHook>; | ||
getWebHook(id: WebHookId): ReturnAsync<WebHook>; | ||
deleteWebHook(id: WebHookId): ReturnAsync<null>; | ||
getOrders(): ReturnAsync<Order[]>; | ||
getOrder(id: OrderId): ReturnAsync<Order>; | ||
updateOrder(id: OrderId, updateOrder: UpdateOrder): ReturnAsync<null>; | ||
deleteOrder(id: OrderId): ReturnAsync<null>; | ||
getOrderMetafields(id: OrderId): ReturnAsync<OrderMetafield[]>; | ||
getOrderMetafield(orderId: OrderId, metafieldId: OrderMetafieldId): ReturnAsync<OrderMetafield>; | ||
updateOrderMetafield(orderId: OrderId, metafieldId: OrderMetafieldId, updateOrderMetafield: UpdateOrderMetafield): ReturnAsync<OrderMetafield>; | ||
deleteOrderMetafield(orderId: OrderId, metafieldId: OrderMetafieldId): ReturnAsync<null>; | ||
createCheckout(checkoutCreate: CreateCheckout): ReturnAsync<Checkout>; | ||
getCheckout(checkoutToken: CheckoutToken): ReturnAsync<Checkout>; | ||
getCheckoutShippingRates(checkoutToken: CheckoutToken): ReturnAsync<CheckoutShippingRates[]>; | ||
updateCheckout(checkoutToken: CheckoutToken, checkoutUpdate: UpdateCheckout): ReturnAsync<Checkout>; | ||
completeCheckout(checkoutToken: CheckoutToken): ReturnAsync<Checkout>; | ||
getProducts(): ReturnAsync<Product[]>; | ||
getProductsCount(): ReturnAsync<number>; | ||
getProduct(productId: ProductId): ReturnAsync<Product>; | ||
createProduct(createProduct: CreateProduct): ReturnAsync<Product>; | ||
updateProduct(productId: ProductId, updateProduct: UpdateProduct): ReturnAsync<Product>; | ||
deleteProduct(productId: ProductId): ReturnAsync<null>; | ||
getProductListings(): ReturnAsync<ProductListing[]>; | ||
getProductListingIds(): ReturnAsync<ProductId[]>; | ||
createProductListing(productId: ProductId): ReturnAsync<ProductListing>; | ||
getProductListing(productId: ProductId): ReturnAsync<ProductListing>; | ||
deleteProductListing(productId: ProductId): ReturnAsync<null>; | ||
} | ||
export {}; |
213
lib/index.js
@@ -26,3 +26,7 @@ "use strict"; | ||
}; | ||
const { data: { access_token, scope } } = (await this.instance.post(url, payload)).unwrap(); | ||
const { data } = (await this.instance.post(url, payload)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
const { access_token, scope } = data; | ||
return node_result_1.ResultOk({ | ||
@@ -35,9 +39,15 @@ accessToken: access_token, | ||
const url = '/admin/api/2020-10/shop.json'; | ||
const { data: { shop } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(shop); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.shop); | ||
} | ||
async getCarrierServices() { | ||
const url = '/admin/api/2020-10/carrier_services.json'; | ||
const { data: { carrier_services } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(carrier_services); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.carrier_services); | ||
} | ||
@@ -49,9 +59,15 @@ async createCarrierService(carrierServicesCreate) { | ||
}; | ||
const { data: { carrier_service } } = (await this.instance.post(url, payload)).unwrap(); | ||
return node_result_1.ResultOk(carrier_service); | ||
const { data } = (await this.instance.post(url, payload)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.carrier_service); | ||
} | ||
async getCarrierService(id) { | ||
const url = `/admin/api/2020-10/carrier_services/${id}.json`; | ||
const { data: { carrier_service } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(carrier_service); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.carrier_service); | ||
} | ||
@@ -65,4 +81,7 @@ async deleteCarrierService(id) { | ||
const url = '/admin/api/2020-07/script_tags.json'; | ||
const { data: { script_tags } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(script_tags); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.script_tags); | ||
} | ||
@@ -74,9 +93,15 @@ async createScriptTag(scriptTagCreate) { | ||
}; | ||
const { data: { script_tag } } = (await this.instance.post(url, payload)).unwrap(); | ||
return node_result_1.ResultOk(script_tag); | ||
const { data } = (await this.instance.post(url, payload)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.script_tag); | ||
} | ||
async getScriptTag(id) { | ||
const url = `/admin/api/2020-10/script_tags/${id}.json`; | ||
const { data: { script_tag } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(script_tag); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.script_tag); | ||
} | ||
@@ -90,4 +115,7 @@ async deleteScriptTag(id) { | ||
const url = '/admin/api/2020-10/webhooks.json'; | ||
const { data: { webhooks } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(webhooks); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.webhooks); | ||
} | ||
@@ -99,9 +127,15 @@ async createWebHook(webHookCreate) { | ||
}; | ||
const { data: { webhook } } = (await this.instance.post(url, payload)).unwrap(); | ||
return node_result_1.ResultOk(webhook); | ||
const { data } = (await this.instance.post(url, payload)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.webhook); | ||
} | ||
async getWebHook(id) { | ||
const url = `/admin/api/2019-10/webhooks/${id}.json`; | ||
const { data: { webhook } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(webhook); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.webhook); | ||
} | ||
@@ -115,13 +149,19 @@ async deleteWebHook(id) { | ||
const url = '/admin/api/2020-10/orders.json'; | ||
const { data: { orders } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(orders); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.orders); | ||
} | ||
async getOrder(id) { | ||
const url = `/admin/api/2020-10/orders/${id}.json`; | ||
const { data: { order } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(order); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.order); | ||
} | ||
async updateOrder(id, updateData) { | ||
async updateOrder(id, updateOrder) { | ||
const url = `/admin/api/2020-10/orders/${id}.json`; | ||
const order = Object.assign({ id }, updateData); | ||
const order = Object.assign({ id }, updateOrder); | ||
const payload = { | ||
@@ -140,9 +180,15 @@ order | ||
const url = `/admin/orders/${id}/metafields.json`; | ||
const { data: { metafields } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(metafields); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.metafields); | ||
} | ||
async getOrderMetafield(orderId, metafieldId) { | ||
const url = `/admin/orders/${orderId}/metafields/${metafieldId}.json`; | ||
const { data: { metafield } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(metafield); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.metafield); | ||
} | ||
@@ -154,4 +200,7 @@ async updateOrderMetafield(orderId, metafieldId, updateOrderMetafield) { | ||
}; | ||
const { data: { metafield } } = (await this.instance.put(url, payload)).unwrap(); | ||
return node_result_1.ResultOk(metafield); | ||
const { data } = (await this.instance.put(url, payload)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.metafield); | ||
} | ||
@@ -168,14 +217,23 @@ async deleteOrderMetafield(orderId, metafieldId) { | ||
}; | ||
const { data: { checkout } } = (await this.instance.post(url, payload)).unwrap(); | ||
return node_result_1.ResultOk(checkout); | ||
const { data } = (await this.instance.post(url, payload)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.checkout); | ||
} | ||
async getCheckout(checkoutToken) { | ||
const url = `/admin/api/2020-10/checkouts/${checkoutToken}.json`; | ||
const { data: { checkout } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(checkout); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.checkout); | ||
} | ||
async getCheckoutShippingRates(checkoutToken) { | ||
const url = `/admin/api/2020-10/checkouts/${checkoutToken}/shipping_rates.json`; | ||
const { data: { shipping_rates } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(shipping_rates); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.shipping_rates); | ||
} | ||
@@ -187,24 +245,39 @@ async updateCheckout(checkoutToken, checkoutUpdate) { | ||
}; | ||
const { data: { checkout } } = (await this.instance.put(url, payload)).unwrap(); | ||
return node_result_1.ResultOk(checkout); | ||
const { data } = (await this.instance.put(url, payload)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.checkout); | ||
} | ||
async completeCheckout(checkoutToken) { | ||
const url = `/admin/api/2020-10/checkouts/${checkoutToken}/complete.json`; | ||
const { data: { checkout } } = (await this.instance.post(url)).unwrap(); | ||
return node_result_1.ResultOk(checkout); | ||
const { data } = (await this.instance.post(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.checkout); | ||
} | ||
async getProducts() { | ||
const url = '/admin/api/2020-10/products.json'; | ||
const { data: { products } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(products); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.products); | ||
} | ||
async getProductsCount() { | ||
const url = '/admin/api/2020-10/products/count.json'; | ||
const { data: { count } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(count); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.count); | ||
} | ||
async getProduct(productId) { | ||
const url = `/admin/api/2021-01/products/${productId}.json`; | ||
const { data: { product } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(product); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.product); | ||
} | ||
@@ -214,4 +287,7 @@ async createProduct(createProduct) { | ||
const payload = { product: createProduct }; | ||
const { data: { product } } = (await this.instance.post(url, payload)).unwrap(); | ||
return node_result_1.ResultOk(product); | ||
const { data } = (await this.instance.post(url, payload)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.product); | ||
} | ||
@@ -221,4 +297,7 @@ async updateProduct(productId, updateProduct) { | ||
const payload = { product: Object.assign({ id: productId }, updateProduct) }; | ||
const { data: { product } } = (await this.instance.post(url, payload)).unwrap(); | ||
return node_result_1.ResultOk(product); | ||
const { data } = (await this.instance.post(url, payload)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.product); | ||
} | ||
@@ -232,9 +311,15 @@ async deleteProduct(productId) { | ||
const url = '/admin/api/2021-01/product_listings.json'; | ||
const { data: { product_listings } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(product_listings); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.product_listings); | ||
} | ||
async getProductListingIds() { | ||
const url = '/admin/api/2021-01/product_listings/product_ids.json'; | ||
const { data: { product_ids } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(product_ids); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.product_ids); | ||
} | ||
@@ -248,9 +333,15 @@ async createProductListing(productId) { | ||
}; | ||
const { data: { product_listing } } = (await this.instance.put(url, payload)).unwrap(); | ||
return node_result_1.ResultOk(product_listing); | ||
const { data } = (await this.instance.put(url, payload)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.product_listing); | ||
} | ||
async getProductListing(productId) { | ||
const url = `/admin/api/2021-01/product_listings/${productId}.json`; | ||
const { data: { product_listing } } = (await this.instance.get(url)).unwrap(); | ||
return node_result_1.ResultOk(product_listing); | ||
const { data } = (await this.instance.get(url)).unwrap(); | ||
if (!data) { | ||
return node_result_1.ResultFail(new Error('Response without data.')); | ||
} | ||
return node_result_1.ResultOk(data.product_listing); | ||
} | ||
@@ -257,0 +348,0 @@ async deleteProductListing(productId) { |
@@ -9,3 +9,3 @@ export declare type CarrierServiceId = number; | ||
export declare type CarrierServiceAdminGraphqlApiId = string; | ||
export declare type CarrierServicesCreate = { | ||
export declare type CreateCarrierServices = { | ||
name: CarrierServiceName; | ||
@@ -12,0 +12,0 @@ callback_url: CarrierServiceCallbackUrl; |
@@ -6,19 +6,49 @@ export declare type ProductId = number; | ||
export declare type ProductType = string; | ||
export declare type ProductTags = string[]; | ||
export declare type ProductTags = string; | ||
export declare type ProductBodyHtml = string; | ||
export declare type ProductCreatedAt = string; | ||
export declare type ProductHandle = string; | ||
export declare type ProductUpdatedAt = string; | ||
export declare type ProductPublishedAt = string; | ||
export declare type ProductStatus = 'active'; | ||
export declare type ProductPublishedScope = 'global'; | ||
export declare type ProductVariant = Record<string, never>; | ||
export declare type Product = { | ||
id: ProductId; | ||
}; | ||
export declare type CreateProduct = { | ||
title: ProductTitle; | ||
body_html: string; | ||
body_html: ProductBodyHtml | null; | ||
vendor: ProductVendor; | ||
product_type: ProductType; | ||
tags?: ProductTags; | ||
created_at: ProductCreatedAt; | ||
handle: ProductHandle; | ||
updated_at: ProductUpdatedAt; | ||
published_at: ProductPublishedAt; | ||
status: ProductStatus; | ||
published_scope: ProductPublishedScope; | ||
tags: ProductTags; | ||
variants: ProductVariant[]; | ||
}; | ||
export declare type CreateProduct = { | ||
title: ProductTitle; | ||
body_html?: string; | ||
vendor?: ProductVendor; | ||
product_type?: ProductType; | ||
tags?: string[]; | ||
published?: boolean; | ||
}; | ||
export declare type UpdateProduct = { | ||
title?: ProductTitle; | ||
}; | ||
export declare type ProductListingId = number; | ||
export declare type ProductListing = { | ||
id: ProductListingId; | ||
product_id: ProductId; | ||
created_at: ProductCreatedAt; | ||
updated_at: ProductUpdatedAt; | ||
body_html: ProductBodyHtml; | ||
handle: ProductHandle; | ||
product_type: ProductType; | ||
title: ProductTitle; | ||
vendor: ProductVendor; | ||
available: boolean; | ||
tags: ProductTags; | ||
published_at: ProductPublishedAt; | ||
}; |
export declare type ScriptTagId = number; | ||
declare type ScriptTagEvent = 'onload'; | ||
declare type ScriptTagSrc = string; | ||
declare type ScriptTagCreatedAt = string; | ||
declare type ScriptTagUpdatedAt = string; | ||
declare type ScriptTagDisplayScope = 'all'; | ||
export declare type ScriptTagCreate = { | ||
export declare type ScriptTagEvent = 'onload'; | ||
export declare type ScriptTagSrc = string; | ||
export declare type ScriptTagCreatedAt = string; | ||
export declare type ScriptTagUpdatedAt = string; | ||
export declare type ScriptTagDisplayScope = 'all'; | ||
export declare type CreateScriptTag = { | ||
event: ScriptTagEvent; | ||
@@ -19,2 +19,1 @@ src: ScriptTagSrc; | ||
}; | ||
export {}; |
export declare type ShopId = number; | ||
declare type ShopName = string; | ||
declare type ShopEmail = string; | ||
declare type ShopDomain = string; | ||
declare type ShopProvince = string; | ||
declare type ShopCountry = string; | ||
declare type ShopAddress1 = string; | ||
declare type ShopZip = string; | ||
declare type ShopCity = string; | ||
declare type ShopPhone = string; | ||
declare type ShopLatitude = number; | ||
declare type ShopLongitude = number; | ||
declare type ShopPrimaryLocale = string; | ||
declare type ShopCreatedAt = string; | ||
declare type ShopUpdatedAt = string; | ||
export declare type ShopName = string; | ||
export declare type ShopEmail = string; | ||
export declare type ShopDomain = string; | ||
export declare type ShopProvince = string; | ||
export declare type ShopCountry = string; | ||
export declare type ShopAddress1 = string; | ||
export declare type ShopZip = string; | ||
export declare type ShopCity = string; | ||
export declare type ShopPhone = string; | ||
export declare type ShopLatitude = number; | ||
export declare type ShopLongitude = number; | ||
export declare type ShopPrimaryLocale = string; | ||
export declare type ShopCreatedAt = string; | ||
export declare type ShopUpdatedAt = string; | ||
export declare type Shop = { | ||
@@ -33,2 +33,1 @@ id: ShopId; | ||
}; | ||
export {}; |
export declare type WebHookId = number; | ||
declare type WebHookTopic = 'orders/create' | 'orders/cancelled' | 'orders/fulfilled' | 'orders/paid' | 'orders/partially_fulfilled' | 'orders/updated' | 'orders/delete'; | ||
declare type WebHookAddress = string; | ||
declare type WebhookFormat = 'json' | 'xml'; | ||
export declare type WebHookTopic = 'orders/create' | 'orders/cancelled' | 'orders/fulfilled' | 'orders/paid' | 'orders/partially_fulfilled' | 'orders/updated' | 'orders/delete'; | ||
export declare type WebHookAddress = string; | ||
export declare type WebhookFormat = 'json' | 'xml'; | ||
export declare type WebHook = { | ||
@@ -13,2 +13,1 @@ id: WebHookId; | ||
}; | ||
export {}; |
{ | ||
"name": "node-shopify", | ||
"version": "4.4.0", | ||
"description": "shopify", | ||
"version": "5.0.0", | ||
"description": "module for creating Shopify API calls", | ||
"keywords": [ | ||
"shopify" | ||
"shopify", | ||
"API" | ||
], | ||
@@ -14,4 +15,8 @@ "license": "MIT", | ||
"repository": "github:WatchDG/node-shopify", | ||
"private": false, | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"files": [ | ||
"lib/**/*" | ||
], | ||
"scripts": { | ||
@@ -21,10 +26,10 @@ "fmt": "npx prettier --write \"src/**/*.ts\"", | ||
"build": "npx tsc", | ||
"prepare": "npm run build" | ||
"_postinstall": "husky install", | ||
"prepublishOnly": "pinst --disable", | ||
"prepare": "npm run lint && npm run build", | ||
"postpublish": "pinst --enable" | ||
}, | ||
"files": [ | ||
"lib/**/*" | ||
], | ||
"dependencies": { | ||
"http-instance": "^5.0.0", | ||
"node-result": "^5.6.0" | ||
"http-instance": "^5.5.0", | ||
"node-result": "^6.0.1" | ||
}, | ||
@@ -37,2 +42,3 @@ "devDependencies": { | ||
"husky": "^5.0.6", | ||
"pinst": "^2.1.1", | ||
"prettier": "^2.2.1", | ||
@@ -39,0 +45,0 @@ "typescript": "^4.0.3" |
# node-shopify | ||
module for creating Shopify API calls | ||
node-shopify | ||
## install dependencies | ||
```shell | ||
yarn install | ||
# or | ||
npm install | ||
``` | ||
## checkout | ||
### create checkout | ||
```ts | ||
import {Shopify} from 'node-shopify'; | ||
(async () => { | ||
const accessLogin = 'xxx'; | ||
const accessPassword = 'shpat_yyy'; | ||
const url = 'example.myshopify.com' | ||
const shopify = new Shopify(`https://${accessLogin}:${accessToken}@${url}`, 5000); | ||
// | ||
const checkout = (await shopify.createCheckout({ | ||
email: 'user@example.com' | ||
})).unwrap(); | ||
})(); | ||
## build | ||
```shell | ||
yarn run build | ||
# or | ||
npm run build | ||
``` | ||
## product | ||
## example | ||
### get products | ||
```ts | ||
@@ -40,16 +32,1 @@ import {Shopify} from 'node-shopify'; | ||
``` | ||
### get products count | ||
```ts | ||
import {Shopify} from 'node-shopify'; | ||
(async () => { | ||
const accessLogin = 'xxx'; | ||
const accessPassword = 'shpat_yyy'; | ||
const url = 'example.myshopify.com' | ||
const shopify = new Shopify(`https://${accessLogin}:${accessToken}@${url}`, 5000); | ||
// | ||
const productsCount = (await shopify.getProductsCount()).unwrap(); | ||
})(); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32548
725
8
32
- Removednode-result@5.6.0(transitive)
Updatedhttp-instance@^5.5.0
Updatednode-result@^6.0.1