Class: Clashinator::Location
Overview
This class represents the location model
Constant Summary
Constants inherited from Base
Base::CLASS_MAP, Base::OBJECT_MAP
Class Method Summary collapse
- .list_locations(http, options = {}) ⇒ Object
- .location_clan_rankings(http, location_id, options = {}) ⇒ Object
- .location_info(http, location_id) ⇒ Object
- .location_player_rankings(http, location_id, options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Location
constructor
A new instance of Location.
Methods inherited from Base
prepare_options, #verify_array_of_classes, #verify_hash_that_are_objects
Methods included from Camelizable
Methods included from Underscorable
Constructor Details
#initialize(attrs) ⇒ Location
Returns a new instance of Location.
4 5 6 |
# File 'lib/clashinator/location.rb', line 4 def initialize(attrs) super(attrs) end |
Class Method Details
.list_locations(http, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/clashinator/location.rb', line 8 def self.list_locations(http, = {}) = () response = http.get('/v1/locations', ) parsed = JSON.parse(response.body) if response.success? return Clashinator::ArrayResource.new( Clashinator::Location, parsed['items'], parsed['paging'] ) end raise parsed['message'] unless response.success? end |
.location_clan_rankings(http, location_id, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/clashinator/location.rb', line 29 def self.location_clan_rankings(http, location_id, = {}) = () response = http.get("/v1/locations/#{location_id}/rankings/clans", ) parsed = JSON.parse(response.body) if response.success? return Clashinator::ArrayResource.new( Clashinator::ClanRanking, parsed['items'], parsed['paging'] ) end raise parsed['reason'] unless response.success? end |
.location_info(http, location_id) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/clashinator/location.rb', line 21 def self.location_info(http, location_id) response = http.get("/v1/locations/#{location_id}") parsed = JSON.parse(response.body) return new(parsed) if response.success? raise parsed['message'] unless response.success? end |
.location_player_rankings(http, location_id, options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/clashinator/location.rb', line 42 def self.location_player_rankings(http, location_id, = {}) response = http.get( "/v1/locations/#{location_id}/rankings/players", () ) parsed = JSON.parse(response.body) return Clashinator::ArrayResource.new( Clashinator::PlayerRanking, parsed['items'], parsed['paging'] ) if response.success? raise parsed['reason'] unless response.success? end |