google-ads-common 0.12.4 → 0.12.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f6a5db7dfd14b7bf4d37bdbc437877bc0c62e00
4
- data.tar.gz: 4f6a32a4c035bc75da84395ebf93f074eb262b34
3
+ metadata.gz: 2db986ad1bd370703b2924e95f491c684118272d
4
+ data.tar.gz: 9a7073d4830e50f02fb50f72858ba37947d609b0
5
5
  SHA512:
6
- metadata.gz: af9f3aed5785a4c41c5608b286b7e9eb949085866815357f90d59cdb8319c9ccba0748c7ca44888f37342cb4919197b8cf417f5b7a40d15d41f60cab52e2377e
7
- data.tar.gz: 412ac052f5c5730a06bbe08b63f8ba3837df2059312f2625a3a3d5e03592223d43bc928ba679c36deacb69e8539cef9e7efbc1e9b6a65498cade2110a5a05ac8
6
+ metadata.gz: 761e14fe7e3534f325fee15aac89063fc3679b2be21715e7419e9ec124cfac2440080a0ef8d8744860ae80b16159aab5c226ebe2a9336495261cd5631782615d
7
+ data.tar.gz: 9f71f9c5d76eb075788f295edd25b549f1d0afc9eb45fc3483d9f4e10efc2e3410c847fb2aa233405451bb64944e379b8a2122130d7df70a280a9e6c1049234c
data/ChangeLog CHANGED
@@ -1,3 +1,6 @@
1
+ 0.12.5:
2
+ - Fixed issue #75.
3
+
1
4
  0.12.4:
2
5
  - Started enforcing minumum Ruby runtime version via gemspec.
3
6
 
@@ -88,6 +88,19 @@ module AdsCommon
88
88
  def validate_choice_argument(item, parent, key, item_type)
89
89
  result = false
90
90
  if item_type.kind_of?(Hash) && item_type.include?(:choices)
91
+ # If we have an array of choices, we need to go over them individually.
92
+ # We drop original array and replace it with the generated one that's
93
+ # nested one level more.
94
+ if item.kind_of?(Array)
95
+ parent[key] = []
96
+ item.each do |sub_item|
97
+ unless validate_choice_argument(sub_item, parent, key, item_type)
98
+ validate_arg(sub_item, parent, key, item_type)
99
+ end
100
+ end
101
+ return true
102
+ end
103
+ # New root needed for extra nesting we have (choice field).
91
104
  new_root = {}
92
105
  choice_items = arrayize(item)
93
106
  choice_items.each do |choice_item|
@@ -98,22 +111,44 @@ module AdsCommon
98
111
  raise AdsCommon::Errors::TypeMismatchError.new(
99
112
  'choice subtype', choice_type, choice_item.to_s())
100
113
  end
101
- new_root[choice_type] ||= []
102
- new_root[choice_type] << choice_item
114
+ choice_item[:xsi_type] = choice_type
115
+ # Note we use original name that produces a string like
116
+ # "BasicUserList". That's needed as the name is generated out of
117
+ # standard naming ("basicUserList") which would otherwise be produced.
118
+ choice_key = choice_item_type[:original_name]
119
+ new_root[choice_key] = choice_item
103
120
  type_signature = get_full_type_signature(choice_type)
104
- validate_arg(choice_item, new_root, choice_type, type_signature)
121
+ validate_arg(choice_item, new_root, choice_key, type_signature)
122
+ end
123
+ if parent[key].kind_of?(Array)
124
+ parent[key] << new_root
125
+ else
126
+ parent[key] = new_root
105
127
  end
106
- parent[key] = new_root
107
128
  result = true
108
129
  end
109
130
  return result
110
131
  end
111
132
 
112
133
  def find_choice_by_xsi_type(xsi_type, item_def)
113
- index = item_def.index {|item| xsi_type.eql?(item[:original_name])}
134
+ return nil if xsi_type.nil?
135
+ # Method may allow this class name or any of its ancestors.
136
+ possible_names = collect_parent_types(xsi_type)
137
+ index = item_def.index do |item|
138
+ possible_names.include?(item[:original_name])
139
+ end
114
140
  return index.nil? ? nil : item_def[index]
115
141
  end
116
142
 
143
+ def collect_parent_types(xsi_type)
144
+ result = [xsi_type]
145
+ type_signature = @registry.get_type_signature(xsi_type)
146
+ if !type_signature.nil? && !type_signature[:base].nil?
147
+ result += collect_parent_types(type_signature[:base])
148
+ end
149
+ return result
150
+ end
151
+
117
152
  # Checks if no extra fields provided outside of known ones.
118
153
  def check_extra_fields(args_hash, known_fields)
119
154
  extra_fields = args_hash.keys - known_fields - IGNORED_HASH_KEYS
@@ -19,6 +19,6 @@
19
19
 
20
20
  module AdsCommon
21
21
  module ApiConfig
22
- CLIENT_LIB_VERSION = '0.12.4'
22
+ CLIENT_LIB_VERSION = '0.12.5'
23
23
  end
24
24
  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.12.4
4
+ version: 0.12.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Gomes
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-08-31 00:00:00.000000000 Z
13
+ date: 2016-10-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: google-ads-savon