Actions

Actions are used to send player event, completing purchase reward and redeeming points in a single API call

Actions endpoint can be used to complete the below:

The endpoint is flexible and can be used to send single or all of the mentioned information to Gameball in the same request.

The following APIs use Hashing Function SHA1, Check how Hashing is done below.

post
Send Action

/integrations/action
Request
Response
Request
Headers
APIKey
required
string
Client API Key
Body Parameters
pointsTransaction
optional
object
pointsTransaction object is described in Object Reference section
events
optional
object
Collection of player events to be sent to Gameball.
playerAttributes
optional
object
An object containing all of the attributes of the player. Player object is described in Object Reference section
playerUniqueId
required
string
Player unique identifier used to uniquely identify the player on Gameball.
Response
200: OK
Success.
{
"redeemResponse": {
"playerUniqueId": "player123",
"playerAttributes": null,
"gameballTransactionId": 12345,
"transactionId":"tra_123456789",
"holdReference":"2342452352435234",
"transactionTime":"2019-09-19T16:14:09.895Z"
},
"rewardResponse": {
"playerUniqueId": "player123",
"playerAttributes": null,
"gameballTransactionId": 12346,
"amount": "50.0",
"transactionId": "tra_123456780",
"transactionTime":"2019-09-19T16:14:09.895Z"
},
"eventResponse": {}
}
400: Bad Request
JSON Body Invalid or missing required parameters. The response will include error description payload described in Errors section.
{
"code": 11,
"message": "BodyHashed Invalid"
}
401: Unauthorized
Invalid APIKey.
{}
402: Payment Required
Request failed. the response will include error description payload described in Errors section.
{
"code": 305,
"message": "Transaction with Id tra_123456789 has already been placed"
}
403: Forbidden
APIKey missing.
{}

Response Description

Response Parameters

Description

redeemResponse

Refer to Redeem

rewardResponse

Refer to Reward

eventResponse

Refer to Events

In case the player doesn't exist on Gameball before sending the Actions API call, the player will be created automatically on Gameball.

Usage Examples

Example One

The example shown is a request sent to Gameball to send events by adding the eventsparameter

cURL
Node.js
Ruby
.NET
PHP
Python
cURL
curl -X POST -H 'apiKey: 807b041b7d35425988e354e1f6bce186' -d '{
"playerUniqueId":"player123",
"events":{
"review":{},
"reserve":{
"rooms":2
}
}
}' -v -i 'https://api.gameball.co/api/v2.0/integrations/action'
Node.js
var apiKey = '807b041b7d35425988e354e1f6bce186'
var gameball = require('gameball')
var Gameball = new gameball(apikey)
Gameball.sendAction({
"playerUniqueId": "player123",
"events": {
"review":{},
"reserve": {
"rooms": 2
}
}
}, function(err, res) {
if (err) console.log(err)
else console.log(res)
})
Ruby
require 'gameball'
Gameball.api_key = "807b041b7d35425988e354e1f6bce186"
Gameball::Action.send_action({
playerUniqueId: "player123",
events: {
review: {},
reserve: {
rooms: 2
}
}
})
.NET
using Gameball;
using Gameball.Models;
var apiKey = "807b041b7d35425988e354e1f6bce186";
var Gameball = new Gameball(apiKey);
//Creating Request
var request = new ActionRequest() {
PlayerUniqueId = "player123"
};
//Reserve Event
Event Reserve = new Event() {
Name = "reserve"
};
Reserve.AddMetadata("rooms",2);
//Review Event
Event Review = new Event() {
Name = "review"
};
//Sending Request
request.AddEvent(Reserve);
request.AddEvent(Review);
var send_action_response = Gameball.SendAction(request);
PHP
require_once('vendor/autoload.php');
$apiKey = "807b041b7d35425988e354e1f6bce186";
$gameball = new \Gameball\GameballClient(apiKey);
$playerRequest =new \Gameball\Models\PlayerRequest();
$playerRequest->playerUniqueId='player123';
$eventRequest = \Gameball\Models\EventRequest::factory($playerRequest);
$eventRequest->addEvent('review');
$eventRequest->addEvent('reserve');
$eventRequest->addMetaData('reserve', 'rooms', 2);
$request = \Gameball\Models\ActionRequest::factory($playerRequest,$eventRequest);
$sendActionResponse= $gameball->action->sendAction($request);
Python
import gameball
apiKey = "807b041b7d35425988e354e1f6bce186"
gameball.api_key = apiKey
request = gameball.actionObject(player_unique_id = "player123")
request.add_event("reserve", {
"rooms": 2
})
request.add_event("review")
send_action_response = gameball.send_action(action_request)

