Gameball Ruby SDK
The Gameball Ruby SDK provides convenient access to the Gameball API from applications written in the Ruby language.
Documentation
Please refer to the Gameball API docs.
Installation
You don't need this source code unless you want to modify the SDK. If you just want to use the SDK, just run:
gem install gameballSDK
Requirements
- Ruby 2.3+ and Gem 3.0+
Usage
The SDK needs to be configured with your account's API & Transaction keys available in your Gameball Dashboard
require 'gameball'
Gameball.api_key="api_key"
Gameball.api_version="v2.0" # Or latest
Gameball.transaction_key="transaction_key"
Example
Sending an Event
# Example 1
Gameball::Event.send_event({
events:{
place_order:{
total_amount:"100",
category:[
"electronics",
"cosmetics"
]
},
review:{}
},
playerUniqueId:"player123"
})
# Example 2
Gameball::Event.send_event({
events:{
reserve:{
rooms:2
}
},
playerUniqueId:" player123",
playerAttributes:{
displayName:" Jon Snow",
email:"[email protected]",
dateOfBirth:"1980-09-19T00:00:00.000Z",
joinDate:"2019-09-19T21:06:29.158Z"
}
})
# Example 3
Gameball::Event.send_event({
events:{
reserve:{
rooms:2
}
},
playerUniqueId:" player123",
playerAttributes:{
displayName:" Jon Snow",
email:"[email protected]",
dateOfBirth:"1980-09-19T00:00:00.000Z",
joinDate:"2019-09-19T21:06:29.158Z",
custom:{
location:"Miami",
graduationDate:"2018-07-04T21:06:29.158Z",
isMarried:false
}
}
})
Create a new Referral
Gameball::Referral.create_referral({
playerCode:"CODE11",
playerUniqueId:"player456"
}
)
# Example 2
Gameball::Referral.create_referral({
playerCode:"CODE11",
playerUniqueId:"player456",
playerAttributes:{
displayName:" Tyrion Lannister",
firstName:"Tyrion",
lastName:"Lannister",
email:"[email protected]",
gender:"M",
dateOfBirth:"1978-01-11T00:00:00.000Z",
joinDate:"2019-09-19T21:06:29.158Z",
custom:{
location:"Miami",
graduationDate:"2018-07-04T21:06:29.158Z",
isMarried:false
}
}
}
)
Reward Examples
# Example 1
Gameball::Transaction.reward_points({
playerUniqueId:"player123",
amount:99.98,
transactionId:"tra_123456789"
})
# Example 2
Gameball::Transaction.reward_points({
playerUniqueId:"player456",
amount:2500,
transactionId:"tra_123456789",
playerAttributes:{
displayName:" Tyrion Lannister",
firstName:"Tyrion",
lastName:"Lannister",
email:"[email protected]",
gender:"M",
dateOfBirth:"1978-01-11T00:00:00.000Z",
joinDate:"2019-09-19T21:06:29.158Z",
custom:{
location:"Miami",
graduationDate:"2018-07-04T21:06:29.158Z",
isMarried:false
}
}
}
)
Get Player Balance Example
Gameball::Transaction.get_player_balance("player456")
Hold Points Example
Gameball::Transaction.hold_points({
playerUniqueId:"player456",
amount:98.89
}
)
Redeem Example
Gameball::Transaction.redeem_points({
playerUniqueId:"player456",
amount:10,
transactionId:"tra_123456789",
holdReference:"2342452352435234",
})
Reverse Transaction Example
Gameball::Transaction.reverse_transaction({
playerUniqueId:"player456",
transactionId:"1234567890",
reversedTransactionId:"234567891"
}
)
Reverse Hold Example
Gameball::Transaction.reverse_hold({
playerUniqueId:" player456",
holdReference:"9245fe4a-d402-451c-b9ed-9c1a04247482"
}
)
Actions
# Example 1
Gameball::Action.send_action({
playerUniqueId: "your_player_unique_id",
events: {
review: {},
reserve: {
rooms: 2
}
}
})
# Example 2
Gameball::Action.send_action({
playerUniqueId: "your_player_unique_id",
events: {
review: {},
reserve: {
rooms: 2
}
},
pointsTransaction: {
rewardAmount: 2,
transactionId: "234567890"
}
})
# Example 3
Gameball::Action.send_action({
playerUniqueId: "your_player_unique_id",
events: {
review: {},
reserve: {
rooms: 2
}
},
pointsTransaction: {
rewardAmount: 2,
holdReference: "2342452352435234",
transactionId: "234567890"
}
Testing
To test run in the terminal bundle
Handling exceptions
Unsuccessful requests raise exceptions. The raised exception will reflect the sort of error that occurred with appropriate message and error code . Please refer to the Gameball API docs.
Contribution
The master branch of this repository contains the latest stable release of the SDK.
Contact
For usage questions\suggestions drop us an email at support[ at ]gameball.co. Please report any bugs as issues.