diff --git a/src/Resources/Product.php b/src/Resources/Product.php index c8eca09..99c4d8e 100644 --- a/src/Resources/Product.php +++ b/src/Resources/Product.php @@ -16,15 +16,13 @@ class Product extends Resource { - protected $prefix = 'products'; - public function uploadFile($file, $file_name = 'uploaded_file') { if ($file instanceof SplFileInfo) { $file_name = $file->getFilename(); } - return $this->call('POST', 'upload_files', [ + return $this->call('POST', 'products/upload_files', [ RequestOptions::JSON => [ 'file_name' => $file_name, 'file_data' => static::dataTypeCast('file', $file), @@ -34,7 +32,7 @@ public function uploadFile($file, $file_name = 'uploaded_file') public function uploadImage($image, $scene = 1 /* PRODUCT_IMAGE */) { - return $this->call('POST', 'upload_imgs', [ + return $this->call('POST', 'products/upload_imgs', [ RequestOptions::JSON => [ 'img_data' => static::dataTypeCast('image', $image), 'img_scene' => $scene, @@ -44,21 +42,21 @@ public function uploadImage($image, $scene = 1 /* PRODUCT_IMAGE */) public function createProduct($data = []) { - return $this->call('POST', '', [ + return $this->call('POST', 'products', [ RequestOptions::JSON => $data ]); } public function createDraftProduct($data = []) { - return $this->call('POST', 'save_draft', [ + return $this->call('POST', 'products/save_draft', [ RequestOptions::JSON => $data ]); } public function deleteProduct($product_ids = []) { - return $this->call('DELETE', '/', [ + return $this->call('DELETE', 'products', [ RequestOptions::JSON => [ 'product_ids' => static::dataTypeCast('array', $product_ids) ] @@ -69,7 +67,7 @@ public function editProduct($product_id, $data = []) { $data['product_id'] = $product_id; - return $this->call('PUT', '/', [ + return $this->call('PUT', 'products', [ RequestOptions::JSON => $data ]); } @@ -81,7 +79,7 @@ public function updateStock($product_id, $skus = []) 'skus' => $skus ]; - return $this->call('PUT', 'stocks', [ + return $this->call('PUT', 'products/stocks', [ RequestOptions::JSON => $data ]); } @@ -93,14 +91,14 @@ public function getProductList($params = []) 'page_size' => 20, ], $params); - return $this->call('POST', 'search', [ + return $this->call('POST', 'products/search', [ RequestOptions::JSON => $params ]); } public function getProductDetail($product_id, $need_audit_version = false) { - return $this->call('GET', 'details', [ + return $this->call('GET', 'products/details', [ RequestOptions::QUERY => [ 'product_id' => $product_id, 'need_audit_version' => static::dataTypeCast('bool', $need_audit_version), @@ -110,7 +108,7 @@ public function getProductDetail($product_id, $need_audit_version = false) public function deactivateProduct($product_ids = []) { - return $this->call('POST', 'inactivated_products', [ + return $this->call('POST', 'products/inactivated_products', [ RequestOptions::JSON => [ 'product_ids' => static::dataTypeCast('array', $product_ids), ] @@ -119,7 +117,7 @@ public function deactivateProduct($product_ids = []) public function activateProduct($product_ids = []) { - return $this->call('POST', 'activate', [ + return $this->call('POST', 'products/activate', [ RequestOptions::JSON => [ 'product_ids' => static::dataTypeCast('array', $product_ids), ] @@ -128,7 +126,7 @@ public function activateProduct($product_ids = []) public function recoverDeletedProduct($product_ids = []) { - return $this->call('POST', 'recover', [ + return $this->call('POST', 'products/recover', [ RequestOptions::JSON => [ 'product_ids' => static::dataTypeCast('array', $product_ids), ] @@ -142,26 +140,26 @@ public function updatePrice($product_id, $skus) 'skus' => $skus ]; - return $this->call('PUT', 'prices', [ + return $this->call('PUT', 'products/prices', [ RequestOptions::JSON => $data ]); } public function getCategories() { - return $this->call('GET', 'categories'); + return $this->call('GET', 'products/categories'); } public function getBrands(array $params) { - return $this->call('GET', 'brands', [ + return $this->call('GET', 'products/brands', [ RequestOptions::QUERY => $params ]); } public function createBrand(string $brand_name) { - return $this->call('POST', 'brand', [ + return $this->call('POST', 'products/brand', [ RequestOptions::JSON => [ 'brand_name' => $brand_name ] @@ -170,7 +168,7 @@ public function createBrand(string $brand_name) public function getAttributes($category_id) { - return $this->call('GET', 'attributes', [ + return $this->call('GET', 'products/attributes', [ RequestOptions::QUERY => [ 'category_id' => static::dataTypeCast('string', $category_id), ] @@ -179,7 +177,7 @@ public function getAttributes($category_id) public function getCategoryRule($category_id) { - return $this->call('GET', 'categories/rules', [ + return $this->call('GET', 'products/categories/rules', [ RequestOptions::QUERY => [ 'category_id' => $category_id ]