prooflink_connect 0.0.20 → 0.0.21
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.
- data/Gemfile.lock +58 -0
- data/lib/prooflink_connect.rb +1 -0
- data/lib/prooflink_connect/activity.rb +35 -0
- data/lib/prooflink_connect/configuration.rb +1 -1
- data/lib/prooflink_connect/version.rb +1 -1
- data/prooflink_connect.gemspec +3 -2
- data/spec/prooflink_connect/activity_spec.rb +27 -0
- data/spec/spec_helper.rb +1 -0
- metadata +24 -9
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
prooflink_connect (0.0.20)
|
|
5
|
+
activesupport
|
|
6
|
+
httparty
|
|
7
|
+
json
|
|
8
|
+
oauth2
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: http://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
activesupport (3.2.7)
|
|
14
|
+
i18n (~> 0.6)
|
|
15
|
+
multi_json (~> 1.0)
|
|
16
|
+
addressable (2.2.8)
|
|
17
|
+
crack (0.3.1)
|
|
18
|
+
diff-lcs (1.1.3)
|
|
19
|
+
faraday (0.8.1)
|
|
20
|
+
multipart-post (~> 1.1)
|
|
21
|
+
httparty (0.8.3)
|
|
22
|
+
multi_json (~> 1.0)
|
|
23
|
+
multi_xml
|
|
24
|
+
httpauth (0.1)
|
|
25
|
+
i18n (0.6.0)
|
|
26
|
+
json (1.7.4)
|
|
27
|
+
jwt (0.1.5)
|
|
28
|
+
multi_json (>= 1.0)
|
|
29
|
+
multi_json (1.3.6)
|
|
30
|
+
multi_xml (0.5.1)
|
|
31
|
+
multipart-post (1.1.5)
|
|
32
|
+
oauth2 (0.8.0)
|
|
33
|
+
faraday (~> 0.8)
|
|
34
|
+
httpauth (~> 0.1)
|
|
35
|
+
jwt (~> 0.1.4)
|
|
36
|
+
multi_json (~> 1.0)
|
|
37
|
+
rack (~> 1.2)
|
|
38
|
+
rack (1.4.1)
|
|
39
|
+
rspec (2.11.0)
|
|
40
|
+
rspec-core (~> 2.11.0)
|
|
41
|
+
rspec-expectations (~> 2.11.0)
|
|
42
|
+
rspec-mocks (~> 2.11.0)
|
|
43
|
+
rspec-core (2.11.1)
|
|
44
|
+
rspec-expectations (2.11.2)
|
|
45
|
+
diff-lcs (~> 1.1.3)
|
|
46
|
+
rspec-mocks (2.11.1)
|
|
47
|
+
webmock (1.8.8)
|
|
48
|
+
addressable (~> 2.2.8)
|
|
49
|
+
crack (>= 0.1.7)
|
|
50
|
+
|
|
51
|
+
PLATFORMS
|
|
52
|
+
ruby
|
|
53
|
+
|
|
54
|
+
DEPENDENCIES
|
|
55
|
+
bundler (>= 1.0.0)
|
|
56
|
+
prooflink_connect!
|
|
57
|
+
rspec
|
|
58
|
+
webmock
|
data/lib/prooflink_connect.rb
CHANGED
|
@@ -7,6 +7,7 @@ module ProoflinkConnect
|
|
|
7
7
|
autoload :ShareButton, "prooflink_connect/share_button"
|
|
8
8
|
autoload :Invite, "prooflink_connect/invite"
|
|
9
9
|
autoload :Share, "prooflink_connect/share"
|
|
10
|
+
autoload :Activity, "prooflink_connect/activity"
|
|
10
11
|
|
|
11
12
|
def self.config
|
|
12
13
|
@configuration ||= Configuration.new
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'oauth2'
|
|
2
|
+
|
|
3
|
+
module ProoflinkConnect
|
|
4
|
+
class Activity
|
|
5
|
+
|
|
6
|
+
# POST /api/v2/activities
|
|
7
|
+
# parameters:
|
|
8
|
+
# - activity (required) => {:activity_type => {:identifier => "some_identifier", :name => "Some name", :value => "1"}}
|
|
9
|
+
# - user => {:email => "foo@bar.com", :first_name => "Foo", :last_name => "Bar"} [for new user]
|
|
10
|
+
# - user_token => "123-456-789" [for existing user]
|
|
11
|
+
# - extra_info (optional) => {} [extra custom info you like to pass to activity]
|
|
12
|
+
|
|
13
|
+
# SAMPLE:
|
|
14
|
+
|
|
15
|
+
# ProoflinkConnect::Activity.log({
|
|
16
|
+
# activity_type: {identifier: 'some_identifier', name: 'some_name', value: '1'},
|
|
17
|
+
# user: {first_name: 'jon', last_name: 'doe', email: 'jon@doe.com', identity_provider: 'prooflink'},
|
|
18
|
+
# extra_info: {your_id: '1234'}
|
|
19
|
+
# })
|
|
20
|
+
|
|
21
|
+
def self.log(params)
|
|
22
|
+
oauth_access_token = ProoflinkConnect.config.oauth_access_token
|
|
23
|
+
client = OAuth2::Client.new(nil, nil, {:site => ProoflinkConnect.config.base_uri})
|
|
24
|
+
access_token = OAuth2::AccessToken.new(client, oauth_access_token, :header_format => "OAuth %s")
|
|
25
|
+
|
|
26
|
+
begin
|
|
27
|
+
response = access_token.post 'api/v2/activities', :body => {:activity => params}
|
|
28
|
+
return JSON.parse(response.body)
|
|
29
|
+
|
|
30
|
+
rescue OAuth2::Error => error
|
|
31
|
+
return JSON.parse(error.response.body)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -14,7 +14,7 @@ module ProoflinkConnect
|
|
|
14
14
|
@@defaults.each_pair{|k,v| self.send("#{k}=",v)}
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
attr_accessor :provider_endpoint, :subdomain, :api_key, :protocol, :locale
|
|
17
|
+
attr_accessor :provider_endpoint, :subdomain, :api_key, :protocol, :locale, :oauth_access_token
|
|
18
18
|
|
|
19
19
|
def validate!
|
|
20
20
|
raise InvalidConfigurationError if [:provider_endpoint, :subdomain, :api_key, :protocol].any?{|option|send(option).blank?}
|
data/prooflink_connect.gemspec
CHANGED
|
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
|
|
5
5
|
s.name = "prooflink_connect"
|
|
6
6
|
s.version = ProoflinkConnect::VERSION
|
|
7
7
|
s.platform = Gem::Platform::RUBY
|
|
8
|
-
s.authors = ["Chiel Wester", "
|
|
9
|
-
s.email = ["chiel.wester@holder.nl", "
|
|
8
|
+
s.authors = ["Chiel Wester", "Jermaine Oosterling"]
|
|
9
|
+
s.email = ["chiel.wester@holder.nl", "jermaine.oosterling@prooflink.com"]
|
|
10
10
|
s.homepage = "https://github.com/prooflink/prooflink_connect"
|
|
11
11
|
s.summary = "Make a connection to the prooflink connect api"
|
|
12
12
|
s.description = "Make a connection to the prooflink connect api for single sign on authentication"
|
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
|
21
21
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
|
22
22
|
s.add_development_dependency "rspec"
|
|
23
23
|
s.add_development_dependency "webmock"
|
|
24
|
+
s.add_dependency 'oauth2'
|
|
24
25
|
|
|
25
26
|
s.files = `git ls-files`.split("\n")
|
|
26
27
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe ProoflinkConnect::Activity do
|
|
4
|
+
before do
|
|
5
|
+
reset_configuration
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
stub_request(:post, "https://example.prooflink.com/api/v2/activities").
|
|
10
|
+
with(:headers => {'Accept'=>'*/*', 'Authorization'=>'OAuth 4321', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Ruby'}).
|
|
11
|
+
to_return do |request|
|
|
12
|
+
if request.body.empty?
|
|
13
|
+
{:body => {:status => "ERROR", :message => "no activity specified"}.to_json}
|
|
14
|
+
else
|
|
15
|
+
{:body => {:status => "SUCCESS", :message => "activity succesfully created"}.to_json}
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should log activity as expected" do
|
|
21
|
+
params = {:activity_type => {:identifier => "my_identifier", :name => "My name", :value => 1},
|
|
22
|
+
:user => {:email => "jon@doe.com", :identity_provider => 'prooflink'}}
|
|
23
|
+
|
|
24
|
+
ProoflinkConnect::Activity.log(params).should eq({"status"=>"SUCCESS", "message"=>"activity succesfully created"})
|
|
25
|
+
ProoflinkConnect::Activity.log({}).should eq({"status"=>"ERROR", "message"=>"no activity specified"})
|
|
26
|
+
end
|
|
27
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: prooflink_connect
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 53
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 0.0.
|
|
9
|
+
- 21
|
|
10
|
+
version: 0.0.21
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Chiel Wester
|
|
14
|
-
-
|
|
14
|
+
- Jermaine Oosterling
|
|
15
15
|
autorequire:
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date:
|
|
20
|
-
default_executable:
|
|
19
|
+
date: 2012-07-30 00:00:00 Z
|
|
21
20
|
dependencies:
|
|
22
21
|
- !ruby/object:Gem::Dependency
|
|
23
22
|
name: json
|
|
@@ -105,10 +104,24 @@ dependencies:
|
|
|
105
104
|
version: "0"
|
|
106
105
|
type: :development
|
|
107
106
|
version_requirements: *id006
|
|
107
|
+
- !ruby/object:Gem::Dependency
|
|
108
|
+
name: oauth2
|
|
109
|
+
prerelease: false
|
|
110
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
|
111
|
+
none: false
|
|
112
|
+
requirements:
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
hash: 3
|
|
116
|
+
segments:
|
|
117
|
+
- 0
|
|
118
|
+
version: "0"
|
|
119
|
+
type: :runtime
|
|
120
|
+
version_requirements: *id007
|
|
108
121
|
description: Make a connection to the prooflink connect api for single sign on authentication
|
|
109
122
|
email:
|
|
110
123
|
- chiel.wester@holder.nl
|
|
111
|
-
-
|
|
124
|
+
- jermaine.oosterling@prooflink.com
|
|
112
125
|
executables: []
|
|
113
126
|
|
|
114
127
|
extensions: []
|
|
@@ -120,9 +133,11 @@ files:
|
|
|
120
133
|
- .rspec
|
|
121
134
|
- .travis.yml
|
|
122
135
|
- Gemfile
|
|
136
|
+
- Gemfile.lock
|
|
123
137
|
- README.md
|
|
124
138
|
- Rakefile
|
|
125
139
|
- lib/prooflink_connect.rb
|
|
140
|
+
- lib/prooflink_connect/activity.rb
|
|
126
141
|
- lib/prooflink_connect/assertion.rb
|
|
127
142
|
- lib/prooflink_connect/configuration.rb
|
|
128
143
|
- lib/prooflink_connect/invite.rb
|
|
@@ -133,12 +148,12 @@ files:
|
|
|
133
148
|
- lib/prooflink_connect/share_button.rb
|
|
134
149
|
- lib/prooflink_connect/version.rb
|
|
135
150
|
- prooflink_connect.gemspec
|
|
151
|
+
- spec/prooflink_connect/activity_spec.rb
|
|
136
152
|
- spec/prooflink_connect/configuration_spec.rb
|
|
137
153
|
- spec/prooflink_connect/invite_spec.rb
|
|
138
154
|
- spec/prooflink_connect/share_spec.rb
|
|
139
155
|
- spec/prooflink_connect_spec.rb
|
|
140
156
|
- spec/spec_helper.rb
|
|
141
|
-
has_rdoc: true
|
|
142
157
|
homepage: https://github.com/prooflink/prooflink_connect
|
|
143
158
|
licenses: []
|
|
144
159
|
|
|
@@ -170,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
170
185
|
requirements: []
|
|
171
186
|
|
|
172
187
|
rubyforge_project: prooflink_connect
|
|
173
|
-
rubygems_version: 1.
|
|
188
|
+
rubygems_version: 1.8.11
|
|
174
189
|
signing_key:
|
|
175
190
|
specification_version: 3
|
|
176
191
|
summary: Make a connection to the prooflink connect api
|