identity_linker 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in identity_linker.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'rake'
8
+ gem 'rspec'
9
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Josh Starcher
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # IdentityLinker
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'identity_linker'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install identity_linker
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = FileList['spec/**/*_spec.rb']
8
+ end
9
+ task :default => :spec
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/identity_linker/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Josh Starcher"]
6
+ gem.email = ["josh.starcher@gmail.com"]
7
+ gem.description = %q{Ruby library for accessing Cru's Identity Linking system}
8
+ gem.summary = %q{Ruby library for accessing Cru's Identity Linking system}
9
+ gem.homepage = "https://github.com/CruGlobal/identity_linker"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "identity_linker"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = IdentityLinker::VERSION
17
+ gem.add_dependency('savon', '~> 0.9.14')
18
+ end
@@ -0,0 +1,10 @@
1
+ module IdentityLinker
2
+ Config = Struct.new(:server_id, :server_secret) do
3
+
4
+ def self.default
5
+ config = new
6
+ config
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,141 @@
1
+ require 'savon'
2
+
3
+ module IdentityLinker
4
+ class Linker
5
+ extend Savon::Model
6
+
7
+ endpoint "https://signin.ccci.org/ws-identity-linking/idlinking"
8
+ namespace "http://webservice.linking.idm.ccci.org/"
9
+
10
+ attr_reader :server_id, :server_secret
11
+
12
+ def initialize(server_id = nil, server_secret = nil)
13
+ @server_id = server_id || IdentityLinker.config.server_id
14
+ @server_secret = server_secret || IdentityLinker.config.server_secret
15
+ end
16
+
17
+ def find_linked_identity(id_type, id_value, target)
18
+ response = client.request(:wsdl, :find_linked_identity) do
19
+ xml = <<-END
20
+ <serverId>#{server_id}</serverId>
21
+ <serverSecret>#{server_secret}</serverSecret>
22
+ <identity>
23
+ <idType>#{id_type}</idType>
24
+ <idValue>#{id_value}</idValue>
25
+ </identity>
26
+ <target>#{target}</target>
27
+ END
28
+ soap.body = xml
29
+ end
30
+
31
+ if response.success?
32
+ return response.to_hash[:find_linked_identity_response][:linked_identity]
33
+ end
34
+
35
+ nil
36
+ end
37
+
38
+ def self.find_linked_identity(id_type, id_value, target)
39
+ new.find_linked_identity(id_type, id_value, target)
40
+ end
41
+
42
+ def find_linked_identity_with_details(id_type, id_value, target)
43
+ response = client.request(:wsdl, :find_linked_identity_with_details) do
44
+ xml = <<-END
45
+ <serverId>#{server_id}</serverId>
46
+ <serverSecret>#{server_secret}</serverSecret>
47
+ <identity>
48
+ <idType>#{id_type}</idType>
49
+ <idValue>#{id_value}</idValue>
50
+ </identity>
51
+ <target>#{target}</target>
52
+ END
53
+ soap.body = xml
54
+ end
55
+
56
+ if response.success?
57
+ return response.to_hash[:find_linked_identity_with_details_response][:linked_identity]
58
+ end
59
+
60
+ nil
61
+ end
62
+
63
+ def self.find_linked_identity_with_details(id_type, id_value, target)
64
+ new.find_linked_identity_with_details(id_type, id_value, target)
65
+ end
66
+
67
+ def find_all_linked_identities(id_type, id_value)
68
+ response = client.request(:wsdl, :find_all_linked_identities) do
69
+ xml = <<-END
70
+ <serverId>#{server_id}</serverId>
71
+ <serverSecret>#{server_secret}</serverSecret>
72
+ <identity>
73
+ <idType>#{id_type}</idType>
74
+ <idValue>#{id_value}</idValue>
75
+ </identity>
76
+ END
77
+ soap.body = xml
78
+ end
79
+
80
+ if response.success?
81
+ return response.to_hash[:find_all_linked_identities_response][:linked_identity]
82
+ end
83
+
84
+ nil
85
+ end
86
+
87
+ def self.find_all_linked_identities(id_type, id_value)
88
+ new.find_all_linked_identities(id_type, id_value)
89
+ end
90
+
91
+ def find_all_linked_identities_with_details(id_type, id_value)
92
+ response = client.request(:wsdl, :find_all_linked_identities_with_details) do
93
+ xml = <<-END
94
+ <serverId>#{server_id}</serverId>
95
+ <serverSecret>#{server_secret}</serverSecret>
96
+ <identity>
97
+ <idType>#{id_type}</idType>
98
+ <idValue>#{id_value}</idValue>
99
+ </identity>
100
+ END
101
+ soap.body = xml
102
+ end
103
+
104
+ if response.success?
105
+ return response.to_hash[:find_all_linked_identities_with_details_response][:linked_identity]
106
+ end
107
+
108
+ nil
109
+ end
110
+
111
+ def self.find_all_linked_identities_with_details(id_type, id_value)
112
+ new.find_all_linked_identities_with_details(id_type, id_value)
113
+ end
114
+
115
+ def find_linked_identities_of_type(id_type, id_value, target)
116
+ response = client.request(:wsdl, :find_linked_identities_of_type) do
117
+ xml = <<-END
118
+ <serverId>#{server_id}</serverId>
119
+ <serverSecret>#{server_secret}</serverSecret>
120
+ <identity>
121
+ <idType>#{id_type}</idType>
122
+ <idValue>#{id_value}</idValue>
123
+ </identity>
124
+ <target>#{target}</target>
125
+ END
126
+ soap.body = xml
127
+ end
128
+
129
+ if response.success?
130
+ return [response.to_hash[:find_linked_identities_of_type_response][:linked_identity]].flatten.compact
131
+ end
132
+
133
+ nil
134
+ end
135
+
136
+ def self.find_linked_identities_of_type(id_type, id_value, target)
137
+ new.find_linked_identities_of_type(id_type, id_value, target)
138
+ end
139
+
140
+ end
141
+ end
@@ -0,0 +1,3 @@
1
+ module IdentityLinker
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,18 @@
1
+ require "identity_linker/version"
2
+ require "identity_linker/linker"
3
+ require "identity_linker/config"
4
+
5
+
6
+ module IdentityLinker
7
+ extend self
8
+
9
+ def configure
10
+ yield config
11
+ end
12
+
13
+ def config
14
+ @config ||= Config.default
15
+ end
16
+
17
+ attr_writer :config
18
+ end
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require'rspec'
4
+ require'identity_linker'
5
+ RSpec.configure do |config|
6
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: identity_linker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Josh Starcher
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: savon
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.14
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.14
30
+ description: Ruby library for accessing Cru's Identity Linking system
31
+ email:
32
+ - josh.starcher@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - identity_linker.gemspec
43
+ - lib/identity_linker.rb
44
+ - lib/identity_linker/config.rb
45
+ - lib/identity_linker/linker.rb
46
+ - lib/identity_linker/version.rb
47
+ - spec/spec_helper.rb
48
+ homepage: https://github.com/CruGlobal/identity_linker
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.24
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Ruby library for accessing Cru's Identity Linking system
72
+ test_files:
73
+ - spec/spec_helper.rb