Class: Br::Api::Fantasy
- Inherits:
-
Object
- Object
- Br::Api::Fantasy
- Includes:
- HTTParty
- Defined in:
- lib/br_api_fantasy.rb
Class Method Summary collapse
- .authenticate(token) ⇒ Object
- .parse_creds ⇒ Object
- .set_team(token, team_id) ⇒ Object
- .sig(token) ⇒ Object
Class Method Details
.authenticate(token) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/br_api_fantasy.rb', line 24 def self.authenticate(token) base_uri credentails['api_uri'] response = get '/api/fantasy/authenticate.json', :query => {:token => token, :sig => sig(token)} if response.is_a?(Hash) return response elsif response.is_a?(String) return { :response_status => 500, :response_details => "500 Error", :response_data => response } else raise "response is not a Hash or String #{response.class}" end end |
.parse_creds ⇒ Object
14 15 16 17 |
# File 'lib/br_api_fantasy.rb', line 14 def self.parse_creds path = File.(self.config_path) YAML.load(IO.read(path))[RAILS_ENV] end |
.set_team(token, team_id) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/br_api_fantasy.rb', line 40 def self.set_team(token, team_id) base_uri credentails['api_uri'] response = get '/api/fantasy/set_team.json', :query => {:token => token, :team_id => team_id, :sig => sig(token)} if response.is_a?(Hash) return response elsif response.is_a?(String) return { :response_status => 500, :response_details => "500 Error", :response_data => response } else raise "response is not a Hash or String #{response.class}" end end |
.sig(token) ⇒ Object
20 21 22 |
# File 'lib/br_api_fantasy.rb', line 20 def self.sig(token) Digest::SHA1.hexdigest("--#{credentails['api_key']}--#{token}--") end |