google-ads-common 0.12.4 → 0.12.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +3 -0
- data/lib/ads_common/parameters_validator.rb +40 -5
- data/lib/ads_common/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2db986ad1bd370703b2924e95f491c684118272d
|
4
|
+
data.tar.gz: 9a7073d4830e50f02fb50f72858ba37947d609b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 761e14fe7e3534f325fee15aac89063fc3679b2be21715e7419e9ec124cfac2440080a0ef8d8744860ae80b16159aab5c226ebe2a9336495261cd5631782615d
|
7
|
+
data.tar.gz: 9f71f9c5d76eb075788f295edd25b549f1d0afc9eb45fc3483d9f4e10efc2e3410c847fb2aa233405451bb64944e379b8a2122130d7df70a280a9e6c1049234c
|
data/ChangeLog
CHANGED
@@ -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
|
-
|
102
|
-
|
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,
|
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
|
-
|
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
|
data/lib/ads_common/version.rb
CHANGED
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
|
+
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-
|
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
|