'use strict';
let Client = require('../client');
let productSearch = require('./types/productSearch');
/**
* @module class/ProductService
* @author Evrim OLÇUM
*/
module.exports = class extends Client {
/**
* @param {String} appKey n11 appkey
* @param {String} appSecret n11 appSecret
*/
constructor(appKey, appSecret) {
super(appKey, appSecret)
this.wsdl = 'https://api.n11.com/ws/ProductService.wsdl';
}
/**
* N11 ürün ID sini kullanarak sistemde kayıtlı olan ürünün bilgilerini getirir.
* @async
* @function getProductByProductId
* @memberof module:class/ProductService
* @instance
* @param {number} productId
* @returns {Promise<object>}
*/
getProductByProductId(productId) {
return super.call(this.wsdl, 'GetProductByProductId', {
productId: productId
});
}
/**
* Mağaza ürün kodunu kullanarak sistemde kayıtlı olan ürünün bilgilerini getirir.
* @async
* @function getProductBySellerCode
* @memberof module:class/ProductService
* @instance
* @param {string} sellerCode
* @returns {Promise<object>}
*/
getProductBySellerCode(sellerCode) {
return super.call(this.wsdl, 'GetProductBySellerCode', {
sellerCode: sellerCode
});
}
/**
* Sistemde ürünleri listelemek için kullanılır. Metot ürün ile ilgili özet bilgileri
* getirmektedir. Bu metottan dönen “productSellerCode” bilgisini kullanarak
* “GetProductBySellerCode” metodu veya “id” bilgisini kullanarak “GetProductById” metodu
* kullanılarak ürünün detaylı bilgilerine ulaşılabilir.
* Sonuçlar, sayfalama bilgisi ile beraber döner. “itemsPerPage” parametresi ile her sayfada
* listelenecek ürün adedi, “currentPage” parametresi ile de listelenmek istenen sayfanın numarası
* kontrol edilebilir. Herhangi bir değer girilmediği takdirde, her sayfada 100 adet ürün listelenir
* ve birinci sayfa listelenir.
* “pagingData” içinde toplam ürün adedi, sayfa sayısı, mevcut sayfa ve sayfa başına düşen ürün adedi
* bilgileri kullanıcılara verilir.
* @async
* @function getProductList
* @memberof module:class/ProductService
* @instance
* @param {number} currentPage
* @param {number} pageSize
* @returns {Promise<object>}
*/
getProductList(currentPage, pageSize) {
return super.call(this.wsdl, 'GetProductList', {
pagingData: {
currentPage: currentPage,
pageSize: pageSize,
}
});
}
/**
*/
SearchProducts(currentPage, pageSize, productSearch) {
return super.call(this.wsdl, 'SearchProducts', {
pagingData: {
currentPage: currentPage,
pageSize: pageSize,
},
productSearch: productSearch
});
}
/**
* Bir ürünün N11 ürün ID si kullanılarak ürünün sadece baz fiyat bilgilerini,
* ürün stok birimi fiyat bilgilerini veya her ikisinin güncellenmesi için kullanılır.
* @async
* @function updateProductPriceById
* @memberof module:class/ProductService
* @instance
* @param {number} productId Ürünün N11 ID si
* @param {number} price Güncellenmek istenen ürün fiyatı
* @param {number} currencyType Ürün listeleme fiyatı para birimi
* @param {object} stockItems
* @returns {Promise<object>}
*/
updateProductPriceById(productId, price, currencyType, stockItems) {
return super.call(this.wsdl, 'UpdateProductPriceById', {
productId: productId,
price: price,
currencyType: currencyType,
stockItems: stockItems
});
}
updateProductPriceBySellerCode(productSellerCode, price, currencyType) {
return super.call(this.wsdl, 'UpdateProductPriceBySellerCode', {
productSellerCode: productSellerCode,
price: price,
currencyType: currencyType
});
}
deleteProductById(productId) {
return super.call(this.wsdl, 'DeleteProductById', {
productId: productId
});
}
deleteProductBySellerCode(productSellerCode) {
return super.call(this.wsdl, 'DeleteProductBySellerCode', {
productSellerCode: productSellerCode
});
}
saveProduct(product) {
product = {
product: product
};
return super.call(this.wsdl, 'SaveProduct', product);
}
UpdateProductBasic(productDetail) {
return super.call(this.wsdl, 'UpdateProductBasic', oProductDetail);
}
updateDiscountValueByProductId(productId, discountType, discountValue) {
return super.call(this.wsdl, 'UpdateDiscountValueByProductId', {
productId: productId,
productDiscount: {
discountType: discountType,
discountValue: discountValue
}
});
}
updateDiscountValueBySellerCode(productSellerCode, discountType, discountValue) {
return super.call(this.wsdl, 'UpdateDiscountValueBySellerCode', {
productSellerCode: productSellerCode,
productDiscount: {
discountType: discountType,
discountValue: discountValue
}
});
}
GetProductQuestionList(productQuestionSearch, currentPage, pageSize) {
return super.call(this.wsdl, 'GetProductQuestionList', {
productQuestionSearch: productQuestionSearch,
pagingData: {
currentPage: currentPage,
pageSize: pageSize,
},
});
}
GetProductQuestionDetail(productQuestionId) {
return super.call(this.wsdl, 'GetProductQuestionDetail', {
productQuestionId: productQuestionId
});
}
SaveProductAnswer(productQuestionId, answer) {
return super.call(this.wsdl, 'SaveProductAnswer', {
productQuestionId: productQuestionId,
answer: answer
});
}
AdaptUnificationProducts(productQuestionId, answer) {
return super.call(this.wsdl, 'AdaptUnificationProducts', {
});
}
ProductApprovalStatus(productQuestionId, answer) {
return super.call(this.wsdl, 'ProductApprovalStatus', {
});
}
UpdateProductsByPims(productIdList) {
return super.call(this.wsdl, 'UpdateProductsByPims', {
productIdList: productIdList
});
}
}
Source