google-ads-common 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,6 @@
1
+ 0.9.1:
2
+ - Fixed issues #93, #96, #97.
3
+
1
4
  0.9.0:
2
5
  - Switched to Signet OAuth implementation.
3
6
  - Removed deprecated OAuth1.0a scheme, please use OAuth2.0 instead.
@@ -138,7 +138,8 @@ module AdsCommon
138
138
  if credentials[:oauth2_keyfile] &&
139
139
  !File.file?(credentials[:oauth2_keyfile])
140
140
  raise AdsCommon::Errors::AuthError,
141
- "Key file '%s' does not exist or not a file."
141
+ "Key file '%s' does not exist or not a file." %
142
+ credentials[:oauth2_keyfile]
142
143
  end
143
144
  end
144
145
 
@@ -170,6 +171,7 @@ module AdsCommon
170
171
  oauth_options = OAUTH2_CONFIG.merge({
171
172
  :issuer => credentials[:oauth2_issuer],
172
173
  :signing_key => credentials[:oauth2_key],
174
+ :person => credentials[:oauth2_prn],
173
175
  :scope => @scope,
174
176
  })
175
177
  return Signet::OAuth2::Client.new(oauth_options)
@@ -128,7 +128,7 @@ module AdsCommon
128
128
  # This could be used to include documentation from wsdl.
129
129
  #:doc => get_element_doc(operation, 'wsdl')
130
130
  }
131
- original_name = (name.snakecase.lower_camelcase == name)? nil : name
131
+ original_name = get_original_name_if_needed(name)
132
132
  method[:original_name] = original_name unless original_name.nil?
133
133
  return method
134
134
  end
@@ -207,7 +207,11 @@ module AdsCommon
207
207
  def get_element_fields(element)
208
208
  fields = []
209
209
  REXML::XPath.each(element, 'descendant::element') do |item|
210
- field = {:name => get_element_name(item).snakecase.to_sym,
210
+ name = get_element_name(item)
211
+ original_name = get_original_name_if_needed(name)
212
+ field = {
213
+ :name => name.snakecase.to_sym,
214
+ :original_name => original_name,
211
215
  :type => item.attribute('type').to_s.gsub(/^.+:/, ''),
212
216
  :min_occurs => attribute_to_int(item.attribute('minOccurs')),
213
217
  :max_occurs => attribute_to_int(item.attribute('maxOccurs'))}
@@ -216,6 +220,13 @@ module AdsCommon
216
220
  return fields
217
221
  end
218
222
 
223
+ # Returns original name if it can not be back-converted and required for
224
+ # XML serialization.
225
+ def get_original_name_if_needed(name)
226
+ return (name.nil? || (name.snakecase.lower_camelcase == name)) ?
227
+ nil : name
228
+ end
229
+
219
230
  # Simple converter for int values.
220
231
  def attribute_to_int(attribute)
221
232
  return nil if attribute.nil?
@@ -63,6 +63,11 @@ module AdsCommon
63
63
  item = args_hash[key]
64
64
  check_required_argument_present(item, field)
65
65
  if item
66
+ original_name = field[:original_name]
67
+ if original_name
68
+ key = handle_name_override(args_hash, key, original_name)
69
+ end
70
+
66
71
  item_type = get_full_type_signature(field[:type])
67
72
  item_ns = field[:ns] || type_ns
68
73
  key = handle_namespace_override(args_hash, key, item_ns) if item_ns
@@ -108,6 +113,13 @@ module AdsCommon
108
113
  end
109
114
  end
110
115
 
116
+ # Overrides non-standard name conversion.
117
+ def handle_name_override(args, key, original_name)
118
+ rename_hash_key(args, key, original_name)
119
+ replace_array_item(args[:order!], key, original_name)
120
+ return original_name
121
+ end
122
+
111
123
  # Overrides non-default namespace if requested.
112
124
  def handle_namespace_override(args, key, ns)
113
125
  add_extra_namespace(ns)
@@ -125,7 +137,8 @@ module AdsCommon
125
137
  when Hash
126
138
  validate_hash_arg(arg, parent, key, arg_type)
127
139
  when Time
128
- validate_time_arg(arg, parent, key)
140
+ arg = validate_time_arg(arg, parent, key)
141
+ validate_hash_arg(arg, parent, key, arg_type)
129
142
  else
130
143
  arg
131
144
  end
@@ -21,6 +21,6 @@
21
21
 
22
22
  module AdsCommon
23
23
  module ApiConfig
24
- CLIENT_LIB_VERSION = '0.9.0'
24
+ CLIENT_LIB_VERSION = '0.9.1'
25
25
  end
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-ads-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-08 00:00:00.000000000 Z
13
+ date: 2013-02-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: savon