Class: Scoreoid::Player
- Inherits:
-
Object
- Object
- Scoreoid::Player
- Defined in:
- lib/scoreoid/player.rb
Overview
Represents the game players.
Class Method Summary collapse
-
.count(params = {}) ⇒ Integer
Get the number of players for a game.
-
.create(params = {}) ⇒ Hash
Create a new player for a game.
-
.edit(params = {}) ⇒ Hash
Edit player information.
-
.update_field(params = {}) ⇒ Hash
Updates a players field.
Class Method Details
.count(params = {}) ⇒ Integer
Get the number of players for a game.
Examples:
Count the total number of players
Count the total number of players
puts "This game has #{Scoreoid::Player.count} total players."
Count new players
Count new players
count = Scoreoid::Player.count(start_date: '2012-11-01')
puts "There are #{count} new players since 2012-11-01."
Parameters:
-
params
(Hash)
(defaults to: {})
—
Parameters to include in the API request. Default parameters set with Scoreoid.configure will be included for you.
Options Hash (params):
-
:api_key
(String)
—
Your Scoreoid API key
-
:game_id
(String)
—
The game ID
-
:start_date
(Date, Time, String)
—
optional
-
:end_date
(Date, Time, String)
—
optional
Returns:
-
(Integer)
—
The number of players.
22 23 24 |
# File 'lib/scoreoid/player.rb', line 22 def self.count(params={}) Scoreoid::API.query_and_parse('countPlayers', params)['players'] end |
.create(params = {}) ⇒ Hash
Create a new player for a game.
Examples:
Create a player named Bob
Create a player named Bob
Scoreoid::Player.create(username: 'bob', first_name: 'Bob', last_name: 'Ross')
Parameters:
-
params
(Hash)
(defaults to: {})
—
Parameters to include in the API request. Default parameters set with Scoreoid.configure will be included for you.
Options Hash (params):
-
:api_key
(String)
—
Your Scoreoid API key
-
:game_id
(String)
—
The game ID
-
:username
(String)
—
The player’s username (required)
-
:password
(String)
—
Optional
-
:score
(String)
—
optional
-
:difficulty
(String)
—
optional
-
:unique_id
(String)
—
optional
-
:first_name
(String)
—
optional
-
:last_name
(String)
—
optional
-
:email
(String)
—
optional
-
:created
(String)
—
optional
-
:updated
(String)
—
optional
-
:bonus
(String)
—
optional
-
:achievements
(String)
—
optional
-
:best_score
(String)
—
optional
-
:gold
(String)
—
optional
-
:money
(String)
—
optional
-
:kills
(String)
—
optional
-
:lives
(String)
—
optional
-
:time_played
(String)
—
optional
-
:unlocked_levels
(String)
—
optional
-
:unlocked_items
(String)
—
optional
-
:inventory
(String)
—
optional
-
:last_level
(String)
—
optional
-
:current_level
(String)
—
optional
-
:current_time
(String)
—
optional
-
:current_bonus
(String)
—
optional
-
:current_kills
(String)
—
optional
-
:current_achievements
(String)
—
optional
-
:current_gold
(String)
—
optional
-
:current_unlocked_levels
(String)
—
optional
-
:current_unlocked_items
(String)
—
optional
-
:current_lives
(String)
—
optional
-
:xp
(String)
—
optional
-
:energy
(String)
—
optional
-
:boost
(String)
—
optional
-
:latitude
(String)
—
optional
-
:longitude
(String)
—
optional
-
:game_state
(String)
—
optional
-
:platform
(String)
—
optional
Returns:
-
(Hash)
—
The API response from Scoreoid (should contain a success message)
Raises:
-
(Scoreoid::APIError)
—
if the player could not be created
78 79 80 |
# File 'lib/scoreoid/player.rb', line 78 def self.create(params={}) Scoreoid::API.query_and_parse('createPlayer', params) end |
.edit(params = {}) ⇒ Hash
Edit player information.
Examples:
Update John’s first and last name
Update John’s first and last name
Scoreoid::Player.edit(username: 'john', first_name: 'John', last_name: 'Dough')
Parameters:
-
params
(Hash)
(defaults to: {})
—
Parameters to include in the API request. Default parameters set with Scoreoid.configure will be included for you.
Options Hash (params):
-
:api_key
(String)
—
Your Scoreoid API key
-
:game_id
(String)
—
The game ID
-
:username
(String)
—
The player’s username (required)
-
:password
(String)
—
Optional
-
:score
(String)
—
optional
-
:difficulty
(String)
—
optional
-
:unique_id
(String)
—
optional
-
:first_name
(String)
—
optional
-
:last_name
(String)
—
optional
-
:email
(String)
—
optional
-
:created
(String)
—
optional
-
:updated
(String)
—
optional
-
:bonus
(String)
—
optional
-
:achievements
(String)
—
optional
-
:best_score
(String)
—
optional
-
:gold
(String)
—
optional
-
:money
(String)
—
optional
-
:kills
(String)
—
optional
-
:lives
(String)
—
optional
-
:time_played
(String)
—
optional
-
:unlocked_levels
(String)
—
optional
-
:unlocked_items
(String)
—
optional
-
:inventory
(String)
—
optional
-
:last_level
(String)
—
optional
-
:current_level
(String)
—
optional
-
:current_time
(String)
—
optional
-
:current_bonus
(String)
—
optional
-
:current_kills
(String)
—
optional
-
:current_achievements
(String)
—
optional
-
:current_gold
(String)
—
optional
-
:current_unlocked_levels
(String)
—
optional
-
:current_unlocked_items
(String)
—
optional
-
:current_lives
(String)
—
optional
-
:xp
(String)
—
optional
-
:energy
(String)
—
optional
-
:boost
(String)
—
optional
-
:latitude
(String)
—
optional
-
:longitude
(String)
—
optional
-
:game_state
(String)
—
optional
-
:platform
(String)
—
optional
Returns:
-
(Hash)
—
The API response from Scoreoid (should contain a success message)
Raises:
-
(Scoreoid::APIError)
—
if the player could not be updated
134 135 136 |
# File 'lib/scoreoid/player.rb', line 134 def self.edit(params={}) Scoreoid::API.query_and_parse('editPlayer', params) end |
.update_field(params = {}) ⇒ Hash
Updates a players field.
Examples:
Update John’s e-mail address
Update John’s e-mail address
Scoreoid::Player.update_field(username: 'john', field: 'email', value: '[email protected]')
Parameters:
-
params
(Hash)
(defaults to: {})
—
Parameters to include in the API request. Default parameters set with Scoreoid.configure will be included for you.
Options Hash (params):
-
:api_key
(String)
—
Your Scoreoid API key
-
:game_id
(String)
—
The game ID
-
:username
(String)
—
The player’s username (required)
-
:field
(String)
—
The field name to update (see edit)
-
:value
(String)
—
The value to set
Returns:
-
(Hash)
—
The API response from Scoreoid (should contain a success message)
Raises:
-
(Scoreoid::APIError)
—
if the field could not be updated
155 156 157 |
# File 'lib/scoreoid/player.rb', line 155 def self.update_field(params={}) Scoreoid::API.query_and_parse('updatePlayerField', params) end |