mindmatch 0.0.1.pre.beta → 0.0.1.pre.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mind_match/client.rb +16 -0
- data/lib/mind_match/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: 510b993b376f44566ac27c884bd6bf84ce0f90fb
|
4
|
+
data.tar.gz: 005357f6ac53c683862e04f9c7c2099e0f8ce14a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5134b594b3dc800fbd59f1732c2714c1e019f04cafcd4042a1d600a9fa1b9db5c91b9b8c0ca0f2a7e7c7b53bf2db6890a907846f9820efe052dc821ca73eaedc
|
7
|
+
data.tar.gz: 6b080267bbe523da2aefbfae20d3230c33657404ea63c61bac626c747678788a7de77649af8c662c7061dd1020036036110d00b38a4412f1716d44b22372af34
|
data/lib/mind_match/client.rb
CHANGED
@@ -2,6 +2,10 @@ require 'faraday'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
module MindMatch
|
5
|
+
class ArgumentError < StandardError; end
|
6
|
+
class Unauthorized < StandardError; end
|
7
|
+
class UnexpectedError < StandardError; end
|
8
|
+
|
5
9
|
class Client
|
6
10
|
|
7
11
|
DEFAULT_ENDPOINT = 'https://api.mindmatch.ai'
|
@@ -52,6 +56,7 @@ module MindMatch
|
|
52
56
|
raw_response = conn.get do |req|
|
53
57
|
req.body = JSON.generate(query: query_match_score)
|
54
58
|
end
|
59
|
+
handle_error(raw_response)
|
55
60
|
response = JSON.parse(raw_response.body)
|
56
61
|
match = response.dig('data', 'match')
|
57
62
|
match = match['data'] if match.has_key?('data') # FIX: remove data namespece in mindmatch api
|
@@ -80,6 +85,7 @@ module MindMatch
|
|
80
85
|
raw_response = conn.post do |req|
|
81
86
|
req.body = JSON.generate(query: create_match_mutation)
|
82
87
|
end
|
88
|
+
handle_error(raw_response)
|
83
89
|
response = JSON.parse(raw_response.body)
|
84
90
|
response['data']['match']['id']
|
85
91
|
end
|
@@ -139,5 +145,15 @@ module MindMatch
|
|
139
145
|
"Content-Type": "application/json"
|
140
146
|
}
|
141
147
|
end
|
148
|
+
|
149
|
+
def handle_error(raw_response)
|
150
|
+
return if raw_response.status.to_s =~ /2\d\d/
|
151
|
+
|
152
|
+
case raw_response.status
|
153
|
+
when 400 then raise(ArgumentError, raw_response.body)
|
154
|
+
when 401 then raise(Unauthorized, raw_response.body)
|
155
|
+
else raise(UnexpectedError, raw_response.status, raw_response.body)
|
156
|
+
end
|
157
|
+
end
|
142
158
|
end
|
143
159
|
end
|
data/lib/mind_match/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mindmatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.pre.
|
4
|
+
version: 0.0.1.pre.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MindMatch
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-09-
|
13
|
+
date: 2017-09-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|