Class: Google::Apis::MerchantapiProductsV1beta::MerchantService

Inherits:
Core::BaseService
  • Object
show all
Defined in:
lib/google/apis/merchantapi_products_v1beta/service.rb

Overview

Merchant API

Programmatically manage your Merchant Center Accounts.

Examples:

require 'google/apis/merchantapi_products_v1beta'

Merchantapi = Google::Apis::MerchantapiProductsV1beta # Alias the module
service = Merchantapi::MerchantService.new

See Also:

Constant Summary collapse

DEFAULT_ENDPOINT_TEMPLATE =
"https://merchantapi.$UNIVERSE_DOMAIN$/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMerchantService

Returns a new instance of MerchantService.



47
48
49
50
51
52
# File 'lib/google/apis/merchantapi_products_v1beta/service.rb', line 47

def initialize
  super(DEFAULT_ENDPOINT_TEMPLATE, '',
        client_name: 'google-apis-merchantapi_products_v1beta',
        client_version: Google::Apis::MerchantapiProductsV1beta::GEM_VERSION)
  @batch_path = 'batch'
end

Instance Attribute Details

#keyString

Returns API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.

Returns:

  • (String)

    API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.



40
41
42
# File 'lib/google/apis/merchantapi_products_v1beta/service.rb', line 40

def key
  @key
end

#quota_userString

Returns Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

Returns:

  • (String)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.



45
46
47
# File 'lib/google/apis/merchantapi_products_v1beta/service.rb', line 45

def quota_user
  @quota_user
end

Instance Method Details

#delete_account_product_input(name, data_source: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::MerchantapiProductsV1beta::Empty

Deletes a product input from your Merchant Center account. After inserting, updating, or deleting a product input, it may take several minutes before the processed product can be retrieved.

Parameters:

  • name (String)

    Required. The name of the product input to delete. Format: accounts/account/ productInputs/productInputThe `productInput` segment is a unique identifier for the product. This identifier must be unique within a merchant account and generally follows the structure: `content_language~feed_label~ offer_id`. Example: `en~US~sku123` For legacy local products, the structure is: `local~content_language~feed_label~offer_id`. Example: `local~en~US~sku123` The format of the `productInput` segment in the URL is automatically detected by the server, supporting two options: 1. **Encoded Format**: The productInputsegment is an unpadded base64url encoded string (RFC 4648 Section 5). The decoded string must result in the `content_language~feed_label~ offer_id` structure. This encoding MUST be used if any part of the product identifier (like `offer_id`) contains characters such as `/`, `%`, or `~`. * Example: To represent the product ID `en~US~sku/123`, theproductInput segment must be the unpadded base64url encoding of this string, which is `ZW5- VVN-c2t1LzEyMw`. The full resource name for the product would be `accounts/123/ productInputs/ZW5-VVN-c2t1LzEyMw`. 2. **Plain Format**: TheproductInput segment is the tilde-separated string `content_language~feed_label~offer_id`. This format is suitable only when `content_language`, `feed_label`, and ` offer_id` do not contain URL-problematic characters like `/`, `%`, or `~`. We recommend using the **Encoded Format** for all product IDs to ensure correct parsing, especially those containing special characters. The presence of tilde (`~`) characters in theproductInput`` segment is used to differentiate between the two formats.

  • data_source (String) (defaults to: nil)

    Required. The primary or supplemental data source from which the product input should be deleted. Format: accounts/account/dataSources/datasource`. For example,accounts/123456/dataSources/104628`.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



102
103
104
105
106
107
108
109
110
111
# File 'lib/google/apis/merchantapi_products_v1beta/service.rb', line 102

def (name, data_source: nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:delete, 'products/v1beta/{+name}', options)
  command.response_representation = Google::Apis::MerchantapiProductsV1beta::Empty::Representation
  command.response_class = Google::Apis::MerchantapiProductsV1beta::Empty
  command.params['name'] = name unless name.nil?
  command.query['dataSource'] = data_source unless data_source.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#get_account_product(name, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::MerchantapiProductsV1beta::Product

Retrieves the processed product from your Merchant Center account. After inserting, updating, or deleting a product input, it may take several minutes before the updated final product can be retrieved.

