NAME

Google::Ads::GoogleAds::Utils::GoogleAdsHelper

DESCRIPTION

This module provides utility methods to other services.

METHODS

remove_unassigned_fields

Removes the fields not presenting in the constructor arguments from a newly created Google Ads API entity. These fields will be excluded when encoding the JSON HTTP request payload.

Parameters

  • hash_ref: a hash reference to the newly created Google Ads API entity.

  • args: the arguments for the constructor of a Google Ads API entity.

check_params

Checks whether the parameters in the code sample are correctly specified. The values can either be set in the source code or passed in from the command line.

Parameters

  • params: an array of parameters in the code sample to verify.

Returns

True, if all the parameters are correctly specified. False, otherwise.

trim

Removes the leading and trailing spaces and line breaks from a string.

Parameters

  • The original input string.

Returns

The trimmed string without leading and trailing white spaces.

expand_path_template

Expands a path template by replacing the parameters in braces with the given arguments.

Parameters

  • path_template: the path template to expand. The format could be: 'customers/{customer_id}/adGroups/{ad_group_id}' or 'v15/customers/{+customerId}/adGroups:mutate'.

  • args: the args in scalar or array/hash reference used to expand the template.

Returns

The expanded path template.

copy_from

Copies a hash reference deeply to a new object.

Parameters

  • original: the original hash reference to copy from.

Returns

A deeply copied object based on the original hash reference.

to_lower_underscore

Converts a string to lower underscore case.

Parameters

  • The original input string.

Returns

The result string in lower underscore case.

to_boolean

Converts a scalar to boolean string.

Parameters

  • The original input scalar value.

Returns

"true" if the input value is valid. "false", otherwise.

die_with_code

Dies with a specified exit code.

Parameters

  • exit_code: the exit code.

  • list: list of one or more items, which will be stringified and concatenated to make the exception.

LICENSE AND COPYRIGHT

Copyright 2019 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

REPOSITORY INFORMATION

$Rev: $
$LastChangedBy: $
$Id: $