Example Two

The example shown is a request sent to Gameball to send multiple actions, in the following example the endpoint is used to send events and a purchase reward by adding the rewardAmount in the pointsTransaction object

cURL
Node.js
Ruby
.NET
PHP
Python
cURL
curl -X POST -H 'apiKey: 807b041b7d35425988e354e1f6bce186' -d '{
"playerUniqueId": "player123",
"events": {
"review": {},
"reserve": {
"rooms": 2
}
},
"pointsTransaction": {
"rewardAmount": 99.98,
"transactionId": "tra_123456789",
"transactionTime":"2019-09-19T16:14:09.895Z",
"hash":"f3437e2919ab9f853c7ccde92f4f2b9a6def42db"
}
}' -v -i 'https://api.gameball.co/api/v2.0/integrations/action'
Node.js
var apiKey = '807b041b7d35425988e354e1f6bce186'
var transactionKey = '90byuedhb7y37d2bd22ybshsn82'
var gameball = require('gameball')
var Gameball = new gameball(apikey,transactionKey)
Gameball.sendAction({
"playerUniqueId": "player123",
"events": {
"review":{},
"reserve": {
"rooms": 2
}
},
"pointsTransaction": {
"rewardAmount": "99.98",
"transactionId": "tra_123456789"
}
}, function(err, res) {
if (err) console.log(err)
else console.log(res)
})
Ruby
require 'gameball'
Gameball.api_key = "807b041b7d35425988e354e1f6bce186"
Gameball.transaction_key = "90byuedhb7y37d2bd22ybshsn82"
Gameball::Action.send_action({
playerUniqueId: "player123",
events: {
review: {},
reserve: {
rooms: 2
}
},
pointsTransaction: {
rewardAmount: 99.98,
transactionId: "tra_123456789"
}
})
.NET
using Gameball;
using Gameball.Models;
var apiKey = "807b041b7d35425988e354e1f6bce186";
var transactionKey = "90byuedhb7y37d2bd22ybshsn82";
var Gameball = new Gameball(apiKey,transactionKey);
//Creating Request
var request = new ActionRequest() {
PlayerUniqueId = "player123",
PointsTransaction = new PointsTransaction()
{
RewardAmount = 99.98,
TransactionId = "tra_123456789"
}
};
//Reserve Event
Event Reserve = new Event() {
Name = "reserve"
};
Reserve.AddMetadata("rooms",2);
//Review Event
Event Review = new Event() {
Name = "review"
};
//Sending Request
request.AddEvent(Reserve);
request.AddEvent(Review);
var send_action_response = Gameball.SendAction(request);
PHP
require_once('vendor/autoload.php');
$apiKey = "807b041b7d35425988e354e1f6bce186";
$transactionKey = "90byuedhb7y37d2bd22ybshsn82";
$gameball = new \Gameball\GameballClient(apiKey,transactionKey);
$playerRequest =new \Gameball\Models\PlayerRequest();
$playerRequest->playerUniqueId='player123';
$eventRequest = \Gameball\Models\EventRequest::factory($playerRequest);
$eventRequest->addEvent('review');
$eventRequest->addEvent('reserve');
$eventRequest->addMetaData('reserve', 'rooms', 2);
$pointsTransaction = new \Gameball\Models\PointsTransaction();
$pointsTransaction->rewardAmount= 99.98;
$pointsTransaction->transactionId ='tra_123456789';
$request = \Gameball\Models\ActionRequest::factory($playerRequest,$eventRequest,$pointsTransaction);
$sendEventResponse= $gameball->action->sendAction($request);
Python
import gameball
apiKey = "807b041b7d35425988e354e1f6bce186"
transactionKey = "90byuedhb7y37d2bd22ybshsn82"
gameball.api_key = apiKey
gameball.transaction_key = transactionKey
request = gameball.actionObject(player_unique_id = "player123")
request.add_event("reserve", {
"rooms": 2
})
request.add_event("review")
request.add_points_transaction(transaction_id = "tra_123456789", reward_amount = 99.98)
send_action_response = gameball.send_action(action_request)

Example Three

