Class: Hyperscore::Client
- Inherits:
-
Object
- Object
- Hyperscore::Client
- Includes:
- Hyperclient
- Defined in:
- lib/hyperscore/client.rb
Instance Method Summary collapse
- #dashboard(username) ⇒ Object
- #games ⇒ Object
-
#initialize(url = 'http://cs-api.herokuapp.com/') ⇒ Client
constructor
A new instance of Client.
- #motd ⇒ Object
- #news ⇒ Object
- #profile(username) ⇒ Object
- #submissions ⇒ Object
- #user(username) ⇒ Object
Constructor Details
#initialize(url = 'http://cs-api.herokuapp.com/') ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 |
# File 'lib/hyperscore/client.rb', line 10 def initialize(url='http://cs-api.herokuapp.com/') @client = Hyperclient::EntryPoint.new url, { headers: { 'Accept-Encoding' => 'gzip,deflate' } } end |
Instance Method Details
#dashboard(username) ⇒ Object
43 44 45 |
# File 'lib/hyperscore/client.rb', line 43 def dashboard(username) get_user(username).links.dashboard.url end |
#games ⇒ Object
29 30 31 |
# File 'lib/hyperscore/client.rb', line 29 def games @client.links.games..games end |
#motd ⇒ Object
47 48 49 |
# File 'lib/hyperscore/client.rb', line 47 def motd @client.attributes['motd'] end |
#news ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/hyperscore/client.rb', line 16 def news @client.links.news..news.map do |news| Hyperscore::Coercions::News.new( news.get.merge({ :source => news.links.self.url, :site => news.links.alternate.url }) ) end end |
#profile(username) ⇒ Object
39 40 41 |
# File 'lib/hyperscore/client.rb', line 39 def profile(username) get_user(username).links.profile.url end |
#submissions ⇒ Object
25 26 27 |
# File 'lib/hyperscore/client.rb', line 25 def submissions @client.links.submissions..submissions end |
#user(username) ⇒ Object
33 34 35 36 37 |
# File 'lib/hyperscore/client.rb', line 33 def user(username) user = @client.links.users.links.search.({username: username}).get user.key?('error') ? nil : user end |