This repository has been archived by the owner on Feb 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'player-not-found' of git://github.com/dewski/swish into…
… dewski-player-not-found
- Loading branch information
Showing
3 changed files
with
26 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,30 +1,40 @@ | |||
module Dribbble | module Dribbble | ||
class Player < Base | class Player < Base | ||
def self.fetch(url, options = {}) | |||
user = get(url, options) | |||
|
|||
if user.response.is_a?(Net::HTTPNotFound) | |||
raise PlayerNotFound | |||
else | |||
user | |||
end | |||
end | |||
|
|||
def self.find(id) | def self.find(id) | ||
new(get("/players/#{id}")) | new(fetch("/players/#{id}")) | ||
end | end | ||
|
|
||
# Fetches this player's shots. | # Fetches this player's shots. | ||
# Options: :page, :per_page | # Options: :page, :per_page | ||
def shots(options={}) | def shots(options={}) | ||
paginated_list(self.class.get("/players/#{@id}/shots", :query => options)) | paginated_list(self.class.fetch("/players/#{@id}/shots", :query => options)) | ||
end | end | ||
|
|
||
# Fetches shots by players that this player follows. | # Fetches shots by players that this player follows. | ||
def shots_following(options={}) | def shots_following(options={}) | ||
paginated_list(self.class.get("/players/#{@id}/shots/following", :query => options)) | paginated_list(self.class.fetch("/players/#{@id}/shots/following", :query => options)) | ||
end | end | ||
|
|
||
def draftees(options={}) | def draftees(options={}) | ||
paginated_list(self.class.get("/players/#{@id}/draftees", :query => options)) | paginated_list(self.class.fetch("/players/#{@id}/draftees", :query => options)) | ||
end | end | ||
|
|
||
def followers(options={}) | def followers(options={}) | ||
paginated_list(self.class.get("/players/#{@id}/followers", :query => options)) | paginated_list(self.class.fetch("/players/#{@id}/followers", :query => options)) | ||
end | end | ||
|
|
||
def following(options={}) | def following(options={}) | ||
paginated_list(self.class.get("/players/#{@id}/following", :query => options)) | paginated_list(self.class.fetch("/players/#{@id}/following", :query => options)) | ||
end | end | ||
end | end | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters