mindmatch 0.0.1.pre.beta5 → 0.0.1.pre.beta6
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/mind_match/client.rb +56 -19
- 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: b3e5a49deda4f439b0c972b291dae0c73882de96
|
4
|
+
data.tar.gz: 902887d3cbc230824ca003c98143a51c529765b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c01244cffb23578783e2c01ac75f787a5fa97a75add3efe26ac65628bd9eea223c8fbb97901a6e03ab8624d6a26fda295a3ca2ecf86f56b5e408677fd74ccf3f
|
7
|
+
data.tar.gz: a8894f5947afb821b3fcd10b34899b2b9adc213f7fc6b69908150680184f44aaca5a77119b7d7acccca518e82ee7946814866614a1fe067695579660ff6105da
|
data/lib/mind_match/client.rb
CHANGED
@@ -6,10 +6,51 @@ module MindMatch
|
|
6
6
|
class Unauthorized < StandardError; end
|
7
7
|
class UnexpectedError < StandardError; end
|
8
8
|
|
9
|
-
class
|
9
|
+
class QueryBuilder
|
10
|
+
def initialize
|
11
|
+
@fields = {}
|
12
|
+
end
|
10
13
|
|
11
|
-
|
12
|
-
|
14
|
+
def build
|
15
|
+
@fields = @fields.freeze
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_h
|
20
|
+
Hash[
|
21
|
+
fields.map { |k, _v| [k, []] }
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
''.tap do |s|
|
27
|
+
fields.each do |k, v|
|
28
|
+
s << "#{k} {\n"
|
29
|
+
s << v.join("\n")
|
30
|
+
s << "}\n"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
attr_reader :fields
|
38
|
+
|
39
|
+
def method_missing(m, *args, &block)
|
40
|
+
method = m.to_s
|
41
|
+
if method.start_with?('with_')
|
42
|
+
key = method.split('with_')[1]
|
43
|
+
@fields[key] = args[0]
|
44
|
+
self
|
45
|
+
else
|
46
|
+
super(m, *args, &block)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class Client
|
52
|
+
DEFAULT_ENDPOINT = 'https://api.mindmatch.ai'.freeze
|
53
|
+
PATH = '/graphql'.freeze
|
13
54
|
|
14
55
|
def initialize(token:, endpoint: DEFAULT_ENDPOINT)
|
15
56
|
@token = token
|
@@ -28,26 +69,22 @@ module MindMatch
|
|
28
69
|
create_matches(talents: talents, companies: companies)
|
29
70
|
end
|
30
71
|
|
31
|
-
def query_match(id:)
|
72
|
+
def query_match(id:, query: nil)
|
73
|
+
unless query.is_a?(QueryBuilder)
|
74
|
+
query = (@query_match_query ||= QueryBuilder.new
|
75
|
+
.with_results(%w(score personId positionId companyId))
|
76
|
+
.with_people(%w(id refId))
|
77
|
+
.with_positions(%w(id refId))
|
78
|
+
.build)
|
79
|
+
end
|
80
|
+
|
32
81
|
query_match_score = <<-GRAPHQL
|
33
82
|
query getMatch {
|
34
83
|
match: getMatch(id: "#{id}") {
|
35
84
|
id
|
36
85
|
status
|
37
86
|
data {
|
38
|
-
|
39
|
-
score
|
40
|
-
personId
|
41
|
-
positionId
|
42
|
-
}
|
43
|
-
people {
|
44
|
-
id
|
45
|
-
refId
|
46
|
-
}
|
47
|
-
positions {
|
48
|
-
id
|
49
|
-
refId
|
50
|
-
}
|
87
|
+
#{query.to_s}
|
51
88
|
}
|
52
89
|
}
|
53
90
|
}
|
@@ -59,8 +96,8 @@ module MindMatch
|
|
59
96
|
handle_error(raw_response)
|
60
97
|
response = JSON.parse(raw_response.body)
|
61
98
|
match = response.dig('data', 'match')
|
62
|
-
if match&.has_key?('data') # FIX: remove data
|
63
|
-
match = match.merge(match['data'] ||
|
99
|
+
if match&.has_key?('data') # FIX: remove data namespace in mindmatch api
|
100
|
+
match = match.merge(match['data'] || query.to_h)
|
64
101
|
match.delete('data')
|
65
102
|
end
|
66
103
|
match
|
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.beta6
|
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-10-
|
13
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|