gameball 1.0.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +202 -132
- data/gameball.gemspec +1 -1
- data/lib/gameball/lang.rb +12 -0
- data/lib/gameball/models/configurations.rb +19 -0
- data/lib/gameball/models/event.rb +5 -1
- data/lib/gameball/models/leaderboard.rb +19 -0
- data/lib/gameball/models/notifications.rb +32 -0
- data/lib/gameball/models/order.rb +23 -0
- data/lib/gameball/models/player.rb +62 -4
- data/lib/gameball/models/transaction.rb +88 -11
- data/lib/gameball/utils/helper.rb +3 -0
- data/lib/gameball/utils/request.rb +16 -8
- data/lib/gameball/version.rb +1 -1
- data/lib/gameball.rb +5 -2
- metadata +13 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfd74e1b4babbc69fe5972ac45e485d71bb7c15bd92076ab91296b2537aa8b46
|
4
|
+
data.tar.gz: a26a1472bae3ad9bf15929edf6bdedcd993b89dc3e34827b28afe1ecc1869826
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc7d36cfb2f6813e7d03c87c480e79804d087739c6b19df694644487b98deb76ac984ec81e12bebb70caee0ea77d9e0af5fc117a90ed624d5335145697e14e12
|
7
|
+
data.tar.gz: 15ccd652bbd32fddf34322b55e46074eb8beca1b12fb527604c65bf50125f8ace4fd4e02bcc2137ecebfe0262f32685e02ce6c54b04e59a669a7f54ddfd835aa
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -28,10 +28,89 @@ require 'gameball'
|
|
28
28
|
|
29
29
|
Gameball.api_key="api_key"
|
30
30
|
Gameball.transaction_key="transaction_key"
|
31
|
+
# If using API Version 3.0
|
32
|
+
Gameball.api_version="v3.0
|
31
33
|
```
|
32
34
|
|
33
35
|
### Example
|
34
36
|
|
37
|
+
#### Create Player
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
# Example 1
|
41
|
+
Gameball::Player.initialize_player({
|
42
|
+
playerUniqueId:"player123",
|
43
|
+
mobile: "+1234567",
|
44
|
+
email: "jon.snow@example.com",
|
45
|
+
"playerAttributes":{
|
46
|
+
displayName:"Jon Snow",
|
47
|
+
firstName: "Jon",
|
48
|
+
lastName: "Snow",
|
49
|
+
mobile: "+1234567",
|
50
|
+
email:"jon.snow@example.com",
|
51
|
+
gender:"M",
|
52
|
+
dateOfBirth:"1980-09-19T00:00:00.000Z",
|
53
|
+
joinDate:"2019-09-19T21:06:29.158Z",
|
54
|
+
tags: "VIP,Platinum",
|
55
|
+
custom:{
|
56
|
+
location:"Miami",
|
57
|
+
graduationDate:"2018-07-04T21:06:29.158Z",
|
58
|
+
isMarried:false
|
59
|
+
}
|
60
|
+
}
|
61
|
+
})
|
62
|
+
# Example 2
|
63
|
+
Gameball::Player.initialize_player({
|
64
|
+
referrerCode:"CODE11",
|
65
|
+
playerUniqueId:"player456",
|
66
|
+
playerAttributes:{
|
67
|
+
displayName:" Tyrion Lannister",
|
68
|
+
firstName:"Tyrion",
|
69
|
+
lastName:"Lannister",
|
70
|
+
email:"tyrion@example.com",
|
71
|
+
gender:"M",
|
72
|
+
dateOfBirth:"1978-01-11T00:00:00.000Z",
|
73
|
+
joinDate:"2019-09-19T21:06:29.158Z",
|
74
|
+
custom:{
|
75
|
+
location:"Miami",
|
76
|
+
graduationDate:"2018-07-04T21:06:29.158Z",
|
77
|
+
isMarried:false
|
78
|
+
}
|
79
|
+
})
|
80
|
+
|
81
|
+
|
82
|
+
```
|
83
|
+
|
84
|
+
#### Retrieve Player
|
85
|
+
```ruby
|
86
|
+
Gameball::Player.get_player_info("player123")
|
87
|
+
|
88
|
+
```
|
89
|
+
|
90
|
+
#### Player Balance
|
91
|
+
```ruby
|
92
|
+
Gameball::Player.get_player_balance("player123")
|
93
|
+
|
94
|
+
```
|
95
|
+
|
96
|
+
#### Player's Progress
|
97
|
+
```ruby
|
98
|
+
Gameball::Player.get_player_progress("player123")
|
99
|
+
|
100
|
+
```
|
101
|
+
|
102
|
+
#### Attach Tags to Player
|
103
|
+
```ruby
|
104
|
+
Gameball::Player.attach_tags("player123","VIP,Platinum")
|
105
|
+
|
106
|
+
```
|
107
|
+
|
108
|
+
#### Detach Tags
|
109
|
+
```ruby
|
110
|
+
Gameball::Player.detach_tags("player123","VIP,Platinum")
|
111
|
+
|
112
|
+
```
|
113
|
+
|
35
114
|
#### Sending an Event
|
36
115
|
|
37
116
|
```ruby
|
@@ -56,104 +135,22 @@ Gameball::Event.send_event({
|
|
56
135
|
rooms:2
|
57
136
|
}
|
58
137
|
},
|
59
|
-
playerUniqueId:" player123"
|
60
|
-
|
61
|
-
displayName:" Jon Snow",
|
62
|
-
email:"jon.snow@example.com",
|
63
|
-
dateOfBirth:"1980-09-19T00:00:00.000Z",
|
64
|
-
joinDate:"2019-09-19T21:06:29.158Z"
|
65
|
-
}
|
66
|
-
})
|
67
|
-
# Example 3
|
68
|
-
Gameball::Event.send_event({
|
69
|
-
events:{
|
70
|
-
reserve:{
|
71
|
-
rooms:2
|
72
|
-
}
|
73
|
-
},
|
74
|
-
playerUniqueId:" player123",
|
75
|
-
playerAttributes:{
|
76
|
-
displayName:" Jon Snow",
|
77
|
-
email:"jon.snow@example.com",
|
78
|
-
dateOfBirth:"1980-09-19T00:00:00.000Z",
|
79
|
-
joinDate:"2019-09-19T21:06:29.158Z",
|
80
|
-
custom:{
|
81
|
-
location:"Miami",
|
82
|
-
graduationDate:"2018-07-04T21:06:29.158Z",
|
83
|
-
isMarried:false
|
84
|
-
}
|
85
|
-
}
|
138
|
+
playerUniqueId:" player123"
|
139
|
+
|
86
140
|
})
|
87
141
|
|
88
142
|
|
89
143
|
```
|
90
144
|
|
91
|
-
####
|
92
|
-
|
93
|
-
```ruby
|
94
|
-
Gameball::Referral.create_referral({
|
95
|
-
playerCode:"CODE11",
|
96
|
-
playerUniqueId:"player456"
|
97
|
-
}
|
98
|
-
)
|
99
|
-
# Example 2
|
100
|
-
Gameball::Referral.create_referral({
|
101
|
-
playerCode:"CODE11",
|
102
|
-
playerUniqueId:"player456",
|
103
|
-
playerAttributes:{
|
104
|
-
displayName:" Tyrion Lannister",
|
105
|
-
firstName:"Tyrion",
|
106
|
-
lastName:"Lannister",
|
107
|
-
email:"tyrion@example.com",
|
108
|
-
gender:"M",
|
109
|
-
dateOfBirth:"1978-01-11T00:00:00.000Z",
|
110
|
-
joinDate:"2019-09-19T21:06:29.158Z",
|
111
|
-
custom:{
|
112
|
-
location:"Miami",
|
113
|
-
graduationDate:"2018-07-04T21:06:29.158Z",
|
114
|
-
isMarried:false
|
115
|
-
}
|
116
|
-
}
|
117
|
-
}
|
118
|
-
)
|
119
|
-
```
|
120
|
-
|
121
|
-
#### Reward Examples
|
145
|
+
#### Cashback Examples
|
122
146
|
|
123
147
|
```ruby
|
124
148
|
# Example 1
|
125
|
-
Gameball::Transaction.
|
149
|
+
Gameball::Transaction.cashback({
|
126
150
|
playerUniqueId:"player123",
|
127
151
|
amount:99.98,
|
128
152
|
transactionId:"tra_123456789"
|
129
153
|
})
|
130
|
-
# Example 2
|
131
|
-
Gameball::Transaction.reward_points({
|
132
|
-
playerUniqueId:"player456",
|
133
|
-
amount:2500,
|
134
|
-
transactionId:"tra_123456789",
|
135
|
-
playerAttributes:{
|
136
|
-
displayName:" Tyrion Lannister",
|
137
|
-
firstName:"Tyrion",
|
138
|
-
lastName:"Lannister",
|
139
|
-
email:"tyrion@example.com",
|
140
|
-
gender:"M",
|
141
|
-
dateOfBirth:"1978-01-11T00:00:00.000Z",
|
142
|
-
joinDate:"2019-09-19T21:06:29.158Z",
|
143
|
-
custom:{
|
144
|
-
location:"Miami",
|
145
|
-
graduationDate:"2018-07-04T21:06:29.158Z",
|
146
|
-
isMarried:false
|
147
|
-
}
|
148
|
-
}
|
149
|
-
}
|
150
|
-
)
|
151
|
-
```
|
152
|
-
|
153
|
-
#### Get Player Balance Example
|
154
|
-
|
155
|
-
```ruby
|
156
|
-
Gameball::Transaction.get_player_balance("player456")
|
157
154
|
```
|
158
155
|
|
159
156
|
#### Hold Points Example
|
@@ -169,21 +166,29 @@ Gameball::Transaction.hold_points({
|
|
169
166
|
#### Redeem Example
|
170
167
|
|
171
168
|
```ruby
|
169
|
+
# Example 1
|
172
170
|
Gameball::Transaction.redeem_points({
|
173
171
|
playerUniqueId:"player456",
|
174
|
-
amount:10,
|
175
172
|
transactionId:"tra_123456789",
|
176
173
|
holdReference:"2342452352435234",
|
177
174
|
})
|
175
|
+
|
176
|
+
# Example 2
|
177
|
+
Gameball::Transaction.redeem_points({
|
178
|
+
playerUniqueId:"player456",
|
179
|
+
transactionId:"tra_123456789",
|
180
|
+
redeemedAmount:12,
|
181
|
+
})
|
178
182
|
```
|
179
183
|
|
180
184
|
#### Reverse Transaction Example
|
181
185
|
|
182
186
|
```ruby
|
183
|
-
Gameball::Transaction.
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
+
Gameball::Transaction.refund({
|
188
|
+
playerUniqueId:"player456",
|
189
|
+
transactionId:"1234567890",
|
190
|
+
reverseTransactionId:"234567891",
|
191
|
+
amount: nil
|
187
192
|
}
|
188
193
|
)
|
189
194
|
```
|
@@ -191,56 +196,121 @@ Gameball::Transaction.reverse_transaction({
|
|
191
196
|
#### Reverse Hold Example
|
192
197
|
|
193
198
|
```ruby
|
194
|
-
Gameball::Transaction.reverse_hold(
|
195
|
-
playerUniqueId:" player456",
|
196
|
-
holdReference:"9245fe4a-d402-451c-b9ed-9c1a04247482"
|
197
|
-
}
|
198
|
-
)
|
199
|
+
Gameball::Transaction.reverse_hold("9245fe4a-d402-451c-b9ed-9c1a04247482")
|
199
200
|
```
|
200
201
|
|
201
|
-
|
202
|
+
#### Manual Transaction Example
|
202
203
|
|
203
204
|
```ruby
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
205
|
+
Gameball::Transaction.manual_transaction({
|
206
|
+
playerUniqueId:"player123",
|
207
|
+
amount:99.98,
|
208
|
+
transactionId:"tra_123456789",
|
209
|
+
username: "admin_storename",
|
210
|
+
reason: "Thank You Gift"
|
211
|
+
})
|
212
|
+
```
|
213
|
+
|
214
|
+
#### List Transactions Example
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
Gameball::Transaction.list_transactions({
|
218
|
+
page:2,
|
219
|
+
limit:10
|
220
|
+
})
|
221
|
+
```
|
222
|
+
|
223
|
+
#### Order Examples
|
224
|
+
|
225
|
+
```ruby
|
226
|
+
Gameball::Order.place_order({
|
227
|
+
playerUniqueId:"player456",
|
228
|
+
orderId: "6253e03b",
|
229
|
+
totalPrice: "100",
|
230
|
+
totalPaid: "90",
|
231
|
+
totalDiscount: "0",
|
232
|
+
totalShipping: "0",
|
233
|
+
totalTax: "0",
|
234
|
+
lineItems:[
|
235
|
+
{
|
236
|
+
productId:"197765",
|
237
|
+
tag: ["VIP"],
|
238
|
+
category: [
|
239
|
+
"natural",
|
240
|
+
"cosmetics"
|
241
|
+
],
|
242
|
+
weight: "20",
|
243
|
+
vendor: "nike",
|
244
|
+
collection: ["14313", "4343"],
|
245
|
+
},
|
246
|
+
{
|
247
|
+
productId:"875511",
|
248
|
+
title: "XPS-15s",
|
249
|
+
category: [
|
250
|
+
"electronics"
|
251
|
+
],
|
252
|
+
vendor: "Dell"
|
253
|
+
}
|
254
|
+
],
|
255
|
+
discountCodes: [
|
256
|
+
"AU7X-8Q7L",
|
257
|
+
"BY3V-22GK"
|
258
|
+
],
|
259
|
+
extra: {
|
260
|
+
paymentMethod: "credit card",
|
261
|
+
billingAddress: "Alabama"
|
262
|
+
},
|
263
|
+
redeemedAmount: 20,
|
264
|
+
holdReference: nil,
|
265
|
+
guest: false
|
213
266
|
})
|
267
|
+
```
|
268
|
+
#### Leaderboard
|
269
|
+
|
270
|
+
```ruby
|
271
|
+
# Example 1
|
272
|
+
Gameball::Leaderboard.get_leaderboard()
|
273
|
+
|
214
274
|
# Example 2
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
275
|
+
|
276
|
+
Gameball::Leaderboard.get_leaderboard({limit: 5})
|
277
|
+
```
|
278
|
+
|
279
|
+
#### Get Player Notifications
|
280
|
+
|
281
|
+
```ruby
|
282
|
+
# Example 1
|
283
|
+
Gameball::Notifications.get_notifications("player123")
|
284
|
+
|
285
|
+
# Example 2
|
286
|
+
Gameball::Notifications.get_notifications("player123",{
|
287
|
+
page: 2,
|
288
|
+
limit: 10
|
227
289
|
})
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
290
|
+
|
291
|
+
```
|
292
|
+
|
293
|
+
#### Mark Player Notifications
|
294
|
+
|
295
|
+
```ruby
|
296
|
+
Gameball::Notifications.mark_notifications({notificationIds: ["123", "3441", "3245"]})
|
297
|
+
|
298
|
+
```
|
299
|
+
|
300
|
+
#### Configurations
|
301
|
+
|
302
|
+
```ruby
|
303
|
+
# Example 1
|
304
|
+
Gameball::Configurations.get_configurations()
|
305
|
+
|
306
|
+
# Example 2
|
307
|
+
Gameball::Configurations.get_configurations({lang: "en"})
|
308
|
+
|
242
309
|
```
|
243
310
|
|
311
|
+
|
312
|
+
|
313
|
+
|
244
314
|
### Testing
|
245
315
|
|
246
316
|
To test run in the terminal `bundle exec rspec spec`
|
data/gameball.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
# spec.metadata["allowed_push_host"] = "https://github.com/Alsouidan/alphasdk"
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = "
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/gameballers/gameball-ruby"
|
19
19
|
spec.metadata["changelog_uri"] = "http://mygemserver.com"
|
20
20
|
|
21
21
|
# Specify which files should be added to the gem when it is released.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Gameball
|
2
|
+
class Configurations
|
3
|
+
# include Gameball::Utils
|
4
|
+
def self.get_configurations(params={})
|
5
|
+
Gameball::Utils.validate(params, [], ["lang"])
|
6
|
+
res = Gameball::Utils::request("get", "/integrations/config",params:params)
|
7
|
+
unless res.kind_of? Net::HTTPSuccess
|
8
|
+
if res.kind_of? Net::HTTPInternalServerError
|
9
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
10
|
+
else
|
11
|
+
raise Gameball::GameballError.new(res.body)
|
12
|
+
end
|
13
|
+
else
|
14
|
+
return res
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -2,7 +2,11 @@ module Gameball
|
|
2
2
|
class Event
|
3
3
|
def self.sendEvent(eventBody)
|
4
4
|
# Validating keys in incoming body
|
5
|
-
Gameball
|
5
|
+
if(Gameball.api_version=="v3.0")
|
6
|
+
Gameball::Utils.validate(eventBody, ["events", "playerUniqueId"], ["mobile","email"])
|
7
|
+
else
|
8
|
+
Gameball::Utils.validate(eventBody, ["events", "playerUniqueId"], ["playerAttributes"])
|
9
|
+
end
|
6
10
|
res = Gameball::Utils::request("post", "/integrations/event", eventBody)
|
7
11
|
# Check for HTTP Success and throws error if not success
|
8
12
|
unless res.kind_of? Net::HTTPSuccess
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Gameball
|
2
|
+
class Leaderboard
|
3
|
+
# include Gameball::Utils
|
4
|
+
def self.get_leaderboard(params={})
|
5
|
+
Gameball::Utils.validate(params, [], ["limit","from","to","playerUniqueId","challengeId"])
|
6
|
+
res = Gameball::Utils::request("get", "/integrations/leaderboard",params:params)
|
7
|
+
unless res.kind_of? Net::HTTPSuccess
|
8
|
+
if res.kind_of? Net::HTTPInternalServerError
|
9
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
10
|
+
else
|
11
|
+
raise Gameball::GameballError.new(res.body)
|
12
|
+
end
|
13
|
+
else
|
14
|
+
return res
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Gameball
|
2
|
+
class Notifications
|
3
|
+
# include Gameball::Utils
|
4
|
+
def self.get_notifications(playerUniqueId,params={})
|
5
|
+
Gameball::Utils.validate(params, [], ["limit","page","isRead","lang"])
|
6
|
+
res = Gameball::Utils::request("get", "/integrations/notifications/#{playerUniqueId}",params:params)
|
7
|
+
unless res.kind_of? Net::HTTPSuccess
|
8
|
+
if res.kind_of? Net::HTTPInternalServerError
|
9
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
10
|
+
else
|
11
|
+
raise Gameball::GameballError.new(res.body)
|
12
|
+
end
|
13
|
+
else
|
14
|
+
return res
|
15
|
+
end
|
16
|
+
end
|
17
|
+
def self.mark_notifications(body)
|
18
|
+
Gameball::Utils.validate(body, ["notificationIds"], [])
|
19
|
+
res = Gameball::Utils::request("put", "/integrations/notifications",body)
|
20
|
+
unless res.kind_of? Net::HTTPSuccess
|
21
|
+
if res.kind_of? Net::HTTPInternalServerError
|
22
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
23
|
+
else
|
24
|
+
raise Gameball::GameballError.new(res.body)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
return res
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Gameball
|
2
|
+
class Order
|
3
|
+
def self.place_order(body)
|
4
|
+
# Validating keys in incoming body
|
5
|
+
Gameball::Utils.validate(body, ["playerUniqueId","orderId","totalPaid","totalPrice"],
|
6
|
+
["mobile","email","totalShipping","totalTax","totalDiscount","lineItems","discountCodes","extra","redeemedAmount","holdReference","guest",
|
7
|
+
"merchant"])
|
8
|
+
body[:orderDate] = Time.now.utc.iso8601
|
9
|
+
res = Gameball::Utils::request("post", "/Integrations/order", body)
|
10
|
+
# Check for HTTP Success and throws error if not success
|
11
|
+
unless res.kind_of? Net::HTTPSuccess
|
12
|
+
if res.kind_of? Net::HTTPInternalServerError
|
13
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
14
|
+
else
|
15
|
+
raise Gameball::GameballError.new(res.body)
|
16
|
+
end
|
17
|
+
else
|
18
|
+
return res
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -2,7 +2,7 @@ module Gameball
|
|
2
2
|
class Player
|
3
3
|
def self.initialize_player(body)
|
4
4
|
# Validating keys in incoming body
|
5
|
-
Gameball::Utils.validate(body, ["playerAttributes", "playerUniqueId"], [])
|
5
|
+
Gameball::Utils.validate(body, ["playerAttributes", "playerUniqueId"], ["mobile","email","referrerCode","levelOrder"])
|
6
6
|
# .iso8601 Throws an exception if not invoked on a valid date object, so it is used to check if the dates are valid
|
7
7
|
begin
|
8
8
|
body[:playerAttributes][:joinDate] = body[:playerAttributes][:joinDate].iso8601
|
@@ -23,9 +23,67 @@ module Gameball
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
def self.get_player_info(playerUniqueId)
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
if Gameball.api_version!="v3.0"
|
27
|
+
body = { playerUniqueId: playerUniqueId }
|
28
|
+
body["hash"] = Gameball::Utils::hashBody(playerUniqueId: playerUniqueId)
|
29
|
+
res = Gameball::Utils::request("post", "/integrations/Player/Info", body)
|
30
|
+
else
|
31
|
+
res=Gameball::Utils::request("get","/integrations/player/#{playerUniqueId}")
|
32
|
+
end
|
33
|
+
# Check for HTTP Success and throws error if not success
|
34
|
+
unless res.kind_of? Net::HTTPSuccess
|
35
|
+
if res.kind_of? Net::HTTPInternalServerError
|
36
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
37
|
+
else
|
38
|
+
raise Gameball::GameballError.new(res.body)
|
39
|
+
end
|
40
|
+
else
|
41
|
+
return res
|
42
|
+
end
|
43
|
+
end
|
44
|
+
def self.get_player_balance(playerUniqueId)
|
45
|
+
res=Gameball::Utils::request("get","/integrations/player/#{playerUniqueId}/balance")
|
46
|
+
# Check for HTTP Success and throws error if not success
|
47
|
+
unless res.kind_of? Net::HTTPSuccess
|
48
|
+
if res.kind_of? Net::HTTPInternalServerError
|
49
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
50
|
+
else
|
51
|
+
raise Gameball::GameballError.new(res.body)
|
52
|
+
end
|
53
|
+
else
|
54
|
+
return res
|
55
|
+
end
|
56
|
+
end
|
57
|
+
def self.get_player_progress(playerUniqueId)
|
58
|
+
res=Gameball::Utils::request("get","/integrations/player/#{playerUniqueId}/progress")
|
59
|
+
# Check for HTTP Success and throws error if not success
|
60
|
+
unless res.kind_of? Net::HTTPSuccess
|
61
|
+
if res.kind_of? Net::HTTPInternalServerError
|
62
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
63
|
+
else
|
64
|
+
raise Gameball::GameballError.new(res.body)
|
65
|
+
end
|
66
|
+
else
|
67
|
+
return res
|
68
|
+
end
|
69
|
+
end
|
70
|
+
def self.attach_tags(playerUniqueId,tags)
|
71
|
+
body={tags:tags}
|
72
|
+
res=Gameball::Utils::request("post","/integrations/player/#{playerUniqueId}/tags",body)
|
73
|
+
# Check for HTTP Success and throws error if not success
|
74
|
+
unless res.kind_of? Net::HTTPSuccess
|
75
|
+
if res.kind_of? Net::HTTPInternalServerError
|
76
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
77
|
+
else
|
78
|
+
raise Gameball::GameballError.new(res.body)
|
79
|
+
end
|
80
|
+
else
|
81
|
+
return res
|
82
|
+
end
|
83
|
+
end
|
84
|
+
def self.detach_tags(playerUniqueId,tags)
|
85
|
+
body={tags:tags}
|
86
|
+
res=Gameball::Utils::request("delete","/integrations/player/#{playerUniqueId}/tags",body)
|
29
87
|
# Check for HTTP Success and throws error if not success
|
30
88
|
unless res.kind_of? Net::HTTPSuccess
|
31
89
|
if res.kind_of? Net::HTTPInternalServerError
|
@@ -15,10 +15,14 @@ module Gameball
|
|
15
15
|
def self.hold_points(body)
|
16
16
|
# puts body
|
17
17
|
# check if attributes are available
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
if (Gameball.api_version!="v3.0")
|
19
|
+
Gameball::Utils.validate(body, ["playerUniqueId", "amount"], ["otp"])
|
20
|
+
body[:transactionTime] = Time.now.utc
|
21
|
+
body = Gameball::Utils::extractAttributesToHash(body)
|
22
|
+
else
|
23
|
+
Gameball::Utils.validate(body, ["playerUniqueId", "amount"], ["mobile","email"])
|
24
|
+
body[:transactionTime] = Time.now.utc.iso8601
|
25
|
+
end
|
22
26
|
res = Gameball::Utils::request("post", "/integrations/transaction/hold", body)
|
23
27
|
unless res.kind_of? Net::HTTPSuccess
|
24
28
|
if res.kind_of? Net::HTTPInternalServerError
|
@@ -32,9 +36,15 @@ module Gameball
|
|
32
36
|
end
|
33
37
|
def self.redeem_points(body)
|
34
38
|
# check if attributes are available
|
35
|
-
Gameball
|
36
|
-
|
37
|
-
|
39
|
+
if (Gameball.api_version!="v3.0")
|
40
|
+
Gameball::Utils.validate(body, ["holdReference", "playerUniqueId", "transactionId"], [])
|
41
|
+
body[:transactionTime] = Time.now.utc
|
42
|
+
body = Gameball::Utils::extractAttributesToHash(body)
|
43
|
+
else
|
44
|
+
Gameball::Utils.validate(body, ["playerUniqueId", "transactionId"],
|
45
|
+
["mobile","email","redeemedAmount","holdReference"])
|
46
|
+
body[:transactionTime] = Time.now.utc.iso8601
|
47
|
+
end
|
38
48
|
res = Gameball::Utils::request("post", "/integrations/transaction/redeem", body)
|
39
49
|
unless res.kind_of? Net::HTTPSuccess
|
40
50
|
if res.kind_of? Net::HTTPInternalServerError
|
@@ -49,7 +59,6 @@ module Gameball
|
|
49
59
|
def self.reverse_transaction(body)
|
50
60
|
Gameball::Utils.validate(body, ["reversedTransactionId", "playerUniqueId", "transactionId"], [])
|
51
61
|
body[:transactionTime] = Time.now.utc
|
52
|
-
|
53
62
|
body = Gameball::Utils::extractAttributesToHash(body)
|
54
63
|
res = Gameball::Utils::request("post", "/integrations/transaction/cancel", body)
|
55
64
|
unless res.kind_of? Net::HTTPSuccess
|
@@ -62,10 +71,24 @@ module Gameball
|
|
62
71
|
return res
|
63
72
|
end
|
64
73
|
end
|
74
|
+
def self.refund(body)
|
75
|
+
Gameball::Utils.validate(body, ["reverseTransactionId", "playerUniqueId", "transactionId"],
|
76
|
+
["mobile","email","amount"])
|
77
|
+
body[:transactionTime] = Time.now.utc.iso8601
|
78
|
+
res = Gameball::Utils::request("post", "/integrations/transaction/refund", body)
|
79
|
+
unless res.kind_of? Net::HTTPSuccess
|
80
|
+
if res.kind_of? Net::HTTPInternalServerError
|
81
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
82
|
+
else
|
83
|
+
raise Gameball::GameballError.new(res.body)
|
84
|
+
end
|
85
|
+
else
|
86
|
+
return res
|
87
|
+
end
|
88
|
+
end
|
65
89
|
def self.reward_points(body)
|
66
90
|
Gameball::Utils.validate(body, ["playerUniqueId", "amount", "transactionId"], ["playerAttributes"])
|
67
91
|
body[:transactionTime] = Time.now.utc
|
68
|
-
|
69
92
|
body = Gameball::Utils::extractAttributesToHash(body)
|
70
93
|
res = Gameball::Utils::request("post", "/integrations/transaction/reward", body)
|
71
94
|
unless res.kind_of? Net::HTTPSuccess
|
@@ -75,14 +98,68 @@ module Gameball
|
|
75
98
|
raise Gameball::GameballError.new(res.body)
|
76
99
|
end
|
77
100
|
else
|
78
|
-
return
|
101
|
+
return res
|
102
|
+
end
|
103
|
+
end
|
104
|
+
def self.cashback(body)
|
105
|
+
Gameball::Utils.validate(body, ["playerUniqueId", "amount", "transactionId"], ["mobile","email","merchant"])
|
106
|
+
body[:transactionTime] = Time.now.utc.iso8601
|
107
|
+
res = Gameball::Utils::request("post", "/integrations/transaction/cashback", body)
|
108
|
+
unless res.kind_of? Net::HTTPSuccess
|
109
|
+
if res.kind_of? Net::HTTPInternalServerError
|
110
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
111
|
+
else
|
112
|
+
raise Gameball::GameballError.new(res.body)
|
113
|
+
end
|
114
|
+
else
|
115
|
+
return res
|
116
|
+
end
|
117
|
+
end
|
118
|
+
def self.manual_transaction(body)
|
119
|
+
Gameball::Utils.validate(body, ["playerUniqueId", "username", "transactionId","reason"],
|
120
|
+
["mobile","email","amount","points"])
|
121
|
+
body[:transactionTime] = Time.now.utc.iso8601
|
122
|
+
res = Gameball::Utils::request("post", "/integrations/transaction/manual", body)
|
123
|
+
unless res.kind_of? Net::HTTPSuccess
|
124
|
+
if res.kind_of? Net::HTTPInternalServerError
|
125
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
126
|
+
else
|
127
|
+
raise Gameball::GameballError.new(res.body)
|
128
|
+
end
|
129
|
+
else
|
130
|
+
return res
|
131
|
+
end
|
132
|
+
end
|
133
|
+
def self.list_transactions(params={})
|
134
|
+
Gameball::Utils.validate(params, [], ["page","limit","direction","from","to","transactionId","status"])
|
135
|
+
res = Gameball::Utils::request("get", "/integrations/transaction/list",params:params)
|
136
|
+
unless res.kind_of? Net::HTTPSuccess
|
137
|
+
if res.kind_of? Net::HTTPInternalServerError
|
138
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
139
|
+
else
|
140
|
+
raise Gameball::GameballError.new(res.body)
|
141
|
+
end
|
142
|
+
else
|
143
|
+
return res
|
79
144
|
end
|
80
145
|
end
|
81
146
|
def self.reverse_hold(body)
|
82
147
|
# check if holdReference is in body else throw error
|
148
|
+
if(Gameball.api_version=="v3.0")
|
149
|
+
# If v3.0 holReference is sent instead of body in args
|
150
|
+
res = Gameball::Utils::request("delete", "/integrations/transaction/hold/#{body}")
|
151
|
+
unless res.kind_of? Net::HTTPSuccess
|
152
|
+
if res.kind_of? Net::HTTPInternalServerError
|
153
|
+
raise Gameball::GameballError.new("An Internal Server Error has occurred")
|
154
|
+
else
|
155
|
+
raise Gameball::GameballError.new(res.body)
|
156
|
+
end
|
157
|
+
else
|
158
|
+
return res
|
159
|
+
end
|
160
|
+
end
|
83
161
|
Gameball::Utils.validate(body, ["holdReference", "playerUniqueId"], [])
|
84
162
|
body[:transactionTime] = Time.now.utc
|
85
|
-
|
86
163
|
body = Gameball::Utils::extractAttributesToHash(body)
|
87
164
|
res = Gameball::Utils::request("post", "/integrations/transaction/hold", body)
|
88
165
|
unless res.kind_of? Net::HTTPSuccess
|
@@ -2,35 +2,42 @@ module Gameball
|
|
2
2
|
module Utils
|
3
3
|
extend self
|
4
4
|
|
5
|
-
def request(verb, path, body = {})
|
5
|
+
def request(verb, path, body = {},lang:"",params:{})
|
6
|
+
|
6
7
|
# check for api_version and key and throw error if not included
|
7
8
|
if !Gameball.api_key
|
8
9
|
raise Gameball::GameballError.new("Please provide the api_key before making a request, try Gameball::api_key='your_key'")
|
9
10
|
end
|
10
11
|
uri = URI(Gameball.api_base + "/api" + "/" + Gameball.api_version + path)
|
11
|
-
|
12
|
+
if params != {}
|
13
|
+
uri.query=URI.encode_www_form(params)
|
14
|
+
end
|
12
15
|
https = Net::HTTP.new(uri.host, uri.port)
|
13
16
|
https.max_retries = Gameball.max_retries
|
14
17
|
https.read_timeout = Gameball.read_timeout
|
15
18
|
https.keep_alive_timeout = Gameball.keep_alive_timeout
|
16
19
|
https.use_ssl = true
|
17
|
-
|
20
|
+
|
18
21
|
case verb.downcase
|
19
22
|
when "post"
|
20
|
-
req = Net::HTTP::Post.new(uri
|
23
|
+
req = Net::HTTP::Post.new(uri, initheader = { "Content-Type" => "application/json" })
|
21
24
|
when "get"
|
22
|
-
req = Net::HTTP::Get.new(uri
|
25
|
+
req = Net::HTTP::Get.new(uri, initheader = { "Content-Type" => "application/json" })
|
23
26
|
when "put"
|
24
|
-
req = Net::HTTP::Put.new(uri
|
27
|
+
req = Net::HTTP::Put.new(uri, initheader = { "Content-Type" => "application/json" })
|
25
28
|
when "delete"
|
26
|
-
req = Net::HTTP::Delete.new(uri
|
29
|
+
req = Net::HTTP::Delete.new(uri, initheader = { "Content-Type" => "application/json" })
|
27
30
|
else
|
28
31
|
raise Gameball::GameballException.new("Please provide a valid HTTP Verb") # will later throw an exception
|
29
32
|
end
|
30
33
|
if body != {}
|
31
34
|
req.body = body.to_json
|
32
35
|
end
|
36
|
+
if lang!=""
|
37
|
+
req["lang"]=lang
|
38
|
+
end
|
33
39
|
req["APIKey"] = Gameball.api_key
|
40
|
+
req["secretKey"]=Gameball.transaction_key
|
34
41
|
res = https.request(req)
|
35
42
|
return res
|
36
43
|
end
|
@@ -63,8 +70,9 @@ module Gameball
|
|
63
70
|
if body != {}
|
64
71
|
req.body = body.to_json
|
65
72
|
end
|
66
|
-
req["APIKey"] = Gameball.api_key
|
67
73
|
Thread.new do
|
74
|
+
req["APIKey"] = Gameball.api_key
|
75
|
+
req["secretKey"]=Gameball.transaction_key
|
68
76
|
res = https.request(req)
|
69
77
|
return res
|
70
78
|
end
|
data/lib/gameball/version.rb
CHANGED
data/lib/gameball.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# Requiring all dependencies needed
|
2
2
|
require "net/http"
|
3
|
-
require "net/http"
|
4
3
|
require "openssl"
|
5
4
|
require "uri"
|
6
5
|
require "Time"
|
@@ -16,6 +15,10 @@ require_relative "./gameball/models/transaction"
|
|
16
15
|
require_relative "./gameball/models/referral"
|
17
16
|
require_relative "./gameball/models/coupon"
|
18
17
|
require_relative "./gameball/models/action"
|
18
|
+
require_relative "./gameball/models/order"
|
19
|
+
require_relative "./gameball/models/leaderboard"
|
20
|
+
require_relative "./gameball/models/notifications"
|
21
|
+
require_relative "./gameball/models/configurations"
|
19
22
|
require_relative "./gameball/exceptions/gameballException"
|
20
23
|
|
21
24
|
module Gameball
|
@@ -26,7 +29,7 @@ module Gameball
|
|
26
29
|
@api_version = "v2.0"
|
27
30
|
class << self
|
28
31
|
attr_accessor :api_key
|
29
|
-
|
32
|
+
attr_accessor :api_version
|
30
33
|
attr_accessor :transaction_key
|
31
34
|
attr_accessor :read_timeout
|
32
35
|
attr_accessor :max_retries
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gameball
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alsouidan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
|
-
description:
|
41
|
+
description:
|
42
42
|
email:
|
43
43
|
- alsouidan@gmail.com
|
44
44
|
executables: []
|
@@ -61,9 +61,14 @@ files:
|
|
61
61
|
- gameball.gemspec
|
62
62
|
- lib/gameball.rb
|
63
63
|
- lib/gameball/exceptions/gameballException.rb
|
64
|
+
- lib/gameball/lang.rb
|
64
65
|
- lib/gameball/models/action.rb
|
66
|
+
- lib/gameball/models/configurations.rb
|
65
67
|
- lib/gameball/models/coupon.rb
|
66
68
|
- lib/gameball/models/event.rb
|
69
|
+
- lib/gameball/models/leaderboard.rb
|
70
|
+
- lib/gameball/models/notifications.rb
|
71
|
+
- lib/gameball/models/order.rb
|
67
72
|
- lib/gameball/models/player.rb
|
68
73
|
- lib/gameball/models/referral.rb
|
69
74
|
- lib/gameball/models/transaction.rb
|
@@ -76,9 +81,9 @@ licenses:
|
|
76
81
|
- MIT
|
77
82
|
metadata:
|
78
83
|
homepage_uri: https://www.gameball.co/
|
79
|
-
source_code_uri:
|
84
|
+
source_code_uri: https://github.com/gameballers/gameball-ruby
|
80
85
|
changelog_uri: http://mygemserver.com
|
81
|
-
post_install_message:
|
86
|
+
post_install_message:
|
82
87
|
rdoc_options: []
|
83
88
|
require_paths:
|
84
89
|
- lib
|
@@ -93,8 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
98
|
- !ruby/object:Gem::Version
|
94
99
|
version: '0'
|
95
100
|
requirements: []
|
96
|
-
rubygems_version: 3.
|
97
|
-
signing_key:
|
101
|
+
rubygems_version: 3.2.32
|
102
|
+
signing_key:
|
98
103
|
specification_version: 4
|
99
104
|
summary: Ruby SDK for Gameball's API
|
100
105
|
test_files: []
|