hachi 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hachi/clients/base.rb +13 -3
- data/lib/hachi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a319c1c79696358c41de7fa1df683d09162eb41b9c19b28fb5ffa56bd9da89b7
|
4
|
+
data.tar.gz: 0fe4dc40cd59d0b794009d2ba91e7c1330f84bc689f2236963b618c2ec511fb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dc84dd512c59811549ecf92e35d78eee5a843d4ec0cf45798b01b4573bd4d819fb32be67a0a7560a57b1b86e75d56d4a804e2e639f52d759bb2f3ed6c185fb0
|
7
|
+
data.tar.gz: 05b182a298cce9505a70fc5654c87990b8fe377255816fa83422a7a09ce0e36033606f602effc09ddf6ff68d1266550d7dd3239e50daceb5d16cc79c65752e63
|
data/lib/hachi/clients/base.rb
CHANGED
@@ -64,7 +64,11 @@ module Hachi
|
|
64
64
|
response = http.request(req)
|
65
65
|
json = parse_body(response.body)
|
66
66
|
|
67
|
-
|
67
|
+
code = response.code
|
68
|
+
unless code.start_with? "20"
|
69
|
+
message = json.dig("message")
|
70
|
+
raise Error, "Unsupported response code returned: #{code} (#{message})"
|
71
|
+
end
|
68
72
|
|
69
73
|
yield json
|
70
74
|
end
|
@@ -114,8 +118,8 @@ module Hachi
|
|
114
118
|
validate_range range
|
115
119
|
|
116
120
|
conditions = attributes.map do |key, value|
|
117
|
-
if value.is_a?(Array)
|
118
|
-
{
|
121
|
+
if key == :data && value.is_a?(Array)
|
122
|
+
{ _or: decompose_data(value) }
|
119
123
|
else
|
120
124
|
{ _string: "#{key}:#{value}" }
|
121
125
|
end
|
@@ -134,6 +138,12 @@ module Hachi
|
|
134
138
|
|
135
139
|
post("#{path}?range=#{range}", query: query) { |json| json }
|
136
140
|
end
|
141
|
+
|
142
|
+
def decompose_data(data)
|
143
|
+
data.map do |elem|
|
144
|
+
{ _field: "data", _value: elem }
|
145
|
+
end
|
146
|
+
end
|
137
147
|
end
|
138
148
|
end
|
139
149
|
end
|
data/lib/hachi/version.rb
CHANGED