bleacher_api 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +67 -1
- data/config/gemspec.yml +1 -1
- data/lib/bleacher_api.rb +7 -2
- data/spec/bleacher_api_spec.rb +28 -14
- metadata +4 -4
data/README.md
CHANGED
@@ -15,6 +15,8 @@ Table of Contents
|
|
15
15
|
|
16
16
|
* [GET /api/article/article.json](#article_article)
|
17
17
|
* [POST /api/authenticate/login.json](#authenticate_login)
|
18
|
+
* [GET /api/authenticate/logout.json](#authenticate_logout)
|
19
|
+
* [GET /api/authenticate/signup](#authenticate_signup)
|
18
20
|
* [GET /api/front/lead_articles.json](#front_lead_articles)
|
19
21
|
* [GET /api/geolocation/teams.json](#geolocation_teams)
|
20
22
|
* [GET /api/related/channel.json](#related_channel)
|
@@ -32,6 +34,7 @@ GET /api/article/article.json
|
|
32
34
|
* id - Article ID (required)
|
33
35
|
* article - When given any value, action includes article body in JSON output
|
34
36
|
* article[entry_id] - Changes article body to a quick hit or live blog entry
|
37
|
+
* article[only] - When given comma-separated parameters, returns only values for the parameters in JSON output
|
35
38
|
* comments[page] - When given a page number, action includes comments in JSON output
|
36
39
|
* related_content - When given any value, action includes related content in JSON output
|
37
40
|
|
@@ -62,6 +65,7 @@ POST /api/authenticate/login.json
|
|
62
65
|
|
63
66
|
* user[email]
|
64
67
|
* user[password]
|
68
|
+
* redirect_url (optional)
|
65
69
|
|
66
70
|
### Returns
|
67
71
|
|
@@ -81,6 +85,68 @@ http://bleacherreport.com/api/authenticate/login.json?user[email]=your@email.com
|
|
81
85
|
|
82
86
|
Please note that any request with a password should be sent as a POST, despite this example using GET.
|
83
87
|
|
88
|
+
### Redirect
|
89
|
+
|
90
|
+
When a `redirect_url` parameter is specified, B/R will redirect the request back to that URL, passing basic information
|
91
|
+
from the <a href="#user_user">User API</a> as GET parameters.
|
92
|
+
|
93
|
+
If the login fails, B/R will redirect the request back to the URL with a `fail=1` GET parameter.
|
94
|
+
|
95
|
+
<a name="authenticate_logout"></a>
|
96
|
+
|
97
|
+
GET /api/authenticate/logout.json
|
98
|
+
---------------------------------
|
99
|
+
|
100
|
+
### Parameters
|
101
|
+
|
102
|
+
* redirect_url (optional)
|
103
|
+
|
104
|
+
### Returns
|
105
|
+
|
106
|
+
Returns `true` if succeeded, `false` if not.
|
107
|
+
|
108
|
+
### Ruby Example
|
109
|
+
|
110
|
+
<pre>
|
111
|
+
BleacherApi::Authenticate.logout
|
112
|
+
</pre>
|
113
|
+
|
114
|
+
### HTTP Example
|
115
|
+
|
116
|
+
<pre>
|
117
|
+
http://bleacherreport.com/api/authenticate/logout.json
|
118
|
+
</pre>
|
119
|
+
|
120
|
+
### Redirect
|
121
|
+
|
122
|
+
When a `redirect_url` parameter is specified, B/R will redirect the request back to that URL, passing a `fail=1` parameter
|
123
|
+
if the logout failed.
|
124
|
+
|
125
|
+
<a name="authenticate_signup"></a>
|
126
|
+
|
127
|
+
GET /api/authenticate/signup
|
128
|
+
----------------------------
|
129
|
+
|
130
|
+
### Parameters
|
131
|
+
|
132
|
+
* redirect_url
|
133
|
+
* type (optional) - Optional values for this include: "fantasy"
|
134
|
+
|
135
|
+
### Returns
|
136
|
+
|
137
|
+
An HTML page with a sign up form.
|
138
|
+
|
139
|
+
### HTTP Example
|
140
|
+
|
141
|
+
<pre>
|
142
|
+
http://bleacherreport.com/api/authenticate/signup?redirect_url=http://bleacherreport.com&type=fantasy
|
143
|
+
</pre>
|
144
|
+
|
145
|
+
### Redirect
|
146
|
+
|
147
|
+
A `redirect_url` parameter is mandatory. B/R will redirect the request back to that URL, passing basic information
|
148
|
+
from the <a href="#user_user">User API</a> as GET parameters.
|
149
|
+
|
84
150
|
<a name="front_lead_articles"></a>
|
85
151
|
|
86
152
|
GET /api/front/lead_articles.json
|
@@ -341,4 +407,4 @@ LOGIN=user@user.com PASSWORD=password URL=http://localhost ONLY=geolocation spec
|
|
341
407
|
|
342
408
|
<code>URL</code> defaults to "http://bleacherreport.com".
|
343
409
|
|
344
|
-
<code>ONLY</code> is optional, and allows you to only run a specific group of specs.
|
410
|
+
<code>ONLY</code> is optional, and allows you to only run a specific group of specs.
|
data/config/gemspec.yml
CHANGED
data/lib/bleacher_api.rb
CHANGED
@@ -27,16 +27,21 @@ class BleacherApi
|
|
27
27
|
|
28
28
|
class Authenticate
|
29
29
|
class <<self
|
30
|
-
def login(email, password)
|
30
|
+
def login(email, password, redirect=nil)
|
31
31
|
result = BleacherApi.call(:post, 'authenticate/login', {
|
32
32
|
'user[email]' => email,
|
33
|
-
'user[password]' => password
|
33
|
+
'user[password]' => password,
|
34
|
+
'redirect' => nil
|
34
35
|
})
|
35
36
|
if result
|
36
37
|
BleacherApi::Config.token result['token']
|
37
38
|
end
|
38
39
|
result
|
39
40
|
end
|
41
|
+
|
42
|
+
def logout
|
43
|
+
BleacherApi.call(:get, 'authenticate/logout')
|
44
|
+
end
|
40
45
|
end
|
41
46
|
end
|
42
47
|
|
data/spec/bleacher_api_spec.rb
CHANGED
@@ -8,26 +8,40 @@ describe BleacherApi do
|
|
8
8
|
|
9
9
|
if only?(:Authenticate)
|
10
10
|
describe :Authenticate do
|
11
|
-
describe
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
describe :login do
|
12
|
+
|
13
|
+
describe 'success' do
|
14
|
+
before(:all) do
|
15
|
+
@response = BleacherApi::Authenticate.login(ENV['LOGIN'], ENV['PASSWORD'])
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return a hash with valid keys" do
|
19
|
+
@response.keys.length.should == @user_keys.length
|
20
|
+
(@response.keys - @user_keys).should == []
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should set Config.token" do
|
24
|
+
BleacherApi::Config.token.should == @response['token']
|
25
|
+
end
|
19
26
|
end
|
20
27
|
|
21
|
-
|
22
|
-
|
28
|
+
describe 'failure' do
|
29
|
+
before(:all) do
|
30
|
+
@response = BleacherApi::Authenticate.login('fail', 'fail')
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return false" do
|
34
|
+
@response.should == false
|
35
|
+
end
|
23
36
|
end
|
24
37
|
end
|
25
|
-
|
26
|
-
describe
|
38
|
+
|
39
|
+
describe :logout do
|
40
|
+
|
27
41
|
before(:all) do
|
28
|
-
@response = BleacherApi::Authenticate.
|
42
|
+
@response = BleacherApi::Authenticate.logout
|
29
43
|
end
|
30
|
-
|
44
|
+
|
31
45
|
it "should return false" do
|
32
46
|
@response.should == false
|
33
47
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bleacher_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bleacher Report
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-29 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|