node-shopify
Advanced tools
Comparing version 5.2.0 to 5.3.0
@@ -8,3 +8,3 @@ import { ResultOK, ResultFAIL } from 'node-result'; | ||
import { CreateCheckout, UpdateCheckout, CheckoutToken, Checkout, CheckoutShippingRates } from './types/checkout'; | ||
import { ProductId, Product, CreateProduct, UpdateProduct, ProductListing } from './types/product'; | ||
import { ProductId, Product, CreateProduct, UpdateProduct, ProductListing, ProductVariantId, CreateProductVariant, ProductVariant } from './types/product'; | ||
declare type ReturnAsync<T> = Promise<ResultOK<T> | ResultFAIL<Error>>; | ||
@@ -55,3 +55,5 @@ export declare class Shopify { | ||
deleteProductListing(productId: ProductId): ReturnAsync<null>; | ||
createProductVariant(productId: ProductId, createProductVariant: CreateProductVariant): ReturnAsync<ProductVariant>; | ||
deleteProductVariant(productId: ProductId, productVariantId: ProductVariantId): ReturnAsync<null>; | ||
} | ||
export {}; |
@@ -337,2 +337,18 @@ "use strict"; | ||
} | ||
async createProductVariant(productId, createProductVariant) { | ||
const payload = { | ||
variant: createProductVariant | ||
}; | ||
const url = `/admin/api/2021-01/products/632910392/variants.json`; | ||
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.variant); | ||
} | ||
async deleteProductVariant(productId, productVariantId) { | ||
const url = `/admin/api/2021-01/products/${productId}/variants/${productVariantId}.json`; | ||
(await this.instance.delete(url)).unwrap(); | ||
return node_result_1.ResultOk(null); | ||
} | ||
} | ||
@@ -453,2 +469,8 @@ __decorate([ | ||
], Shopify.prototype, "deleteProductListing", null); | ||
__decorate([ | ||
node_result_1.tryCatchWrapperAsync | ||
], Shopify.prototype, "createProductVariant", null); | ||
__decorate([ | ||
node_result_1.tryCatchWrapperAsync | ||
], Shopify.prototype, "deleteProductVariant", null); | ||
exports.Shopify = Shopify; |
@@ -14,3 +14,5 @@ export declare type ProductId = number; | ||
export declare type ProductPublishedScope = 'global'; | ||
export declare type ProductVariant = Record<string, never>; | ||
export declare type ProductVariant = { | ||
id: ProductVariantId; | ||
}; | ||
export declare type Product = { | ||
@@ -55,1 +57,5 @@ id: ProductId; | ||
}; | ||
export declare type CreateProductVariant = { | ||
title?: string; | ||
price?: string; | ||
}; |
{ | ||
"name": "node-shopify", | ||
"version": "5.2.0", | ||
"version": "5.3.0", | ||
"description": "module for creating Shopify API calls", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
34267
762