Parameters:

  • name (String)

    Required. The name of the product. Format: accounts/account/products/ productTheproductsegment is a unique identifier for the product. This identifier must be unique within a merchant account and generally follows the structure: `content_language~feed_label~offer_id`. Example: `en~US~sku123` For legacy local products, the structure is: `local~content_language~feed_label~ offer_id`. Example: `local~en~US~sku123` The format of theproductsegment in the URL is automatically detected by the server, supporting two options: 1. **Encoded Format**: Theproductsegment is an unpadded base64url encoded string (RFC 4648 Section 5). The decoded string must result in the ` content_language~feed_label~offer_id` structure. This encoding MUST be used if any part of the product identifier (like `offer_id`) contains characters such as `/`, `%`, or `~`. * Example: To represent the product ID `en~US~sku/123`, theproductsegment must be the unpadded base64url encoding of this string, which is `ZW5-VVN-c2t1LzEyMw`. The full resource name for the product would be `accounts/123/products/ZW5-VVN-c2t1LzEyMw`. 2. **Plain Format**: The productsegment is the tilde-separated string `content_language~feed_label~ offer_id`. This format is suitable only when `content_language`, `feed_label`, and `offer_id` do not contain URL-problematic characters like `/`, `%`, or `~`. We recommend using the **Encoded Format** for all product IDs to ensure correct parsing, especially those containing special characters. The presence of tilde (`~`) characters in theproduct`segment is used to differentiate between the two formats. Note: For calls to the v1beta version, the plain format ischannel~content_language~feed_label~offer_id, for example: accounts/123/products/online~en~US~sku123`.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



282
283
284
285
286
287
288
289
290
# File 'lib/google/apis/merchantapi_products_v1beta/service.rb', line 282

def (name, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:get, 'products/v1beta/{+name}', options)
  command.response_representation = Google::Apis::MerchantapiProductsV1beta::Product::Representation
  command.response_class = Google::Apis::MerchantapiProductsV1beta::Product
  command.params['name'] = name unless name.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#insert_account_product_input(parent, product_input_object = nil, data_source: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::MerchantapiProductsV1beta::ProductInput

Uploads a product input to your Merchant Center account. You must have a products data source to be able to insert a product. The unique identifier of the data source is passed as a query parameter in the request URL. If a product input with the same contentLanguage, offerId, and dataSource already exists, then the product input inserted by this method replaces that entry. After inserting, updating, or deleting a product input, it may take several minutes before the processed product can be retrieved.

Parameters:

  • parent (String)

    Required. The account where this product will be inserted. Format: accounts/ account``

  • product_input_object (Google::Apis::MerchantapiProductsV1beta::ProductInput) (defaults to: nil)
  • data_source (String) (defaults to: nil)

    Required. The primary or supplemental product data source name. If the product already exists and data source provided is different, then the product will be moved to a new data source. For more information, see Create a primary data source. Only API data sources are supported. Format: accounts/account/ dataSources/datasource`. For example,accounts/123456/dataSources/104628`.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/google/apis/merchantapi_products_v1beta/service.rb', line 150

def (parent, product_input_object = nil, data_source: nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'products/v1beta/{+parent}/productInputs:insert', options)
  command.request_representation = Google::Apis::MerchantapiProductsV1beta::ProductInput::Representation
  command.request_object = product_input_object
  command.response_representation = Google::Apis::MerchantapiProductsV1beta::ProductInput::Representation
  command.response_class = Google::Apis::MerchantapiProductsV1beta::ProductInput
  command.params['parent'] = parent unless parent.nil?
  command.query['dataSource'] = data_source unless data_source.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#list_account_products(parent, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::MerchantapiProductsV1beta::ListProductsResponse

Lists the processed products in your Merchant Center account. The response might contain fewer items than specified by pageSize. Rely on pageToken to determine if there are more items to be requested. After inserting, updating, or deleting a product input, it may take several minutes before the updated processed product can be retrieved.

