dbalatero-evri_rpx 1.0.0 → 1.0.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.
- data/README.markdown +8 -2
- data/VERSION +1 -1
- data/evri_rpx.gemspec +3 -2
- data/lib/evri/rpx/session.rb +24 -0
- data/spec/evri/rpx/session_spec.rb +22 -9
- data/spec/fixtures/session/set_status.json +3 -0
- metadata +3 -2
data/README.markdown
CHANGED
@@ -2,6 +2,8 @@ evri_rpx
|
|
2
2
|
========
|
3
3
|
The `evri_rpx` library provides an wrapper around RPXNow's universal sign-on API. To learn more about this API, you can read up at [https://rpxnow.com/docs](https://rpxnow.com/docs)
|
4
4
|
|
5
|
+

|
6
|
+
|
5
7
|
Features
|
6
8
|
--------
|
7
9
|
- Clean and simple API design
|
@@ -17,8 +19,7 @@ TODO
|
|
17
19
|
Usage/Install
|
18
20
|
-------------
|
19
21
|
- Grab an API key/account from [http://rpxnow.com](http://rpxnow.com)
|
20
|
-
- As gem: `sudo gem install
|
21
|
-
- The gem will be on RubyForge soon, but their project request page is messed up, so no dice for now.
|
22
|
+
- As gem: `sudo gem install evri_rpx`
|
22
23
|
|
23
24
|
Examples
|
24
25
|
========
|
@@ -137,6 +138,11 @@ provider? methods for Users
|
|
137
138
|
# post an article to facebook via FB connect
|
138
139
|
end
|
139
140
|
|
141
|
+
Setting a Twitter/Facebook/MySpace status (Plus/Pro)
|
142
|
+
----------------------------------------------------
|
143
|
+
user = rpx.auth_info(params[:token])
|
144
|
+
rpx.set_status(user, 'My new status message.')
|
145
|
+
|
140
146
|
Copyright
|
141
147
|
=========
|
142
148
|
Copyright (c) 2009 Evri, Inc. Authored by David Balatero <dbalatero at evri dot com>. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/evri_rpx.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{evri_rpx}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["David Balatero"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-07-14}
|
10
10
|
s.email = %q{dbalatero@evri.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
@@ -45,6 +45,7 @@ Gem::Specification.new do |s|
|
|
45
45
|
"spec/fixtures/session/map.json",
|
46
46
|
"spec/fixtures/session/normal_error.json",
|
47
47
|
"spec/fixtures/session/service_down_error.json",
|
48
|
+
"spec/fixtures/session/set_status.json",
|
48
49
|
"spec/fixtures/session/unmap.json",
|
49
50
|
"spec/fixtures/user/dbalatero_facebook.json",
|
50
51
|
"spec/fixtures/user/dbalatero_gmail.json",
|
data/lib/evri/rpx/session.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
module Evri
|
2
2
|
module RPX
|
3
|
+
# All API calls go through this session object.
|
4
|
+
#
|
5
|
+
# Any API call has the chance of raising one of two errors, which
|
6
|
+
# you should be aware of:
|
7
|
+
# - ServiceUnavailableError, raised when RPX is down
|
8
|
+
# - APICallError, raised when RPX finds something wrong w/ your API call.
|
3
9
|
class Session
|
4
10
|
API_VERSION = 'v2'
|
5
11
|
API_HOST = 'rpxnow.com'
|
@@ -107,6 +113,24 @@ module Evri
|
|
107
113
|
json['stat'] == 'ok'
|
108
114
|
end
|
109
115
|
|
116
|
+
# Sets the status for a given user's social network. If this
|
117
|
+
# is not supported by the API, it will raise an error message
|
118
|
+
# to that effect.
|
119
|
+
#
|
120
|
+
# See: https://rpxnow.com/dos#api_set_status
|
121
|
+
#
|
122
|
+
# Only available in Plus and Pro.
|
123
|
+
def set_status(user_or_identifier, status_message)
|
124
|
+
params = { 'apiKey' => @api_key,
|
125
|
+
'status' => status_message }
|
126
|
+
params['identifier'] = identifier_param(user_or_identifier)
|
127
|
+
|
128
|
+
json = parse_response(get("/api/#{API_VERSION}/set_status",
|
129
|
+
params))
|
130
|
+
|
131
|
+
json['stat'] == 'ok'
|
132
|
+
end
|
133
|
+
|
110
134
|
# Remove (unmap) an OpenID from a primary key.
|
111
135
|
#
|
112
136
|
# Returns true.
|
@@ -19,7 +19,7 @@ describe Evri::RPX::Session do
|
|
19
19
|
it "should raise an APICallError if RPX returns an error message" do
|
20
20
|
FakeWeb.register_uri(:get,
|
21
21
|
'https://rpxnow.com:443/api/v2/auth_info',
|
22
|
-
:
|
22
|
+
:body => fixture_path('session/normal_error.json'),
|
23
23
|
:status => ['400', 'Bad Request'])
|
24
24
|
lambda {
|
25
25
|
@session.auth_info('errortoken')
|
@@ -29,7 +29,7 @@ describe Evri::RPX::Session do
|
|
29
29
|
it "should raise ServiceUnavailableError if the service is not available" do
|
30
30
|
FakeWeb.register_uri(:get,
|
31
31
|
'https://rpxnow.com:443/api/v2/auth_info',
|
32
|
-
:
|
32
|
+
:body => fixture_path('session/service_down_error.json'),
|
33
33
|
:status => ['404', 'Not Found'])
|
34
34
|
lambda {
|
35
35
|
@session.auth_info('errortoken')
|
@@ -39,7 +39,7 @@ describe Evri::RPX::Session do
|
|
39
39
|
it "should return a User object for a mapping" do
|
40
40
|
FakeWeb.register_uri(:get,
|
41
41
|
'https://rpxnow.com:443/api/v2/auth_info',
|
42
|
-
:
|
42
|
+
:body => fixture_path('user/dbalatero_gmail.json'))
|
43
43
|
|
44
44
|
result = @session.auth_info('mytoken')
|
45
45
|
result.should be_a_kind_of(Evri::RPX::User)
|
@@ -50,7 +50,7 @@ describe Evri::RPX::Session do
|
|
50
50
|
it "should return a set of identifiers to mappings" do
|
51
51
|
FakeWeb.register_uri(:get,
|
52
52
|
'https://rpxnow.com:443/api/v2/all_mappings',
|
53
|
-
:
|
53
|
+
:body => fixture_path('session/all_mappings.json'))
|
54
54
|
result = @session.all_mappings
|
55
55
|
result['1'].should == ['http://cygnus.myopenid.com/']
|
56
56
|
result['2'].should == ['http://brianellin.com/', 'http://brian.myopenid.com/']
|
@@ -61,7 +61,7 @@ describe Evri::RPX::Session do
|
|
61
61
|
before(:each) do
|
62
62
|
FakeWeb.register_uri(:get,
|
63
63
|
'https://rpxnow.com:443/api/v2/get_contacts',
|
64
|
-
:
|
64
|
+
:body => fixture_path('session/get_contacts.json'))
|
65
65
|
end
|
66
66
|
|
67
67
|
after(:each) do
|
@@ -90,7 +90,7 @@ describe Evri::RPX::Session do
|
|
90
90
|
before(:each) do
|
91
91
|
FakeWeb.register_uri(:get,
|
92
92
|
'https://rpxnow.com:443/api/v2/map',
|
93
|
-
:
|
93
|
+
:body => fixture_path('session/map.json'))
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should take in a User object as the second parameter" do
|
@@ -111,7 +111,7 @@ describe Evri::RPX::Session do
|
|
111
111
|
it "should return a Mappings object" do
|
112
112
|
FakeWeb.register_uri(:get,
|
113
113
|
'https://rpxnow.com:443/api/v2/mappings',
|
114
|
-
:
|
114
|
+
:body => fixture_path('mappings/identifiers.json'))
|
115
115
|
|
116
116
|
result = @session.mappings('dbalatero')
|
117
117
|
result.should be_a_kind_of(Evri::RPX::Mappings)
|
@@ -121,7 +121,7 @@ describe Evri::RPX::Session do
|
|
121
121
|
it "should take a User object in" do
|
122
122
|
FakeWeb.register_uri(:get,
|
123
123
|
'https://rpxnow.com:443/api/v2/mappings',
|
124
|
-
:
|
124
|
+
:body => fixture_path('mappings/identifiers.json'))
|
125
125
|
user = mock('user')
|
126
126
|
user.should_receive(:primary_key).and_return('dbalatero')
|
127
127
|
|
@@ -131,11 +131,24 @@ describe Evri::RPX::Session do
|
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
+
describe "set_status" do
|
135
|
+
it "should call set_status, and return true" do
|
136
|
+
FakeWeb.register_uri(:get,
|
137
|
+
'https://rpxnow.com/api/v2/set_status',
|
138
|
+
:body => fixture_path('session/set_status.json'))
|
139
|
+
user = mock('user')
|
140
|
+
user.should_receive(:identifier).and_return('https://www.facebook.com/dbalatero')
|
141
|
+
|
142
|
+
result = @session.set_status(user, "My new status!")
|
143
|
+
result.should be_true
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
134
147
|
describe "unmap" do
|
135
148
|
before(:each) do
|
136
149
|
FakeWeb.register_uri(:get,
|
137
150
|
'https://rpxnow.com:443/api/v2/unmap',
|
138
|
-
:
|
151
|
+
:body => fixture_path('session/unmap.json'))
|
139
152
|
end
|
140
153
|
|
141
154
|
it "should take a string as the identifier" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbalatero-evri_rpx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Balatero
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-07-14 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- spec/fixtures/session/map.json
|
56
56
|
- spec/fixtures/session/normal_error.json
|
57
57
|
- spec/fixtures/session/service_down_error.json
|
58
|
+
- spec/fixtures/session/set_status.json
|
58
59
|
- spec/fixtures/session/unmap.json
|
59
60
|
- spec/fixtures/user/dbalatero_facebook.json
|
60
61
|
- spec/fixtures/user/dbalatero_gmail.json
|