airship-client 0.1.1 → 0.1.4
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 +4 -4
- data/lib/airship-client.rb +67 -18
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3eddb0d777479b5d30f9c41bf99e1e38316c80d
|
4
|
+
data.tar.gz: 9a83adab62cbacf7b6dd024811f8037955c37c97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 685994819320fc6f5d95f8f8d375f85ca4592bdd3718fe32b6edd768e7d07c4ea3dc454b921d95218a8c51559497c92a3c6ce914712d079109b0d0628c1ce248
|
7
|
+
data.tar.gz: 490b621ebbf3647121ea6bb281f811556a0b02428c0acf0a557f24d73481629d8af8a826054b96fb58d8a645eae9c7f054409a1f0d0fa756ccf427ecfcbe96aa
|
data/lib/airship-client.rb
CHANGED
@@ -131,6 +131,7 @@ class AirshipClient
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def gate(control_name, obj)
|
134
|
+
is_array = obj.instance_of?(Array)
|
134
135
|
begin
|
135
136
|
response = @conn.post do |req|
|
136
137
|
req.url(V1_GATE_ENDPOINT)
|
@@ -140,12 +141,76 @@ class AirshipClient
|
|
140
141
|
request_obj = {}
|
141
142
|
request_obj["env_key"] = @env_key || @@env_key
|
142
143
|
request_obj["control_short_name"] = control_name
|
143
|
-
|
144
|
+
if is_array
|
145
|
+
request_obj["objects"] = obj
|
146
|
+
else
|
147
|
+
request_obj["object"] = obj
|
148
|
+
end
|
144
149
|
req.body = request_obj.to_json
|
145
150
|
end
|
146
151
|
result = JSON.parse(response.body)
|
147
|
-
if result[SERVER_INFO_KEY] == SERVER_STATE_MAINTENANCE
|
152
|
+
if result.instance_of?(Hash) && result[SERVER_INFO_KEY] == SERVER_STATE_MAINTENANCE
|
148
153
|
if @@fail_gracefully
|
154
|
+
if is_array
|
155
|
+
results = []
|
156
|
+
for i in 0...obj.length
|
157
|
+
o = obj[i]
|
158
|
+
results.push(
|
159
|
+
{
|
160
|
+
"type" => o["type"],
|
161
|
+
"id" => o["id"],
|
162
|
+
"display_name" => o["display_name"],
|
163
|
+
"control" => {
|
164
|
+
"control_short_name" => control_name,
|
165
|
+
"value" => false,
|
166
|
+
"variation" => nil,
|
167
|
+
"from_server" => false,
|
168
|
+
"from_cache" => false
|
169
|
+
}
|
170
|
+
}
|
171
|
+
)
|
172
|
+
end
|
173
|
+
return results
|
174
|
+
else
|
175
|
+
return {
|
176
|
+
"type" => obj["type"],
|
177
|
+
"id" => obj["id"],
|
178
|
+
"display_name" => obj["display_name"],
|
179
|
+
"control" => {
|
180
|
+
"control_short_name" => control_name,
|
181
|
+
"value" => false,
|
182
|
+
"variation" => nil,
|
183
|
+
"from_server" => false,
|
184
|
+
"from_cache" => false
|
185
|
+
}
|
186
|
+
}
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
result
|
191
|
+
rescue Faraday::TimeoutError => e
|
192
|
+
if @@fail_gracefully
|
193
|
+
if is_array
|
194
|
+
results = []
|
195
|
+
for i in 0...obj.length
|
196
|
+
o = obj[i]
|
197
|
+
results.push(
|
198
|
+
{
|
199
|
+
"type" => o["type"],
|
200
|
+
"id" => o["id"],
|
201
|
+
"display_name" => o["display_name"],
|
202
|
+
"control" => {
|
203
|
+
"control_short_name" => control_name,
|
204
|
+
"value" => false,
|
205
|
+
"variation" => nil,
|
206
|
+
"from_server" => false,
|
207
|
+
"from_cache" => false
|
208
|
+
}
|
209
|
+
}
|
210
|
+
)
|
211
|
+
end
|
212
|
+
return results
|
213
|
+
else
|
149
214
|
return {
|
150
215
|
"type" => obj["type"],
|
151
216
|
"id" => obj["id"],
|
@@ -159,22 +224,6 @@ class AirshipClient
|
|
159
224
|
}
|
160
225
|
}
|
161
226
|
end
|
162
|
-
end
|
163
|
-
result
|
164
|
-
rescue Faraday::TimeoutError => e
|
165
|
-
if @@fail_gracefully
|
166
|
-
return {
|
167
|
-
"type" => obj["type"],
|
168
|
-
"id" => obj["id"],
|
169
|
-
"display_name" => obj["display_name"],
|
170
|
-
"control" => {
|
171
|
-
"control_short_name" => control_name,
|
172
|
-
"value" => false,
|
173
|
-
"variation" => nil,
|
174
|
-
"from_server" => false,
|
175
|
-
"from_cache" => false
|
176
|
-
}
|
177
|
-
}
|
178
227
|
else
|
179
228
|
raise
|
180
229
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airship-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Airship Dev Team
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: '0.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.7.7
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.7.7
|
41
41
|
description: Ruby SDK
|
42
42
|
email: hello@airshiphq.com
|
43
43
|
executables: []
|