The example shown is a request sent to Gameball to send 3 actions , the actions are sending events through the events parameter, sending a purchase reward by adding the rewardAmount in the pointsTransaction object and lastly redeeming points by adding the holdReference in the pointsTransaction object

cURL
Node.js
Ruby
.NET
PHP
Python
cURL
curl -X POST -H 'apiKey: 807b041b7d35425988e354e1f6bce186' -d '{
"playerUniqueId": "player123",
"events": {
"review": {},
"reserve": {
"rooms": 2
}
},
"pointsTransaction": {
"rewardAmount": 99.98,
"holdReference": "2342452352435234",
"transactionId": "tra_123456789",
"transactionTime":"2019-09-19T16:14:09.895Z",
"hash":"f3437e2919ab9f853c7ccde92f4f2b9a6def42db"
}
}' -v -i 'https://api.gameball.co/api/v2.0/integrations/action'
Node.js
var apiKey = '807b041b7d35425988e354e1f6bce186'
var transactionKey = '90byuedhb7y37d2bd22ybshsn82'
var gameball = require('gameball')
var Gameball = new gameball(apikey,transactionKey)
Gameball.sendAction({
"playerUniqueId": "player123",
"events": {
"review":{},
"reserve": {
"rooms": 2
}
},
"pointsTransaction": {
"rewardAmount": "99.98",
"holdReference": "2342452352435234",
"transactionId": "tra_123456789"
}
}, function(err, res) {
if (err) console.log(err)
else console.log(res)
})
Ruby
require 'gameball'
Gameball.api_key = "807b041b7d35425988e354e1f6bce186"
Gameball.transaction_key = "90byuedhb7y37d2bd22ybshsn82"
Gameball::Action.send_action({
playerUniqueId: "player123",
events: {
review: {},
reserve: {
rooms: 2
}
},
pointsTransaction: {
rewardAmount: 99.98,
holdReference: "2342452352435234",
transactionId: "tra_123456789"
}
})
.NET
using Gameball;
using Gameball.Models;
var apiKey = "807b041b7d35425988e354e1f6bce186";
var transactionKey = "90byuedhb7y37d2bd22ybshsn82";
var Gameball = new Gameball(apiKey,transactionKey);
//Creating Request
var request = new ActionRequest() {
PlayerUniqueId = "player123"
PointsTransaction = new PointsTransaction()
{
RewardAmount = 99.98,
TransactionId = "tra_123456789",
HoldReference = "2342452352435234"
}
};
//Reserve Event
Event Reserve = new Event() {
Name = "reserve"
};
Reserve.AddMetadata("rooms",2);
//Review Event
Event Review = new Event() {
Name = "review"
};
//Sending Request
request.AddEvent(Reserve);
request.AddEvent(Review);
var send_action_response = Gameball.SendAction(request);
PHP
require_once('vendor/autoload.php');
$apiKey = "807b041b7d35425988e354e1f6bce186";
$transactionKey = "90byuedhb7y37d2bd22ybshsn82";
$gameball = new \Gameball\GameballClient(apiKey,transactionKey);
$playerRequest =new \Gameball\Models\PlayerRequest();
$playerRequest->playerUniqueId='player123';
$eventRequest = \Gameball\Models\EventRequest::factory($playerRequest);
$eventRequest->addEvent('review');
$eventRequest->addEvent('reserve');
$eventRequest->addMetaData('reserve', 'rooms', 2);
$pointsTransaction = new \Gameball\Models\PointsTransaction();
$pointsTransaction->rewardAmount= 99.98;
$pointsTransaction->holdReference = '2342452352435234';
$pointsTransaction->transactionId ='tra_123456789';
$request = \Gameball\Models\ActionRequest::factory($playerRequest,$eventRequest,$pointsTransaction);
$sendEventResponse= $gameball->action->sendAction($request);
Python
import gameball
apiKey = "807b041b7d35425988e354e1f6bce186"
transactionKey = "90byuedhb7y37d2bd22ybshsn82"
gameball.api_key = apiKey
gameball.transaction_key = transactionKey
request = gameball.actionObject(player_unique_id = "player123")
request.add_event("reserve", {
"rooms": 2
})
request.add_event("review")
request.add_points_transaction(transaction_id = "tra_123456789", reward_amount = 99.98 , hold_reference="2342452352435234")
send_action_response = gameball.send_action(action_request)