lexer-identity 0.2.0 → 0.2.1
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/README.md +16 -42
- data/lexer-identity.gemspec +1 -1
- data/lib/lexer/identity/api.rb +5 -4
- data/lib/lexer/identity/version.rb +1 -1
- data/spec/lexer/identity/api_spec.rb +47 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70990bc536acb39402aa3585d646cf30e092449b
|
4
|
+
data.tar.gz: e806dea0b0c8fd7b87189a193c10ada70b4ec8ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81e3545ca200b23118642898bbcc09a186964eda906eef235990cfdd27510780cb1670db61ed43ba770632844cb5904a0c040113d78eca01ff7f46e7298d4ffc
|
7
|
+
data.tar.gz: ff1e6ba86f340c722bd6b89d56d003325dfad2410f773e69ecc467a8a2e90866cbecb31d4b9e6d28bba8041ed102f1a2d127db7652f10487121ee2755801ce82
|
data/README.md
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
[](http://travis-ci.org/lexerdev/identity-gem)
|
4
4
|
[](https://codeclimate.com/github/lexerdev/identity-gem)
|
5
|
+
[](http://badge.fury.io/rb/lexer-identity)
|
5
6
|
|
6
7
|
Lexer Identity Gem is the official Ruby Client for the [Lexer Identity](https://lexer.io/) API. The
|
7
8
|
Lexer Identity API lets brands contribute and consume from Lexer's Identity database directly from their apps.
|
8
9
|
|
10
|
+
|
9
11
|
## Installation
|
10
12
|
|
11
13
|
Add to your Gemfile:
|
@@ -16,51 +18,23 @@ or install from Rubygems:
|
|
16
18
|
|
17
19
|
gem install lexer-identity
|
18
20
|
|
21
|
+
And include it in your project as:
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
### Links:
|
23
|
-
|
24
|
-
Have a limited list of keys which can be reviewed at: http://developer.lexer.io/
|
25
|
-
Your hash should reflect the following format:
|
26
|
-
|
27
|
-
{
|
28
|
-
email: "joe.smith@mybrand.com",
|
29
|
-
phone: "61440000000",
|
30
|
-
twitter: "camplexer"
|
31
|
-
}
|
32
|
-
|
33
|
-
Multiple values can be provided via arrays:
|
34
|
-
|
35
|
-
{
|
36
|
-
email: ["joe.smith@mybrand.com", "j.smith@mybrand.com"],
|
37
|
-
phone: "61440000000",
|
38
|
-
twitter: "camplexer"
|
39
|
-
}
|
40
|
-
|
41
|
-
### Attributes:
|
42
|
-
|
43
|
-
Need to be defined by the valid namespace which should be provided
|
44
|
-
to you along with your tokens.
|
45
|
-
An attribute namespace is defined by: `com.brand.*` where `com.brand`
|
46
|
-
is defined along with your tokens and `*` can be replaced with any
|
47
|
-
`A-Za-z0-9._-` character.
|
48
|
-
|
49
|
-
Your attribute hash should reflect the following format:
|
23
|
+
require 'lexer'
|
50
24
|
|
51
|
-
{
|
52
|
-
"com.brand.email" => "joe.smith@mybrand.com",
|
53
|
-
"com.brand.phone" => "61440000000",
|
54
|
-
"com.brand.twitter" => "camplexer"
|
55
|
-
}
|
56
25
|
|
57
|
-
|
26
|
+
## Use
|
58
27
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
28
|
+
# Configure using the provided tokens
|
29
|
+
Lexer::Identity.configure do |config|
|
30
|
+
config.api_token = "..."
|
31
|
+
config.contributor_token = "..."
|
32
|
+
config.consumer_token = "..."
|
33
|
+
end
|
34
|
+
|
35
|
+
# Communicate via the enrich method
|
36
|
+
Lexer::Identity.enrich( links: { email: "test@lexer.io", twitter: "camplexer" }, attributes: { "io.lexer.name": { value: "Jane Smith", confidence: Lexer::Identity::CONFIDENCE_PROVIDED, ... } )
|
63
37
|
|
64
|
-
|
65
|
-
by JSON is supported by Lexer.
|
38
|
+
## Further Reading
|
66
39
|
|
40
|
+
See the full documentation at http://developer.lexer.io.
|
data/lexer-identity.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.licenses = ['MIT']
|
10
10
|
s.authors = ['Aaron Wallis']
|
11
11
|
s.email = 'code@Lexer.io'
|
12
|
-
s.homepage = 'https://github.com/lexerdev/
|
12
|
+
s.homepage = 'https://github.com/lexerdev/identity-gem'
|
13
13
|
s.summary = 'Lexer Identity API Client'
|
14
14
|
s.description = 'Consume and Contribute Identity data from your Ruby applications.'
|
15
15
|
|
data/lib/lexer/identity/api.rb
CHANGED
@@ -59,15 +59,16 @@ module Lexer
|
|
59
59
|
|
60
60
|
private
|
61
61
|
|
62
|
-
def self.validate_attributes
|
63
|
-
attributes.each
|
62
|
+
def self.validate_attributes(attributes)
|
63
|
+
attributes.each do |k, v|
|
64
64
|
unless v.is_a? Hash
|
65
65
|
fail Lexer::Identity::AttributePayloadError, "#{k} is not a hash"
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
|
+
unless [:value, :confidence].all? { |required_key| v.key?(required_key) || v.key?(required_key.to_s) }
|
68
69
|
fail Lexer::Identity::AttributePayloadError, "#{k} has an invalid payload"
|
69
70
|
end
|
70
|
-
|
71
|
+
end
|
71
72
|
end
|
72
73
|
|
73
74
|
def self.post_request(body)
|
@@ -114,6 +114,33 @@ describe Lexer::Identity do
|
|
114
114
|
)
|
115
115
|
end.must_raise Lexer::Identity::AttributePayloadError
|
116
116
|
end
|
117
|
+
it 'accepts symbols or string keys' do
|
118
|
+
stub_request(:post, 'https://identity.lexer.io/identity').
|
119
|
+
with(body: '{"id":"0a224111-ac64-4142-9198-adf8bf2c1a04","attributes":{"com.brand.car":{"value":"Tesla","confidence":2}},"api_token":"abc-123","contributor_token":"bcd-234"}', headers: { 'Content-Type' => 'application/json' }).
|
120
|
+
to_return(status: 200, body: '{"id":"0a224111-ac64-4142-9198-adf8bf2c1a04"}')
|
121
|
+
|
122
|
+
Lexer::Identity.enrich(
|
123
|
+
id: '0a224111-ac64-4142-9198-adf8bf2c1a04',
|
124
|
+
attributes: {
|
125
|
+
'com.brand.car' => {
|
126
|
+
value: 'Tesla',
|
127
|
+
confidence: Lexer::Identity::CONFIDENCE_PROVIDED
|
128
|
+
}
|
129
|
+
}
|
130
|
+
)
|
131
|
+
|
132
|
+
Lexer::Identity.enrich(
|
133
|
+
id: '0a224111-ac64-4142-9198-adf8bf2c1a04',
|
134
|
+
attributes: {
|
135
|
+
'com.brand.car' => {
|
136
|
+
'value' => 'Tesla',
|
137
|
+
'confidence' => Lexer::Identity::CONFIDENCE_PROVIDED
|
138
|
+
}
|
139
|
+
}
|
140
|
+
)
|
141
|
+
|
142
|
+
assert_requested(:post, 'https://identity.lexer.io/identity', times: 2)
|
143
|
+
end
|
117
144
|
it 'allows a complete payload' do
|
118
145
|
stub_request(:post, 'https://identity.lexer.io/identity').
|
119
146
|
with(body: '{"id":"0a224111-ac64-4142-9198-adf8bf2c1a04","attributes":{"com.brand.car":{"value":"Tesla","confidence":2}},"api_token":"abc-123","contributor_token":"bcd-234"}', headers: { 'Content-Type' => 'application/json' }).
|
@@ -129,6 +156,26 @@ describe Lexer::Identity do
|
|
129
156
|
}
|
130
157
|
)
|
131
158
|
|
159
|
+
assert_requested(:post, 'https://identity.lexer.io/identity', times: 1)
|
160
|
+
end
|
161
|
+
it 'allows a metadata payload' do
|
162
|
+
stub_request(:post, 'https://identity.lexer.io/identity').
|
163
|
+
with(body: '{"id":"0a224111-ac64-4142-9198-adf8bf2c1a04","attributes":{"com.brand.car":{"value":"Tesla","confidence":2,"metadata":{"extra":"data"}}},"api_token":"abc-123","contributor_token":"bcd-234"}', headers: { 'Content-Type' => 'application/json' }).
|
164
|
+
to_return(status: 200, body: '{"id":"0a224111-ac64-4142-9198-adf8bf2c1a04"}')
|
165
|
+
|
166
|
+
Lexer::Identity.enrich(
|
167
|
+
id: '0a224111-ac64-4142-9198-adf8bf2c1a04',
|
168
|
+
attributes: {
|
169
|
+
'com.brand.car' => {
|
170
|
+
value: 'Tesla',
|
171
|
+
confidence: Lexer::Identity::CONFIDENCE_PROVIDED,
|
172
|
+
metadata: {
|
173
|
+
extra: "data"
|
174
|
+
}
|
175
|
+
}
|
176
|
+
}
|
177
|
+
)
|
178
|
+
|
132
179
|
assert_requested(:post, 'https://identity.lexer.io/identity', times: 1)
|
133
180
|
end
|
134
181
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lexer-identity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Wallis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -48,7 +48,7 @@ files:
|
|
48
48
|
- spec/lexer/identity/configuration_spec.rb
|
49
49
|
- spec/lexer/identity_spec.rb
|
50
50
|
- spec/spec_helper.rb
|
51
|
-
homepage: https://github.com/lexerdev/
|
51
|
+
homepage: https://github.com/lexerdev/identity-gem
|
52
52
|
licenses:
|
53
53
|
- MIT
|
54
54
|
metadata: {}
|