Donations

The donation/get api request return all donations received for your customer account. Multiple options are available

  • Get a list of objects with all donations received
  • Get only the amount of all donations received
  • Filter results

Version

1.0.0

Request Parameters

Parameter Valid Input Default Required Description
customer_id unsigned integer - yes The customer_id the data should be requested for
token string - yes The token generated for this request. See token for more information
from string (datetime) null no Start date
to string (datetime) null no End date
sum boolean false no Set to true if you'd only like to receive the sum instead of all objects

Examples

For all examples we are using GuzzleHttpClient.

All donations for year 2015 for customer_id 1

<?php 

use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;

function getDonations() {
    try {
        $client = new Client();
        $response = $client->post('https://my.ngz.net/api/donation/get',
            array(
                'json' => array(
                    'customer_id' => 1,
                    'token' => 'C9FBFB090B8E6BBB1EED94D2259F94D98CDBCB57A710558DA0',
                    'from' => '2015-01-01 00:00:00',
                    'to' => '2015-12-31 23:59:59'
                )
            )
        );
    } catch (ClientException $e) {
        throw new Exception($e->getResponse()->getBody()->getContents(), $e->getResponse()->getStatusCode());
    }
    if(is_object($response) && $response->getStatusCode() == 200) {
        $reply = json_decode($response->getBody()->getContents());
    }
    return $reply;
}

Sample output

Array 
( 
    [0] => stdClass Object 
    ( 
        [id] => 133453 
        [amount] => 10.00 
        [date] => 2015-09-19 14:51:59 
        [donator] => Player1 
        [comment] => Comment1 
    ) 
    [1] => stdClass Object 
    ( 
        [id] => 127401 
        [amount] => 20.00 
        [date] => 2015-09-15 20:04:28 
        [donator] => Player2 
        [comment] => Comment2 
    ) 
)

Only sum of all donations from 15.09.2015 until now for customer_id 1

<?php 

use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;

function getDonations() {
    try {
        $client = new Client();
        $response = $client->post('https://my.ngz.net/api/donation/get',
            array(
                'json' => array(
                    'customer_id' => 1,
                    'token' => 'C9FBFB090B8E6BBB1EED94D2259F94D98CDBCB57A710558DA0',
                    'from' => '2015-09-15 00:00:00',
                    'sum' => true
                )
            )
        );
    } catch (ClientException $e) {
        throw new Exception($e->getResponse()->getBody()->getContents(), $e->getResponse()->getStatusCode());
    }
    if(is_object($response) && $response->getStatusCode() == 200) {
        $reply = json_decode($response->getBody()->getContents());
    }
    return $reply;
}

Sample output

Array 
( 
    [0] => 20 
)
Copyright 2016 by United Gameserver GmbH. Alle Rechte vorbehalten.V3.1.5.1337