Module: AdWords::Utils
- Defined in:
- lib/adwords4r/utils.rb
Class Method Summary collapse
-
.get_categories ⇒ Object
Retrieve list of available advertising categories.
-
.get_countries ⇒ Object
Retrieve list of available countries.
-
.get_currencies ⇒ Object
Retrieve list of available currencies.
-
.get_map(entries) ⇒ Object
Gets a map from an array of map entries.
-
.get_operation_rates ⇒ Object
Retrieve list of API operation rates.
-
.get_timezones ⇒ Object
Retrieve list of available timezones.
-
.get_us_cities ⇒ Object
Retrieve list of available US cities.
-
.get_us_metros ⇒ Object
Retrieve list of available US metropolitan areas.
-
.get_world_cities ⇒ Object
Retrieve list of available world cities.
-
.get_world_regions ⇒ Object
Retrieve list of available world regions.
-
.operation_index_for_error(error) ⇒ Object
Returns the source operation index for an error.
Class Method Details
.get_categories ⇒ Object
Retrieve list of available advertising categories.
Returns:
-
list of lists. Columns: path, name
35 36 37 |
# File 'lib/adwords4r/utils.rb', line 35 def self.get_categories return get_multiple_column_list('categories.csv') end |
.get_countries ⇒ Object
Retrieve list of available countries.
Returns:
-
list of lists. Columns: country, code
44 45 46 |
# File 'lib/adwords4r/utils.rb', line 44 def self.get_countries return get_multiple_column_list('countries.csv') end |
.get_currencies ⇒ Object
Retrieve list of available currencies.
Returns:
-
list of lists. Columns: code, currency
53 54 55 |
# File 'lib/adwords4r/utils.rb', line 53 def self.get_currencies return get_multiple_column_list('currencies.csv') end |
.get_map(entries) ⇒ Object
Gets a map from an array of map entries. A map entry is any object that has a key and value field.
Args:
-
entries: list of map entries
Returns:
-
hash constructed from map entries
120 121 122 123 124 125 126 |
# File 'lib/adwords4r/utils.rb', line 120 def self.get_map(entries) map = {} entries.each do |entry| map[entry.key] = entry.value end return map end |
.get_operation_rates ⇒ Object
Retrieve list of API operation rates.
Returns:
-
list of lists. Columns: service, method, rate, per_item
107 108 109 |
# File 'lib/adwords4r/utils.rb', line 107 def self.get_operation_rates return get_multiple_column_list('ops_rates.csv') end |
.get_timezones ⇒ Object
Retrieve list of available timezones.
Returns:
-
simple list of timezone names
62 63 64 |
# File 'lib/adwords4r/utils.rb', line 62 def self.get_timezones return get_single_column_list('timezones.csv') end |
.get_us_cities ⇒ Object
Retrieve list of available US cities.
Returns:
-
list of lists. Columns: state, code
71 72 73 |
# File 'lib/adwords4r/utils.rb', line 71 def self.get_us_cities return get_multiple_column_list('us_cities.csv') end |
.get_us_metros ⇒ Object
Retrieve list of available US metropolitan areas.
Returns:
-
list of lists. Columns: state, metro, code
80 81 82 |
# File 'lib/adwords4r/utils.rb', line 80 def self.get_us_metros return get_multiple_column_list('us_metros.csv') end |
.get_world_cities ⇒ Object
Retrieve list of available world cities.
Returns:
-
list of lists. Columns: country, code
89 90 91 |
# File 'lib/adwords4r/utils.rb', line 89 def self.get_world_cities return get_multiple_column_list('world_cities.csv') end |
.get_world_regions ⇒ Object
Retrieve list of available world regions.
Returns:
-
list of lists. Columns: country, code, region
98 99 100 |
# File 'lib/adwords4r/utils.rb', line 98 def self.get_world_regions return get_multiple_column_list('world_regions.csv') end |
.operation_index_for_error(error) ⇒ Object
Returns the source operation index for an error
Args:
-
error: the error to be analyzed
Returns:
-
index for the source operation, nil if none
136 137 138 139 140 141 142 143 144 145 |
# File 'lib/adwords4r/utils.rb', line 136 def self.operation_index_for_error(error) if error and error.respond_to? :fieldPath and error.fieldPath parts = error.fieldPath.split('.') if parts.length > 0 match = parts.first.match(/operations\[(\d)\]/) return match ? match[1].to_i : nil end end return nil end |