1<?php 2/* 3 * Copyright 2014 Google Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 * use this file except in compliance with the License. You may obtain a copy of 7 * the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 * License for the specific language governing permissions and limitations under 15 * the License. 16 */ 17 18namespace Google\Service\CloudRetail\Resource; 19 20use Google\Service\CloudRetail\GoogleCloudRetailV2AddFulfillmentPlacesRequest; 21use Google\Service\CloudRetail\GoogleCloudRetailV2AddLocalInventoriesRequest; 22use Google\Service\CloudRetail\GoogleCloudRetailV2ImportProductsRequest; 23use Google\Service\CloudRetail\GoogleCloudRetailV2ListProductsResponse; 24use Google\Service\CloudRetail\GoogleCloudRetailV2Product; 25use Google\Service\CloudRetail\GoogleCloudRetailV2RemoveFulfillmentPlacesRequest; 26use Google\Service\CloudRetail\GoogleCloudRetailV2RemoveLocalInventoriesRequest; 27use Google\Service\CloudRetail\GoogleCloudRetailV2SetInventoryRequest; 28use Google\Service\CloudRetail\GoogleLongrunningOperation; 29use Google\Service\CloudRetail\GoogleProtobufEmpty; 30 31/** 32 * The "products" collection of methods. 33 * Typical usage is: 34 * <code> 35 * $retailService = new Google\Service\CloudRetail(...); 36 * $products = $retailService->products; 37 * </code> 38 */ 39class ProjectsLocationsCatalogsBranchesProducts extends \Google\Service\Resource 40{ 41 /** 42 * Incrementally adds place IDs to Product.fulfillment_info.place_ids. This 43 * process is asynchronous and does not require the Product to exist before 44 * updating fulfillment information. If the request is valid, the update will be 45 * enqueued and processed downstream. As a consequence, when a response is 46 * returned, the added place IDs are not immediately manifested in the Product 47 * queried by GetProduct or ListProducts. This feature is only available for 48 * users who have Retail Search enabled. Please enable Retail Search on Cloud 49 * Console before using this feature. (products.addFulfillmentPlaces) 50 * 51 * @param string $product Required. Full resource name of Product, such as `proj 52 * ects/locations/global/catalogs/default_catalog/branches/default_branch/produc 53 * ts/some_product_id`. If the caller does not have permission to access the 54 * Product, regardless of whether or not it exists, a PERMISSION_DENIED error is 55 * returned. 56 * @param GoogleCloudRetailV2AddFulfillmentPlacesRequest $postBody 57 * @param array $optParams Optional parameters. 58 * @return GoogleLongrunningOperation 59 */ 60 public function addFulfillmentPlaces($product, GoogleCloudRetailV2AddFulfillmentPlacesRequest $postBody, $optParams = []) 61 { 62 $params = ['product' => $product, 'postBody' => $postBody]; 63 $params = array_merge($params, $optParams); 64 return $this->call('addFulfillmentPlaces', [$params], GoogleLongrunningOperation::class); 65 } 66 /** 67 * Updates local inventory information for a Product at a list of places, while 68 * respecting the last update timestamps of each inventory field. This process 69 * is asynchronous and does not require the Product to exist before updating 70 * inventory information. If the request is valid, the update will be enqueued 71 * and processed downstream. As a consequence, when a response is returned, 72 * updates are not immediately manifested in the Product queried by GetProduct 73 * or ListProducts. Local inventory information can only be modified using this 74 * method. CreateProduct and UpdateProduct has no effect on local inventories. 75 * This feature is only available for users who have Retail Search enabled. 76 * Please enable Retail Search on Cloud Console before using this feature. 77 * (products.addLocalInventories) 78 * 79 * @param string $product Required. Full resource name of Product, such as `proj 80 * ects/locations/global/catalogs/default_catalog/branches/default_branch/produc 81 * ts/some_product_id`. If the caller does not have permission to access the 82 * Product, regardless of whether or not it exists, a PERMISSION_DENIED error is 83 * returned. 84 * @param GoogleCloudRetailV2AddLocalInventoriesRequest $postBody 85 * @param array $optParams Optional parameters. 86 * @return GoogleLongrunningOperation 87 */ 88 public function addLocalInventories($product, GoogleCloudRetailV2AddLocalInventoriesRequest $postBody, $optParams = []) 89 { 90 $params = ['product' => $product, 'postBody' => $postBody]; 91 $params = array_merge($params, $optParams); 92 return $this->call('addLocalInventories', [$params], GoogleLongrunningOperation::class); 93 } 94 /** 95 * Creates a Product. (products.create) 96 * 97 * @param string $parent Required. The parent catalog resource name, such as 98 * `projects/locations/global/catalogs/default_catalog/branches/default_branch`. 99 * @param GoogleCloudRetailV2Product $postBody 100 * @param array $optParams Optional parameters. 101 * 102 * @opt_param string productId Required. The ID to use for the Product, which 103 * will become the final component of the Product.name. If the caller does not 104 * have permission to create the Product, regardless of whether or not it 105 * exists, a PERMISSION_DENIED error is returned. This field must be unique 106 * among all Products with the same parent. Otherwise, an ALREADY_EXISTS error 107 * is returned. This field must be a UTF-8 encoded string with a length limit of 108 * 128 characters. Otherwise, an INVALID_ARGUMENT error is returned. 109 * @return GoogleCloudRetailV2Product 110 */ 111 public function create($parent, GoogleCloudRetailV2Product $postBody, $optParams = []) 112 { 113 $params = ['parent' => $parent, 'postBody' => $postBody]; 114 $params = array_merge($params, $optParams); 115 return $this->call('create', [$params], GoogleCloudRetailV2Product::class); 116 } 117 /** 118 * Deletes a Product. (products.delete) 119 * 120 * @param string $name Required. Full resource name of Product, such as `project 121 * s/locations/global/catalogs/default_catalog/branches/default_branch/products/ 122 * some_product_id`. If the caller does not have permission to delete the 123 * Product, regardless of whether or not it exists, a PERMISSION_DENIED error is 124 * returned. If the Product to delete does not exist, a NOT_FOUND error is 125 * returned. The Product to delete can neither be a Product.Type.COLLECTION 126 * Product member nor a Product.Type.PRIMARY Product with more than one 127 * variants. Otherwise, an INVALID_ARGUMENT error is returned. All inventory 128 * information for the named Product will be deleted. 129 * @param array $optParams Optional parameters. 130 * @return GoogleProtobufEmpty 131 */ 132 public function delete($name, $optParams = []) 133 { 134 $params = ['name' => $name]; 135 $params = array_merge($params, $optParams); 136 return $this->call('delete', [$params], GoogleProtobufEmpty::class); 137 } 138 /** 139 * Gets a Product. (products.get) 140 * 141 * @param string $name Required. Full resource name of Product, such as `project 142 * s/locations/global/catalogs/default_catalog/branches/default_branch/products/ 143 * some_product_id`. If the caller does not have permission to access the 144 * Product, regardless of whether or not it exists, a PERMISSION_DENIED error is 145 * returned. If the requested Product does not exist, a NOT_FOUND error is 146 * returned. 147 * @param array $optParams Optional parameters. 148 * @return GoogleCloudRetailV2Product 149 */ 150 public function get($name, $optParams = []) 151 { 152 $params = ['name' => $name]; 153 $params = array_merge($params, $optParams); 154 return $this->call('get', [$params], GoogleCloudRetailV2Product::class); 155 } 156 /** 157 * Bulk import of multiple Products. Request processing may be synchronous. No 158 * partial updating is supported. Non-existing items are created. Note that it 159 * is possible for a subset of the Products to be successfully updated. 160 * (products.import) 161 * 162 * @param string $parent Required. `projects/1234/locations/global/catalogs/defa 163 * ult_catalog/branches/default_branch` If no updateMask is specified, requires 164 * products.create permission. If updateMask is specified, requires 165 * products.update permission. 166 * @param GoogleCloudRetailV2ImportProductsRequest $postBody 167 * @param array $optParams Optional parameters. 168 * @return GoogleLongrunningOperation 169 */ 170 public function import($parent, GoogleCloudRetailV2ImportProductsRequest $postBody, $optParams = []) 171 { 172 $params = ['parent' => $parent, 'postBody' => $postBody]; 173 $params = array_merge($params, $optParams); 174 return $this->call('import', [$params], GoogleLongrunningOperation::class); 175 } 176 /** 177 * Gets a list of Products. 178 * (products.listProjectsLocationsCatalogsBranchesProducts) 179 * 180 * @param string $parent Required. The parent branch resource name, such as 181 * `projects/locations/global/catalogs/default_catalog/branches/0`. Use 182 * `default_branch` as the branch ID, to list products under the default branch. 183 * If the caller does not have permission to list Products under this branch, 184 * regardless of whether or not this branch exists, a PERMISSION_DENIED error is 185 * returned. 186 * @param array $optParams Optional parameters. 187 * 188 * @opt_param string filter A filter to apply on the list results. Supported 189 * features: * List all the products under the parent branch if filter is unset. 190 * * List Product.Type.VARIANT Products sharing the same Product.Type.PRIMARY 191 * Product. For example: `primary_product_id = "some_product_id"` * List 192 * Products bundled in a Product.Type.COLLECTION Product. For example: 193 * `collection_product_id = "some_product_id"` * List Products with a partibular 194 * type. For example: `type = "PRIMARY"` `type = "VARIANT"` `type = 195 * "COLLECTION"` If the field is unrecognizable, an INVALID_ARGUMENT error is 196 * returned. If the specified Product.Type.PRIMARY Product or 197 * Product.Type.COLLECTION Product does not exist, a NOT_FOUND error is 198 * returned. 199 * @opt_param int pageSize Maximum number of Products to return. If unspecified, 200 * defaults to 100. The maximum allowed value is 1000. Values above 1000 will be 201 * coerced to 1000. If this field is negative, an INVALID_ARGUMENT error is 202 * returned. 203 * @opt_param string pageToken A page token 204 * ListProductsResponse.next_page_token, received from a previous 205 * ProductService.ListProducts call. Provide this to retrieve the subsequent 206 * page. When paginating, all other parameters provided to 207 * ProductService.ListProducts must match the call that provided the page token. 208 * Otherwise, an INVALID_ARGUMENT error is returned. 209 * @opt_param string readMask The fields of Product to return in the responses. 210 * If not set or empty, the following fields are returned: * Product.name * 211 * Product.id * Product.title * Product.uri * Product.images * 212 * Product.price_info * Product.brands If "*" is provided, all fields are 213 * returned. Product.name is always returned no matter what mask is set. If an 214 * unsupported or unknown field is provided, an INVALID_ARGUMENT error is 215 * returned. 216 * @return GoogleCloudRetailV2ListProductsResponse 217 */ 218 public function listProjectsLocationsCatalogsBranchesProducts($parent, $optParams = []) 219 { 220 $params = ['parent' => $parent]; 221 $params = array_merge($params, $optParams); 222 return $this->call('list', [$params], GoogleCloudRetailV2ListProductsResponse::class); 223 } 224 /** 225 * Updates a Product. (products.patch) 226 * 227 * @param string $name Immutable. Full resource name of the product, such as `pr 228 * ojects/locations/global/catalogs/default_catalog/branches/default_branch/prod 229 * ucts/product_id`. 230 * @param GoogleCloudRetailV2Product $postBody 231 * @param array $optParams Optional parameters. 232 * 233 * @opt_param bool allowMissing If set to true, and the Product is not found, a 234 * new Product will be created. In this situation, `update_mask` is ignored. 235 * @opt_param string updateMask Indicates which fields in the provided Product 236 * to update. The immutable and output only fields are NOT supported. If not 237 * set, all supported fields (the fields that are neither immutable nor output 238 * only) are updated. If an unsupported or unknown field is provided, an 239 * INVALID_ARGUMENT error is returned. The attribute key can be updated by 240 * setting the mask path as "attributes.${key_name}". If a key name is present 241 * in the mask but not in the patching product from the request, this key will 242 * be deleted after the update. 243 * @return GoogleCloudRetailV2Product 244 */ 245 public function patch($name, GoogleCloudRetailV2Product $postBody, $optParams = []) 246 { 247 $params = ['name' => $name, 'postBody' => $postBody]; 248 $params = array_merge($params, $optParams); 249 return $this->call('patch', [$params], GoogleCloudRetailV2Product::class); 250 } 251 /** 252 * Incrementally removes place IDs from a Product.fulfillment_info.place_ids. 253 * This process is asynchronous and does not require the Product to exist before 254 * updating fulfillment information. If the request is valid, the update will be 255 * enqueued and processed downstream. As a consequence, when a response is 256 * returned, the removed place IDs are not immediately manifested in the Product 257 * queried by GetProduct or ListProducts. This feature is only available for 258 * users who have Retail Search enabled. Please enable Retail Search on Cloud 259 * Console before using this feature. (products.removeFulfillmentPlaces) 260 * 261 * @param string $product Required. Full resource name of Product, such as `proj 262 * ects/locations/global/catalogs/default_catalog/branches/default_branch/produc 263 * ts/some_product_id`. If the caller does not have permission to access the 264 * Product, regardless of whether or not it exists, a PERMISSION_DENIED error is 265 * returned. 266 * @param GoogleCloudRetailV2RemoveFulfillmentPlacesRequest $postBody 267 * @param array $optParams Optional parameters. 268 * @return GoogleLongrunningOperation 269 */ 270 public function removeFulfillmentPlaces($product, GoogleCloudRetailV2RemoveFulfillmentPlacesRequest $postBody, $optParams = []) 271 { 272 $params = ['product' => $product, 'postBody' => $postBody]; 273 $params = array_merge($params, $optParams); 274 return $this->call('removeFulfillmentPlaces', [$params], GoogleLongrunningOperation::class); 275 } 276 /** 277 * Remove local inventory information for a Product at a list of places at a 278 * removal timestamp. This process is asynchronous. If the request is valid, the 279 * removal will be enqueued and processed downstream. As a consequence, when a 280 * response is returned, removals are not immediately manifested in the Product 281 * queried by GetProduct or ListProducts. Local inventory information can only 282 * be removed using this method. CreateProduct and UpdateProduct has no effect 283 * on local inventories. This feature is only available for users who have 284 * Retail Search enabled. Please enable Retail Search on Cloud Console before 285 * using this feature. (products.removeLocalInventories) 286 * 287 * @param string $product Required. Full resource name of Product, such as `proj 288 * ects/locations/global/catalogs/default_catalog/branches/default_branch/produc 289 * ts/some_product_id`. If the caller does not have permission to access the 290 * Product, regardless of whether or not it exists, a PERMISSION_DENIED error is 291 * returned. 292 * @param GoogleCloudRetailV2RemoveLocalInventoriesRequest $postBody 293 * @param array $optParams Optional parameters. 294 * @return GoogleLongrunningOperation 295 */ 296 public function removeLocalInventories($product, GoogleCloudRetailV2RemoveLocalInventoriesRequest $postBody, $optParams = []) 297 { 298 $params = ['product' => $product, 'postBody' => $postBody]; 299 $params = array_merge($params, $optParams); 300 return $this->call('removeLocalInventories', [$params], GoogleLongrunningOperation::class); 301 } 302 /** 303 * Updates inventory information for a Product while respecting the last update 304 * timestamps of each inventory field. This process is asynchronous and does not 305 * require the Product to exist before updating fulfillment information. If the 306 * request is valid, the update will be enqueued and processed downstream. As a 307 * consequence, when a response is returned, updates are not immediately 308 * manifested in the Product queried by GetProduct or ListProducts. When 309 * inventory is updated with CreateProduct and UpdateProduct, the specified 310 * inventory field value(s) will overwrite any existing value(s) while ignoring 311 * the last update time for this field. Furthermore, the last update time for 312 * the specified inventory fields will be overwritten to the time of the 313 * CreateProduct or UpdateProduct request. If no inventory fields are set in 314 * CreateProductRequest.product, then any pre-existing inventory information for 315 * this product will be used. If no inventory fields are set in 316 * SetInventoryRequest.set_mask, then any existing inventory information will be 317 * preserved. Pre-existing inventory information can only be updated with 318 * SetInventory, AddFulfillmentPlaces, and RemoveFulfillmentPlaces. This feature 319 * is only available for users who have Retail Search enabled. Please enable 320 * Retail Search on Cloud Console before using this feature. 321 * (products.setInventory) 322 * 323 * @param string $name Immutable. Full resource name of the product, such as `pr 324 * ojects/locations/global/catalogs/default_catalog/branches/default_branch/prod 325 * ucts/product_id`. 326 * @param GoogleCloudRetailV2SetInventoryRequest $postBody 327 * @param array $optParams Optional parameters. 328 * @return GoogleLongrunningOperation 329 */ 330 public function setInventory($name, GoogleCloudRetailV2SetInventoryRequest $postBody, $optParams = []) 331 { 332 $params = ['name' => $name, 'postBody' => $postBody]; 333 $params = array_merge($params, $optParams); 334 return $this->call('setInventory', [$params], GoogleLongrunningOperation::class); 335 } 336} 337 338// Adding a class alias for backwards compatibility with the previous class name. 339class_alias(ProjectsLocationsCatalogsBranchesProducts::class, 'Google_Service_CloudRetail_Resource_ProjectsLocationsCatalogsBranchesProducts'); 340