Class: Gameball::Player
- Inherits:
-
Object
- Object
- Gameball::Player
- Defined in:
- lib/gameball/models/player.rb
Class Method Summary collapse
Class Method Details
.get_player_info(playerUniqueId) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gameball/models/player.rb', line 25 def self.get_player_info(playerUniqueId) body = { playerUniqueId: playerUniqueId } body["hash"] = Gameball::Utils::hashBody(playerUniqueId: playerUniqueId) res = Gameball::Utils::request("post", "/integrations/Player/Info", body) # Check for HTTP Success and throws error if not success unless res.kind_of? Net::HTTPSuccess if res.kind_of? Net::HTTPInternalServerError raise Gameball::GameballError.new("An Internal Server Error has occurred") else raise Gameball::GameballError.new(res.body) end else return res end end |
.initialize_player(body) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gameball/models/player.rb', line 3 def self.initialize_player(body) # Validating keys in incoming body Gameball::Utils.validate(body, ["playerAttributes", "playerUniqueId"], []) # .iso8601 Throws an exception if not invoked on a valid date object, so it is used to check if the dates are valid begin body[:playerAttributes][:joinDate] = body[:playerAttributes][:joinDate].iso8601 body[:playerAttributes][:dateOfBirth] = body[:playerAttributes][:dateOfBirth].iso8601 rescue NoMethodError => exception raise Gameball::GameballError.new("Invalid Date Format, Please use Time and Date objects") end # Check for HTTP Success and throws error if not success res = Gameball::Utils::request("post", "/integrations/player", body) unless res.kind_of? Net::HTTPSuccess if res.kind_of? Net::HTTPInternalServerError raise Gameball::GameballError.new("An Internal Server Error has occurred") else raise Gameball::GameballError.new(res.body) end else return res end end |