identity-api-client 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e59ebb9f0609ddf1998b4637a1782cd7a808e934
4
- data.tar.gz: 1163c52bd8f1bd553da7f06748d86652da8b6f72
2
+ SHA256:
3
+ metadata.gz: 5c382b4b4ffb648c0649aadf483cc2e43aa72c92143eeb80539e791fa490bca9
4
+ data.tar.gz: 2112e6b70bb6021b5766c981ce5dc37a7bac513496ff2776fe65f501fe873ce9
5
5
  SHA512:
6
- metadata.gz: 52cbafc1abfbeebe9c0e7c48d68820249cf39be2278d9817692fc4eda6106064c5232f108db123fabb84087d36dc65c1a2532f69c7083c5473956c66c76c0f19
7
- data.tar.gz: 92bb38bbfa96713105602e96dce6cd593c2bba585cd5d9f8b3f383f2733e8d304796f198b6c4a51410ff195e168b62f73668fd338e895b975dbe383a3a9036fa
6
+ metadata.gz: 14a03f21ffac4facbf76406e46da832d2bca80c0806e3a03facebc52aefed86ee86376e4fd6bb7793807a78b96800e5731c0f1462fe308f9148ded48be752967
7
+ data.tar.gz: 331f0e57209dfcf3ac7577dcd5a49c3fa46992fc728ed1521fd2ef677e59d91075280381954a9302229ded3b3d4b5cee987bca3cc37a77a5b2c3f4be4520edc1
data/README.md CHANGED
@@ -14,9 +14,11 @@ This api client is distributed as a ruby gem.
14
14
 
15
15
  ```ruby
16
16
  identity = IdentityApiClient.new(host: 'id.test.com', api_token: 'abc123')
17
- person = identity.member.details('abc123')
17
+ person = identity.member.details('abc123', load_current_consents: true)
18
18
  person.first_name
19
19
  => 'Jane'
20
20
  person.last_name
21
21
  => 'Smith'
22
+ person.consents.first.public_id
23
+ => 'terms_of_service_1.0'
22
24
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.1.0
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: identity-api-client 0.0.3 ruby lib
5
+ # stub: identity-api-client 0.1.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "identity-api-client".freeze
9
- s.version = "0.0.3"
9
+ s.version = "0.1.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Nathan Woodhull".freeze]
14
- s.date = "2018-05-01"
14
+ s.date = "2018-09-04"
15
15
  s.description = "Provides a simple ruby binding to 38dgs identity API".freeze
16
16
  s.email = "nathan@controlshiftlabs.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
43
43
  ]
44
44
  s.homepage = "http://github.com/controlshift/identity-api-client".freeze
45
45
  s.licenses = ["MIT".freeze]
46
- s.rubygems_version = "2.6.13".freeze
46
+ s.rubygems_version = "2.7.6".freeze
47
47
  s.summary = "API Client for 38 Degree's Identity API".freeze
48
48
 
49
49
  if s.respond_to? :specification_version then
@@ -1,7 +1,14 @@
1
1
  module IdentityApiClient
2
2
  class Member < Base
3
- def details(guid, load_current_consents: false)
4
- params = {'guid' => guid, 'api_token' => client.connection.configuration.options[:api_token]}
3
+ def details(guid: nil, email: nil, load_current_consents: false)
4
+ if guid.present?
5
+ params = {'guid' => guid, 'api_token' => client.connection.configuration.options[:api_token]}
6
+ elsif email.present?
7
+ params = {'email' => email, 'api_token' => client.connection.configuration.options[:api_token]}
8
+ else
9
+ raise "Must have one of guid or email"
10
+ end
11
+
5
12
  if load_current_consents
6
13
  params['load_current_consents'] = true
7
14
  end
data/spec/member_spec.rb CHANGED
@@ -5,6 +5,14 @@ describe IdentityApiClient::Member do
5
5
 
6
6
  let(:request_path) { '/api/member/details' }
7
7
 
8
+ describe 'failure' do
9
+ context "with no email or guid passed" do
10
+ it "should raise error" do
11
+ expect { subject.member.details() }.to raise_error "Must have one of guid or email"
12
+ end
13
+ end
14
+ end
15
+
8
16
  describe 'success' do
9
17
  let(:status) { 200 }
10
18
 
@@ -18,7 +26,7 @@ describe IdentityApiClient::Member do
18
26
  let(:body) { fixture('details.json') }
19
27
 
20
28
  it 'should get member details back from the API' do
21
- resp = subject.member.details('abcdef1234567890')
29
+ resp = subject.member.details(guid: 'abcdef1234567890')
22
30
 
23
31
  expect(resp.first_name).to eq('Joe')
24
32
  expect(resp.last_name).to eq('Bloggs')
@@ -26,12 +34,13 @@ describe IdentityApiClient::Member do
26
34
  end
27
35
  end
28
36
 
37
+
29
38
  context 'with load_current_consents' do
30
39
  let(:expected_request) { {'guid' => 'abcdef1234567890', 'api_token' => '1234567890abcdef', 'load_current_consents' => true}.to_json }
31
40
  let(:body) { fixture('details_with_consents.json') }
32
41
 
33
42
  it 'should get member details with consents back from the API' do
34
- resp = subject.member.details('abcdef1234567890', load_current_consents: true)
43
+ resp = subject.member.details(guid: 'abcdef1234567890', load_current_consents: true)
35
44
 
36
45
  expect(resp.first_name).to eq('Joe')
37
46
  expect(resp.last_name).to eq('Bloggs')
@@ -41,6 +50,19 @@ describe IdentityApiClient::Member do
41
50
  expect(resp.consents[0].public_id).to eq 'terms_of_service_1.0'
42
51
  end
43
52
  end
53
+
54
+ context 'with email passed' do
55
+ let(:expected_request) { {'email' => 'test@example.com', 'api_token' => '1234567890abcdef'}.to_json }
56
+ let(:body) { fixture('details.json') }
57
+
58
+ it 'should get member details back from the API' do
59
+ resp = subject.member.details(email: 'test@example.com')
60
+
61
+ expect(resp.first_name).to eq('Joe')
62
+ expect(resp.last_name).to eq('Bloggs')
63
+ expect(resp.email).to eq('joe@bloggs.com')
64
+ end
65
+ end
44
66
  end
45
67
  end
46
68
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: identity-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-01 00:00:00.000000000 Z
11
+ date: 2018-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vertebrae
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  requirements: []
187
187
  rubyforge_project:
188
- rubygems_version: 2.6.13
188
+ rubygems_version: 2.7.6
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: API Client for 38 Degree's Identity API