br_api_fantasy 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.markdown +32 -1
  2. data/gemspec.rb +7 -1
  3. data/lib/br_api_fantasy.rb +17 -0
  4. metadata +19 -6
@@ -18,9 +18,12 @@ Usage:
18
18
 
19
19
  After a user logs in or signs up from one of the Bleacher Report's fantasy branded pages, they will be redirected to the passthrough params[:return_to] url, which can be set by the Fantasy Games 3rd party, along with a token (user_token). The 3rd party can use the token to then generate the verified hash on their servers. BR will generate the same hash and compare against it to ensure it's coming from a trusted source.
20
20
 
21
- The plugin contains the method to generate the api request, this method will use the api_key configured in br_api_fantasy.yml:
21
+ The plugin contains methods to talk to the br fantasy api. The methods will use the api_key configured in br_api_fantasy.yml:
22
+
23
+ Methods available:
22
24
 
23
25
  Br::Api::Fantasy.authenticate('user-token-returned-from-login-page')
26
+ Br::Api::Fantasy.set_team('user-token-returned-from-login-page', team_id = 160) # 160 is dallas cowboys
24
27
 
25
28
  Example:
26
29
  ------------
@@ -42,6 +45,34 @@ $ ./script/console
42
45
  "response_summary"=>"login success",
43
46
  "response_status"=>200}
44
47
  => nil
48
+ >> pp Br::Api::Fantasy.authenticate('2e54040f9019023d2ad225b92d08ee1c14af1948')
49
+ {"response_details"=>"signature successfully matched",
50
+ "response_data"=>
51
+ {"user_last_name"=>"Cartman",
52
+ "user_email"=>"eric.cartman@southpark.com",
53
+ "user_first_name"=>"Eric",
54
+ "user_permalink"=>"http://breport.local/users/337228-eric-cartman",
55
+ "user_id"=>337228,
56
+ "fantasy_team_id"=>nil,
57
+ "fantasy_team_name"=>nil},
58
+ "response_summary"=>"user found",
59
+ "response_status"=>200}
60
+ => nil
61
+ >> pp Br::Api::Fantasy.set_team('2e54040f9019023d2ad225b92d08ee1c14af1948', 160)
62
+ {"response_details"=>"",
63
+ "response_data"=>
64
+ {"user_last_name"=>"Cartman",
65
+ "user_email"=>"eric.cartman@southpark.com",
66
+ "user_first_name"=>"Eric",
67
+ "errors"=>"",
68
+ "user_permalink"=>"http://breport.local/users/337228-eric-cartman",
69
+ "success"=>false,
70
+ "user_id"=>337228,
71
+ "fantasy_team_id"=>160,
72
+ "fantasy_team_name"=>"Dallas Cowboys"},
73
+ "response_summary"=>"fantasy team saved success",
74
+ "response_status"=>200}
75
+ => nil
45
76
  >>
46
77
  </pre>
47
78
 
data/gemspec.rb CHANGED
@@ -13,7 +13,7 @@ GEM_SPEC = Gem::Specification.new do |s|
13
13
  s.name = GEM_NAME
14
14
  s.platform = Gem::Platform::RUBY
15
15
  s.require_path = "lib"
16
- s.version = "0.1.4"
16
+ s.version = "0.1.5"
17
17
  s.add_dependency('httparty', '>= 0.5.2')
18
18
 
19
19
  path = File.dirname(__FILE__)+"/config/br_api_fantasy.example.yml"
@@ -36,6 +36,12 @@ Also, create a br_api_fantasy.yml file and place it in your rails_app's' config
36
36
  The br_api_fantasy.yml file will contain the following:
37
37
 
38
38
  #{yaml_instructions}
39
+
40
+ IF YOU'RE UPGRADING THE GEM:
41
+
42
+ Remember to update your rails app to use the newer gem:
43
+
44
+ config.gem 'br_api_fantasy', :version => #{s.version}
39
45
 
40
46
  #{'*'*50}
41
47
  POST_INSTALL_MESSAGE
@@ -36,6 +36,23 @@ module Br
36
36
  raise "response is not a Hash or String #{response.class}"
37
37
  end
38
38
  end
39
+
40
+ def self.set_team(token, team_id)
41
+ base_uri credentails['api_uri']
42
+ response = get '/api/fantasy/set_team.json',
43
+ :query => {:token => token, :team_id => team_id, :sig => sig(token)}
44
+ if response.is_a?(Hash)
45
+ return response
46
+ elsif response.is_a?(String)
47
+ return {
48
+ :response_status => 500,
49
+ :response_details => "500 Error",
50
+ :response_data => response
51
+ }
52
+ else
53
+ raise "response is not a Hash or String #{response.class}"
54
+ end
55
+ end
39
56
  end
40
57
  end
41
58
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: br_api_fantasy
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 17
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 4
9
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
10
11
  platform: ruby
11
12
  authors:
12
13
  - Tung Nguyen
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-07-19 00:00:00 -07:00
18
+ date: 2010-08-10 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: httparty
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 15
27
30
  segments:
28
31
  - 0
29
32
  - 5
@@ -58,13 +61,13 @@ licenses: []
58
61
  post_install_message: |
59
62
  **************************************************
60
63
 
61
- Thanks for installing br_api_fantasy-0.1.4.
64
+ Thanks for installing br_api_fantasy-0.1.5.
62
65
 
63
66
  Please make sure to add the gem to your rails project.
64
67
 
65
68
  Rails::Initializer.run do |config|
66
69
  ...
67
- config.gem 'br_api_fantasy', :version => 0.1.4
70
+ config.gem 'br_api_fantasy', :version => 0.1.5
68
71
  ...
69
72
  end
70
73
 
@@ -90,6 +93,12 @@ post_install_message: |
90
93
  api_uri: http://bleacherreport.com
91
94
  api_key: opensesame
92
95
 
96
+
97
+ IF YOU'RE UPGRADING THE GEM:
98
+
99
+ Remember to update your rails app to use the newer gem:
100
+
101
+ config.gem 'br_api_fantasy', :version => 0.1.5
93
102
 
94
103
  **************************************************
95
104
 
@@ -98,23 +107,27 @@ rdoc_options: []
98
107
  require_paths:
99
108
  - lib
100
109
  required_ruby_version: !ruby/object:Gem::Requirement
110
+ none: false
101
111
  requirements:
102
112
  - - ">="
103
113
  - !ruby/object:Gem::Version
114
+ hash: 3
104
115
  segments:
105
116
  - 0
106
117
  version: "0"
107
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
+ none: false
108
120
  requirements:
109
121
  - - ">="
110
122
  - !ruby/object:Gem::Version
123
+ hash: 3
111
124
  segments:
112
125
  - 0
113
126
  version: "0"
114
127
  requirements: []
115
128
 
116
129
  rubyforge_project:
117
- rubygems_version: 1.3.6
130
+ rubygems_version: 1.3.7
118
131
  signing_key:
119
132
  specification_version: 3
120
133
  summary: ""