ige_isb_api 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/README.md +19 -3
- data/ige_isb_api.gemspec +2 -2
- data/lib/ige_isb_api/callback.rb +122 -69
- data/lib/ige_isb_api/constants.rb +2 -1
- data/lib/ige_isb_api/request.rb +2 -1
- data/lib/ige_isb_api/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67aece4b49ff763e9136f0f46590cf9b120f38c1
|
4
|
+
data.tar.gz: 4f46335786f00997db20ebb3b1ba77e6254f7928
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4dbf5fcaf83c753927d1d79a632f984b87e5d003232d24610d01bf5dabea8f42b34d1708f348cc9197a5d5aaa260be45198dbf2228b89cc8e90c6b12b32e356
|
7
|
+
data.tar.gz: b78c664e78e4053067888e15848e143214dad6b192779efc1410dbad874db96695255fab75853f5faa4e62a726d0c3139839165bbebaca6b47d84951d942d2e5
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ige_isb_api (1.1.
|
4
|
+
ige_isb_api (1.1.3)
|
5
5
|
nokogiri
|
6
6
|
rfc-822
|
7
7
|
|
@@ -11,10 +11,10 @@ GEM
|
|
11
11
|
diff-lcs (1.2.5)
|
12
12
|
dotenv (0.9.0)
|
13
13
|
mini_portile (0.5.2)
|
14
|
-
nokogiri (1.6.
|
14
|
+
nokogiri (1.6.1)
|
15
15
|
mini_portile (~> 0.5.0)
|
16
|
-
rake (10.1.
|
17
|
-
rfc-822 (0.
|
16
|
+
rake (10.1.1)
|
17
|
+
rfc-822 (0.4.0)
|
18
18
|
rspec (2.14.1)
|
19
19
|
rspec-core (~> 2.14.0)
|
20
20
|
rspec-expectations (~> 2.14.0)
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
IGE's Wrapper for ISB APIs
|
2
2
|
==========================
|
3
3
|
|
4
|
-
Ruby Wrapper for ISB's `User API Version 2.
|
4
|
+
Ruby Wrapper for ISB's `User API Version 2.3`, as well as the documents
|
5
5
|
`Integrating ISB HTML5 Games_v1.3` and `Integrating ISB Flash Games_v1.4` (available from ISB), and ISB Bonus API version 1.5.
|
6
6
|
|
7
7
|
## Usage
|
@@ -143,14 +143,14 @@ url = IGE_ISB_API::Game.game_launcher_url player_id: 'player_id', currency: 'EUR
|
|
143
143
|
idrequest: 'somethingunique'
|
144
144
|
```
|
145
145
|
|
146
|
-
## Parsing Callback Data
|
146
|
+
## Parsing Game Session Callback Data
|
147
147
|
|
148
148
|
Once a player has finished their gameplay session, ISB will post session details back
|
149
149
|
to the casino server in the form of a JSON serialized blob of data.
|
150
150
|
You can easily parse that data into a standard Ruby Hash for your application to use as needed.
|
151
151
|
|
152
152
|
```Ruby
|
153
|
-
data = IGE_ISB_API::Callback.parse raw_data
|
153
|
+
data = IGE_ISB_API::Callback::GameplaySession.parse raw_data
|
154
154
|
player = data[:player] # player login as passed in via IGE_ISB_API.register
|
155
155
|
requestid = data[:requestid] # the request id passed in when the game is launched.
|
156
156
|
session_start = data[:session_start] # a Time object in UTC timezone
|
@@ -167,6 +167,22 @@ end
|
|
167
167
|
|
168
168
|
It will throw an `IGE_ISB_API::ValidationException` if the incoming data is bad.
|
169
169
|
|
170
|
+
## Parsing Withdrawal Callback Data
|
171
|
+
|
172
|
+
Once a player's pending withdrawal has been approved, ISB will post withdrawal details back
|
173
|
+
to the casino server in the form of a JSON serialized blob of data.
|
174
|
+
You can easily parse that data into a standard Ruby Hash for your application to use as needed.
|
175
|
+
|
176
|
+
```Ruby
|
177
|
+
data = IGE_ISB_API::Callback::Withdrawal.parse raw_data
|
178
|
+
player = data[:player] # player login as passed in via IGE_ISB_API.register
|
179
|
+
ref = data[:withdrawal_reference] # the withdrawal_reference passed in when the pending withdrawal was created.
|
180
|
+
approved = data[:approved] # true or false
|
181
|
+
operator = data[:operator] # the username of the person who approved the withdrawal
|
182
|
+
```
|
183
|
+
|
184
|
+
It will throw an `IGE_ISB_API::ValidationException` if the incoming data is bad.
|
185
|
+
|
170
186
|
## The Bonus API
|
171
187
|
|
172
188
|
```Ruby
|
data/ige_isb_api.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.version = IGE_ISB_API::VERSION
|
10
10
|
spec.authors = ["Dave Sag"]
|
11
11
|
spec.email = ["davesag@gmail.com"]
|
12
|
-
spec.description = "Implements all of the features of the ISB API version #{IGE_ISB_API::Constants::
|
13
|
-
spec.summary = "A Ruby Wrapper for the ISB
|
12
|
+
spec.description = "Implements all of the features of the ISB USER API version #{IGE_ISB_API::Constants::USER_API_VERSION}, and BONUS API version #{IGE_ISB_API::Constants::BONUS_API_VERSION}."
|
13
|
+
spec.summary = "A Ruby Wrapper for the ISB USER and BONUS APIs, and Game Launcher"
|
14
14
|
spec.homepage = "https://github.com/Interactive-Gaming-Entertainment/IGE_ISB_API"
|
15
15
|
spec.license = "MIT"
|
16
16
|
spec.date = Time.now.utc.strftime("%Y-%m-%d")
|
data/lib/ige_isb_api/callback.rb
CHANGED
@@ -3,81 +3,134 @@
|
|
3
3
|
require 'digest'
|
4
4
|
|
5
5
|
module IGE_ISB_API
|
6
|
-
|
6
|
+
module Callback
|
7
|
+
class GameplaySession
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
9
|
+
# {
|
10
|
+
# "player": String # player login as originally passed to ISB at .registration,
|
11
|
+
# "requestid":Integer, # same as we provided in the IDREQUEST field
|
12
|
+
# "token": String - # a SHA2 digest of our 'SECRETKEY' + 'IDREQUEST' which we will use to authenticate the incoming info.,
|
13
|
+
# "sesson-start":"2013/10/25.10:54:18",
|
14
|
+
# "sesson-end":"2013/10/25.12:32:51",
|
15
|
+
# "skin_ID": 2019
|
16
|
+
# "currency":"USD",
|
17
|
+
# "hostID":1,
|
18
|
+
# "actions":[
|
19
|
+
# {
|
20
|
+
# "bet":{
|
21
|
+
# "amount": 1.00
|
22
|
+
# },
|
23
|
+
# "bet":{
|
24
|
+
# "amount": 50.00
|
25
|
+
# },
|
26
|
+
# "win":{
|
27
|
+
# "amount": 80.00
|
28
|
+
# }
|
29
|
+
# }
|
30
|
+
# ]
|
31
|
+
# }
|
32
|
+
def self.parse(raw_data)
|
33
|
+
raise ValidationException, "No data to parse" if raw_data.nil? || raw_data.empty?
|
34
|
+
begin
|
35
|
+
data = JSON.parse(raw_data)
|
36
|
+
player = data['player']
|
37
|
+
IGE_ISB_API::Validation.test('player', player, 'username')
|
38
|
+
requestid = data['requestid'].to_i
|
39
|
+
IGE_ISB_API::Validation.test('requestid', requestid, 'int')
|
40
|
+
token = data['token']
|
41
|
+
expected = (Digest::SHA2.new << "#{IGE_ISB_API::Constants::SECRET_KEY}#{requestid}").to_s
|
42
|
+
raise ValidationException, "Invalid Token" unless token == expected
|
43
|
+
session_start = DateTime.strptime(data['session-start'], "%Y/%m/%d.%H:%M:%S").to_time.utc
|
44
|
+
session_end = DateTime.strptime(data['session-end'], "%Y/%m/%d.%H:%M:%S").to_time.utc
|
45
|
+
raise ValidationException, "session-end must be after session-start" unless session_start < session_end
|
46
|
+
skinid = data['skin_ID'].to_i
|
47
|
+
IGE_ISB_API::Validation.test('skin_ID', skinid, 'int')
|
48
|
+
currency = data['currency']
|
49
|
+
IGE_ISB_API::Validation.test('currency', currency, 'currency_code')
|
50
|
+
hostid = data['hostID'].to_i
|
51
|
+
actions = data['actions'].map do |act|
|
52
|
+
if act['bet']
|
53
|
+
{
|
54
|
+
action: :bet,
|
55
|
+
amount: act['bet']['amount'].to_f
|
56
|
+
}
|
57
|
+
elsif act['win']
|
58
|
+
{
|
59
|
+
action: :win,
|
60
|
+
amount: act['win']['amount'].to_f
|
61
|
+
}
|
62
|
+
else
|
63
|
+
raise ValidationException, "Invalid Action"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
return {
|
67
|
+
player: player,
|
68
|
+
requestid: requestid,
|
69
|
+
session_start: session_start,
|
70
|
+
session_end: session_end,
|
71
|
+
skinid: skinid,
|
72
|
+
currency: currency,
|
73
|
+
hostid: hostid,
|
74
|
+
actions: actions
|
75
|
+
}
|
76
|
+
rescue ArgumentError => ae
|
77
|
+
raise ValidationException, ae.message
|
78
|
+
rescue JSON::ParserError => jpe
|
79
|
+
raise ValidationException, "Invalid JSON format in supplied data: #{jpe.message}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
class Withdrawal
|
86
|
+
|
87
|
+
# Parses incoming Withdrawl data of the form:
|
88
|
+
# [
|
89
|
+
# {
|
90
|
+
# “player” : “<the player’s username>”,
|
91
|
+
# “withdrawal_reference” : “<the reference we supplied via UserAPI.withdraw>”,
|
92
|
+
# “approved” : true | false, # if false then the withdrawal was declined, not approved.
|
93
|
+
# “operator” : “<the username of the LGF Staff member who approved / declined the withdrawal via the Back Office>”,
|
94
|
+
# “checksum” : "<SHA256 of (player + withdrawal_reference + SECRET_KEY)>"
|
95
|
+
# }, …
|
96
|
+
# ]
|
97
|
+
def self.parse(raw_data)
|
98
|
+
raise ValidationException, "No data to parse" if raw_data.nil? || raw_data.empty?
|
99
|
+
begin
|
100
|
+
data = JSON.parse(raw_data)
|
101
|
+
result = data.map do |wd|
|
102
|
+
player = wd['player']
|
103
|
+
IGE_ISB_API::Validation.test('player', player, 'username')
|
104
|
+
withdrawal_reference = wd['withdrawal_reference'].to_i
|
105
|
+
IGE_ISB_API::Validation.test('withdrawal_reference', withdrawal_reference, 'int')
|
106
|
+
approved = wd['approved']
|
107
|
+
unless !!approved == approved
|
108
|
+
if approved.is_a?(String) && ( approved == 'true' || approved == 'false')
|
109
|
+
approved = (approved == 'true')
|
110
|
+
else
|
111
|
+
raise ArgumentError, "Expected 'approved' to be true or false"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
checksum = wd['checksum']
|
115
|
+
expected = (Digest::SHA256.new << "#{player}#{withdrawal_reference}#{IGE_ISB_API::Constants::SECRET_KEY}").to_s
|
116
|
+
raise ValidationException, "Invalid Checksum" unless checksum == expected
|
117
|
+
operator = wd['operator']
|
118
|
+
IGE_ISB_API::Validation.test('operator', operator, 'username')
|
119
|
+
|
57
120
|
{
|
58
|
-
|
59
|
-
|
121
|
+
player: player,
|
122
|
+
withdrawal_reference: withdrawal_reference,
|
123
|
+
approved: approved,
|
124
|
+
operator: operator
|
60
125
|
}
|
61
|
-
else
|
62
|
-
raise ValidationException, "Invalid Action"
|
63
126
|
end
|
127
|
+
return result
|
128
|
+
rescue ArgumentError => ae
|
129
|
+
raise ValidationException, ae.message
|
130
|
+
rescue JSON::ParserError => jpe
|
131
|
+
raise ValidationException, "Invalid JSON format in supplied data: #{jpe.message}"
|
64
132
|
end
|
65
|
-
return {
|
66
|
-
player: player,
|
67
|
-
requestid: requestid,
|
68
|
-
session_start: session_start,
|
69
|
-
session_end: session_end,
|
70
|
-
skinid: skinid,
|
71
|
-
currency: currency,
|
72
|
-
hostid: hostid,
|
73
|
-
actions: actions
|
74
|
-
}
|
75
|
-
rescue ArgumentError => ae
|
76
|
-
raise ValidationException, ae.message
|
77
|
-
rescue JSON::ParserError => jpe
|
78
|
-
raise ValidationException, "Invalid JSON format in supplied data: #{jpe.message}"
|
79
133
|
end
|
80
134
|
end
|
81
|
-
|
82
135
|
end
|
83
136
|
end
|
data/lib/ige_isb_api/request.rb
CHANGED
@@ -55,7 +55,8 @@ module IGE_ISB_API
|
|
55
55
|
'amount' => {:required => true, :type => 'int'},
|
56
56
|
'reference' => {:required => true, :type => 'string', :length => 32},
|
57
57
|
'cur' => {:required => true, :type => 'currency_code', :length => 3},
|
58
|
-
'wallet' => {:required => true, :type => 'string', :length => 32}
|
58
|
+
'wallet' => {:required => true, :type => 'string', :length => 32},
|
59
|
+
'creditcardnumber' => {:required => true, :type => 'string', :length => 32}
|
59
60
|
},
|
60
61
|
'cancel_withdrawal' => {
|
61
62
|
'withdrawalid' => {:required => true, :type => 'int'}
|
data/lib/ige_isb_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ige_isb_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Sag
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -94,7 +94,8 @@ dependencies:
|
|
94
94
|
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
description: Implements all of the features of the ISB API version 2.
|
97
|
+
description: Implements all of the features of the ISB USER API version 2.3, and BONUS
|
98
|
+
API version 1.5.
|
98
99
|
email:
|
99
100
|
- davesag@gmail.com
|
100
101
|
executables: []
|
@@ -139,5 +140,5 @@ rubyforge_project:
|
|
139
140
|
rubygems_version: 2.1.11
|
140
141
|
signing_key:
|
141
142
|
specification_version: 4
|
142
|
-
summary: A Ruby Wrapper for the ISB
|
143
|
+
summary: A Ruby Wrapper for the ISB USER and BONUS APIs, and Game Launcher
|
143
144
|
test_files: []
|