Sha256: be5da1e9228906204f4de1485683a89cf0a404aeeed6f49aca7309be52624e62
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
require File.dirname(__FILE__) + '/bleacher_api/gems' BleacherApi::Gems.activate %w(httparty) require 'httparty' $:.unshift File.dirname(__FILE__) require 'bleacher_api/config' class BleacherApi include HTTParty class <<self def call(type, path, data=nil) base_uri BleacherApi::Config.url data, old_data = {}, data data[type == :get ? :query : :body] = old_data output = send(type, "/api/#{path}.json", data) if output.headers['status'].include?('200') output else false end end end class Authenticate class <<self def login(email, password) result = BleacherApi.call(:post, 'authenticate/login', { 'user[email]' => email, 'user[password]' => password }) if result BleacherApi::Config.token result['token'] end result end end end class Front class <<self def lead_articles(options) BleacherApi.call(:get, 'front/lead_articles', options) end end end class Geolocation class <<self def teams(options) BleacherApi.call(:get, 'geolocation/teams', options) end end end class Related class <<self def channel(options) BleacherApi.call(:get, 'related/channel', options) end def channel_next(options) BleacherApi.call(:get, 'related/channel_next', options) end end end class Stream class <<self def first(*tags) BleacherApi.call(:get, 'stream/first', { :tags => tags.join(',') }) end end end class User class <<self def user(token=BleacherApi::Config.token) BleacherApi.call(:get, 'user/user', { :token => token }) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bleacher_api-0.1.0 | lib/bleacher_api.rb |