IGE's Wrapper for ISB APIs
Ruby Wrapper for ISB's User API Version 2.3
, as well as the documents
Integrating ISB HTML5 Games_v1.3
and Integrating ISB Flash Games_v1.4
(available from ISB), and ISB Bonus API version 1.8.
Usage
- Add
gem 'ige_isb_api'
to yourGemfile
andrequire 'ige_isb_api
- Ensure the environment variables (see below) have been configured, and your IP has been whitelisted by the people at ISB.
- do something like this:
api = IGE_ISB_API::UserAPI.new username: 'player-username', password: "notwhattheplayerusesforyourcasino"
txid = 12345 # must be unique
response = api.register "some label", txid, email: "[email protected]",
name: "Surname",
firstname: "Firstname",
zip: "123456",
city: "Somewhere",
phone: "000000000",
dob: "2011-11-21",
country: "gb",
ip: '172.0.0.1'
response = api.login label, txid + 1
response = api.deposit label, txid + 2, wallet: 'test', amount: 5000, reference: 'test deposit'
response = api.withdrawal label, txid + 3, wallet: 'test', amount: 5000, reference: 'test withdrawal'
response = api.ban label, txid + 4
response = api.deactivate label, txid + 5
response = api.activate label, txid + 6
response = api.get_vip_points label, txid + 7
response = api.save_friend_email label, txid + 8, invitedname: "Bob Brown", invitedemail: '[email protected]'
response = api.limits label, txid + 9, limitationtype: "deposit", amount: 5000, frequency: 'weekly', until: "2015-11-21"
See the ISB User API docs (supplied by ISB) for details of the API commands and parameters.
Loading Games
You can use this API to parse the games list XML file and associated Game Info XML files.
games_list = IGE_ISB_API::Games.new
games_list.load_from_xml("http://someserver/some_games_list.xml", some_language_code) # language will default to 'en'
games_list.categories.each do |category|
category.games.each do |game|
game.load_info(game.game_info_url)
if errors.size == error_count
# do whatever you wish to do with the game data
end
end
end
Data Integrity
The data that comes from ISB can be inconsistent at times. The load_info
method will return an array of errors if there are any. Games that return errors should be skipped on load.
You can also call the game
's warnings
method to get a list of any specific non-fatal warnings about the data.
Expand upon the code above as follows to parse for errors and warnings.
games_list = IGE_ISB_API::Games.new
games_list.load_from_xml("http://someserver/some_games_list.xml", some_language_code) # language will default to 'en'
errors = []
warnings = []
games_list.categories.each do |category|
category.games.each do |game|
error_count = errors.size
errors = errors | game.load_info(game.game_info_url)
if errors.size == error_count
warnings = warnings | game.warnings
# do whatever else you wish to do with the game data
end
end
end
if !errors.empty?
errors.each {|e| puts "#{e[:game].name}: #{e[:message]}"}
end
if !warnings.empty?
warnings.each {|w| puts "#{w[:game].name}: #{w[:message]}"}
end
Your games loader code must loop through all of the langaues specified in IGE_ISB_API::Cosntants::LANGUAGES
and
load game data for each language. Different language game data will have the same identifier
and skin_id
so your games database will need to know to save language specific versions of each game's name and description.
Embedding a Flash game in 'fun' mode
embed = IGE_ISB_API::Game.embed_game_html host: g.get_info(:fun).host, currency: 'EUR',
colour: '#000000', name: g.name, game_swf_path: g.game_swf_path(:fun),
fun: true, coin_min: g.coin_min, casino: g.casino,
main_category: g.main_category, language: g.language, identifier: g.identifier,
game_swf_url: g.game_swf_url(:fun), wmode: g.wmode, gm_api: 0
Embedding a Flash game in 'real' mode
embed = IGE_ISB_API::Game.embed_game_html host: g.get_info(:real).host, player_id: 'player_id', currency: 'EUR',
colour: '#000000', name: g.name, game_swf_path: g.game_swf_path(:real),
fun: false, coin_min: g.coin_min, casino: g.casino,
main_category: g.main_category, language: g.language, identifier: g.identifier,
game_swf_url: g.game_swf_url(:real), wmode: g.wmode, idrequest: 'somethingunique', gm_api: 0
Using Google's swfobject Flash Embedder in 'fun' mode
embed = IGE_ISB_API::Game.embed_swfobject host: g.get_info(:fun).host, currency: 'EUR',
colour: '#000000', name: g.name, game_swf_path: g.game_swf_path(:fun),
fun: true, coin_min: g.coin_min, casino: g.casino,
main_category: g.main_category, language: g.language, identifier: g.identifier,
game_swf_url: g.game_swf_url(:fun), wmode: g.wmode, container: 'some-div-id', gm_api: 0
Using Google's swfobject Flash Embedder in 'real' mode
embed = IGE_ISB_API::Game.embed_swfobject host: g.get_info(:real).host, player_id: 'player_id', currency: 'EUR',
colour: '#000000', name: g.name, game_swf_path: g.game_swf_path(:real),
fun: false, coin_min: g.coin_min, casino: g.casino,
main_category: g.main_category, language: g.language, identifier: g.identifier,
game_swf_url: g.game_swf_url(:real), wmode: g.wmode, container: 'some-div-id',
idrequest: 'somethingunique', gm_api: 0
Launching an HTML5 game in 'fun' mode
url = IGE_ISB_API::Game.game_launcher_url currency: 'EUR', fun: true,
language: g.language, game_html5_url: g.game_html5_url(:fun)
Launching an HTML5 game in 'real' mode
url = IGE_ISB_API::Game.game_launcher_url player_id: 'player_id', currency: 'EUR', fun: false,
language: g.language, game_html5_url: g.game_html5_url(:real),
idrequest: 'somethingunique'
Parsing Game Session Callback Data
Once a player has finished their gameplay session, ISB will post session details back to the casino server in the form of a JSON serialized blob of data. You can easily parse that data into a standard Ruby Hash for your application to use as needed.
data = IGE_ISB_API::Callback::GameplaySession.parse raw_data
player = data[:player] # player login as passed in via IGE_ISB_API.register
requestid = data[:requestid] # the request id passed in when the game is launched.
session_start = data[:session_start] # a Time object in UTC timezone
session_start = data[:session_end] # a Time object in UTC timezone
actions = data[:actions] # an array of actions
skinid = data[:skinid] # the unique 'skin' number of the game.
currency = data[:currency] # an ISO code
hostid = data[:hostid] # an Integer (see notes on hostID in environnent variables below)
data[:actions].each do |act|
action = act[:action] # :bet or :win
amount = act[:amount] # float
end
It will throw an IGE_ISB_API::ValidationException
if the incoming data is bad.
Parsing Withdrawal Callback Data
Once a player's pending withdrawal has been approved, ISB will post withdrawal details back to the casino server in the form of a JSON serialized blob of data. You can easily parse that data into a standard Ruby Hash for your application to use as needed.
data = IGE_ISB_API::Callback::Withdrawal.parse raw_data
player = data[:player] # player login as passed in via IGE_ISB_API.register
ref = data[:withdrawal_reference] # the withdrawal_reference passed in when the pending withdrawal was created.
approved = data[:approved] # true or false
operator = data[:operator] # the username of the person who approved the withdrawal
It will throw an IGE_ISB_API::ValidationException
if the incoming data is bad.
The Bonus API
b = IGE_ISB_API::BonusAPI.new
response = b.get_trigger_bonus login: 'someplayer', trigger: 'deposit'
See the ISB Bonus API document (version 1.4) for appropriate options:
get_trigger_bonus
get_client_bonuses
count_client_bonuses
has_pending_offers
accept_bonus
decline_bonus
get_remaining_playthrough
remove_bonus_and_winnings_on_withdraw
issue_bonus
cancel_bonus
reset_bonus
update_active_balance_current_value
assign_certificate_to_player
bonus_vip_points
generate_certificate
generate_player_assigned_certificate
get_template_id_by_name
count_promo_codes
sum_bonuses
is_transaction_used
get_player_assigned_certificates
delete_player_assigned_certificate
delete_generated_certificate
certificate_exists
Building and Testing
Installing Nokogiri
This GEM uses Nokogiri to parse XML files. See these instructions for how best to install it on your local system.
Environment Variables
You must set the following environment variables (provided by ISB) for this code to work.
You can put them into a .env
file if you wish.
ISB_API_SERVER
ISB_BONUS_API_SERVER
ISB_FUN_URL
which must end in a/
ISB_LIVE_URL
which must end in a/
ISB_SECRET_KEY
ISB_BONUS_API_KEY
ISB_BONUS_SECRET_KEY
ISB_LICENSEE_ID
ISB_CASINO_ID
ISB_CALLBACK_ID
The ISB_CALLBACK_ID
is an integer that relates to a specific callback URL registered with ISB. For ISB's server to be able to send callbacks to your system you must register your URLs with them, and use appropriate integer as provided by them. This allows you to develop and test your system, including callbacks, without compromising your live production system.
To Test
To run the tests you must ensure that an appropriate environment variables have been configured
(in a .env
file, or otherwise) and that the IP number you are testing from has been whitelisted
by ISB's people. Then simply run:
bundle exec rake