Parameters:

  • parent (String)

    Required. The account to list processed products for. Format: accounts/ account``

  • page_size (Fixnum) (defaults to: nil)

    The maximum number of products to return. The service may return fewer than this value. The maximum value is 1000; values above 1000 will be coerced to

    1. If unspecified, the default page size of 25 products will be returned.
  • page_token (String) (defaults to: nil)

    A page token, received from a previous ListProducts call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to ListProducts must match the call that provided the page token.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



325
326
327
328
329
330
331
332
333
334
335
# File 'lib/google/apis/merchantapi_products_v1beta/service.rb', line 325

def (parent, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:get, 'products/v1beta/{+parent}/products', options)
  command.response_representation = Google::Apis::MerchantapiProductsV1beta::ListProductsResponse::Representation
  command.response_class = Google::Apis::MerchantapiProductsV1beta::ListProductsResponse
  command.params['parent'] = parent unless parent.nil?
  command.query['pageSize'] = page_size unless page_size.nil?
  command.query['pageToken'] = page_token unless page_token.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#patch_account_product_input(name, product_input_object = nil, data_source: nil, update_mask: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::MerchantapiProductsV1beta::ProductInput

Updates the existing product input in your Merchant Center account. The name of the product input to update is taken from the name field within the ProductInput resource. After inserting, updating, or deleting a product input, it may take several minutes before the processed product can be retrieved.

Parameters:

  • name (String)

    Identifier. The name of the product. Format: accounts/account/productInputs/ productinputThe `productinput` segment is a unique identifier for the product. This identifier must be unique within a merchant account and generally follows the structure: `content_language~feed_label~offer_id`. Example: `en~US~sku123` For legacy local products, the structure is: `local~ content_language~feed_label~offer_id`. Example: `local~en~US~sku123` The format of the `productinput` segment in the URL is automatically detected by the server, supporting two options: 1. **Encoded Format**: Theproductinput segment is an unpadded base64url encoded string (RFC 4648 Section 5). The decoded string must result in the `content_language~feed_label~offer_id` structure. This encoding MUST be used if any part of the product identifier ( like `offer_id`) contains characters such as `/`, `%`, or `~`. * Example: To represent the product ID `en~US~sku/123`, theproductinputsegment must be the unpadded base64url encoding of this string, which is `ZW5-VVN-c2t1LzEyMw`. The full resource name for the product would be `accounts/123/productInputs/ ZW5-VVN-c2t1LzEyMw`. 2. **Plain Format**: Theproductinputsegment is the tilde-separated string `content_language~feed_label~offer_id`. This format is suitable only when `content_language`, `feed_label`, and `offer_id` do not contain URL-problematic characters like `/`, `%`, or `~`. We recommend using the **Encoded Format** for all product IDs to ensure correct parsing, especially those containing special characters. The presence of tilde (`~`) characters in theproductinput`` segment is used to differentiate between the two formats.

  • product_input_object (Google::Apis::MerchantapiProductsV1beta::ProductInput) (defaults to: nil)
  • data_source (String) (defaults to: nil)

    Required. The primary or supplemental product data source where data_source name identifies the product input to be updated. Only API data sources are supported. Format: accounts/account/dataSources/datasource`. For example, accounts/123456/dataSources/104628`.

  • update_mask (String) (defaults to: nil)

    Optional. The list of product attributes to be updated. If the update mask is omitted, then it is treated as implied field mask equivalent to all fields that are populated (have a non-empty value). Attributes specified in the update mask without a value specified in the body will be deleted from the product. Update mask can only be specified for top level fields in attributes and custom attributes. To specify the update mask for custom attributes you need to add the custom_attribute. prefix. Providing special "*" value for full product replacement is not supported.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/google/apis/merchantapi_products_v1beta/service.rb', line 223

def (name, product_input_object = nil, data_source: nil, update_mask: nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:patch, 'products/v1beta/{+name}', options)
  command.request_representation = Google::Apis::MerchantapiProductsV1beta::ProductInput::Representation
  command.request_object = product_input_object
  command.response_representation = Google::Apis::MerchantapiProductsV1beta::ProductInput::Representation
  command.response_class = Google::Apis::MerchantapiProductsV1beta::ProductInput
  command.params['name'] = name unless name.nil?
  command.query['dataSource'] = data_source unless data_source.nil?
  command.query['updateMask'] = update_mask unless update_mask.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end