Skip to content

Commit

Permalink
Wallet credit WS ops: reportInfo support
Browse files Browse the repository at this point in the history
  • Loading branch information
wvdhaute committed Jan 5, 2016
1 parent 0d16fec commit 4d78a06
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 5 deletions.
40 changes: 37 additions & 3 deletions linkid-sdk-php/LinkIDClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
require_once('LinkIDWalletReportTransaction.php');
require_once('LinkIDWalletInfoReport.php');
require_once('LinkIDWalletInfo.php');
require_once('LinkIDWalletReportInfo.php');

/*
* linkID WS client
Expand Down Expand Up @@ -893,12 +894,13 @@ public function getWalletInfoReport($language = "en", $walletIds)
* @param $amount double optional start balance
* @param $currency LinkIDCurrency optional start balance currency
* @param $walletCoin string optional wallet coin
* @param $reportInfo LinkIDWalletReportInfo optional wallet report info
*
* @throws Exception something went wrong enrolling
*
* @return string the ID of the linkID wallet that was created
*/
public function walletEnroll($userId, $walletOrganizationId, $amount, $currency, $walletCoin)
public function walletEnroll($userId, $walletOrganizationId, $amount, $currency, $walletCoin, $reportInfo)
{

$requestParams = array(
Expand All @@ -909,6 +911,16 @@ public function walletEnroll($userId, $walletOrganizationId, $amount, $currency,
'walletCoin' => $walletCoin
);

if (null != $reportInfo) {
$requestParams->reportInfo = new stdClass();
if (null != $reportInfo->reference) {
$requestParams->reportInfo->reference = $reportInfo->reference;
}
if (null != $reportInfo->description) {
$requestParams->reportInfo->description = $reportInfo->description;
}
}

/** @noinspection PhpUndefinedMethodInspection */
$response = $this->client->walletEnroll($requestParams);

Expand Down Expand Up @@ -950,10 +962,11 @@ public function walletGetInfo($userId, $walletOrganizationId)
* @param int $amount double amount to add
* @param LinkIDCurrency $currency currency of amount to add
* @param string $walletCoin string optional wallet coin
* @param $reportInfo LinkIDWalletReportInfo optional wallet report info
*
* @throws Exception something went wrong
*/
public function walletAddCredit($userId, $walletId, $amount, $currency, $walletCoin)
public function walletAddCredit($userId, $walletId, $amount, $currency, $walletCoin, $reportInfo)
{

$requestParams = array(
Expand All @@ -964,6 +977,16 @@ public function walletAddCredit($userId, $walletId, $amount, $currency, $walletC
'walletCoin' => $walletCoin
);

if (null != $reportInfo) {
$requestParams->reportInfo = new stdClass();
if (null != $reportInfo->reference) {
$requestParams->reportInfo->reference = $reportInfo->reference;
}
if (null != $reportInfo->description) {
$requestParams->reportInfo->description = $reportInfo->description;
}
}

/** @noinspection PhpUndefinedMethodInspection */
$response = $this->client->walletAddCredit($requestParams);

Expand All @@ -978,10 +1001,11 @@ public function walletAddCredit($userId, $walletId, $amount, $currency, $walletC
* @param int $amount double amount to remove
* @param LinkIDCurrency $currency currency of amount to remove
* @param string $walletCoin string optional wallet coin
* @param $reportInfo LinkIDWalletReportInfo optional wallet report info
*
* @throws Exception something went wrong
*/
public function walletRemoveCredit($userId, $walletId, $amount, $currency, $walletCoin)
public function walletRemoveCredit($userId, $walletId, $amount, $currency, $walletCoin, $reportInfo)
{

$requestParams = array(
Expand All @@ -992,6 +1016,16 @@ public function walletRemoveCredit($userId, $walletId, $amount, $currency, $wall
'walletCoin' => $walletCoin
);

if (null != $reportInfo) {
$requestParams->reportInfo = new stdClass();
if (null != $reportInfo->reference) {
$requestParams->reportInfo->reference = $reportInfo->reference;
}
if (null != $reportInfo->description) {
$requestParams->reportInfo->description = $reportInfo->description;
}
}

/** @noinspection PhpUndefinedMethodInspection */
$response = $this->client->walletRemoveCredit($requestParams);

Expand Down
27 changes: 27 additions & 0 deletions linkid-sdk-php/LinkIDWalletReportInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* Created by PhpStorm.
* User: wvdhaute
* Date: 05/01/16
* Time: 16:34
*/
class LinkIDWalletReportInfo
{

public $reference;
public $description;

/**
* LinkIDWalletReportInfo constructor.
* @param $reference
* @param $description
*/
public function __construct($reference, $description)
{
$this->reference = $reference;
$this->description = $description;
}


}
23 changes: 21 additions & 2 deletions linkid-sdk-php/LinkIDWalletReportTransaction.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<?php

require_once('LinkIDWalletTransaction.php');
require_once('LinkIDWalletReportType.php');
require_once('LinkIDWalletReportInfo.php');

class LinkIDWalletReportTransaction extends LinkIDWalletTransaction
{

public $userId;
public $applicationName;
public $applicationFriendly;
public $type;
public $reportInfo;

function __construct($walletId, $creationDate, $transactionId, $amount, $currency, $walletCoin, $userId, $applicationName)
function __construct($walletId, $creationDate, $transactionId, $amount, $currency, $walletCoin, $userId, $applicationName, $applicationFriendly, $type, $reportInfo)
{
$this->walletId = $walletId;
$this->creationDate = $creationDate;
Expand All @@ -18,12 +23,23 @@ function __construct($walletId, $creationDate, $transactionId, $amount, $currenc
$this->walletCoin = $walletCoin;
$this->userId = $userId;
$this->applicationName = $applicationName;
$this->applicationFriendly = $applicationFriendly;
$this->type = $type;
$this->reportInfo = $reportInfo;
}

}

function parseLinkIDWalletReportTransaction($xmlWalletReportTransaction)
{
$reportInfo = null;
if (isset($xmlWalletReportTransaction->reportInfo)) {
$reportInfo = new LinkIDWalletReportInfo(
isset($xmlWalletReportTransaction->reportInfo->reference) ? $xmlWalletReportTransaction->reportInfo->reference : null,
isset($xmlWalletReportTransaction->reportInfo->description) ? $xmlWalletReportTransaction->reportInfo->description : null
);
}

return new LinkIDWalletReportTransaction(
isset($xmlWalletReportTransaction->walletId) ? $xmlWalletReportTransaction->walletId : null,
isset($xmlWalletReportTransaction->creationDate) ? $xmlWalletReportTransaction->creationDate : null,
Expand All @@ -32,6 +48,9 @@ function parseLinkIDWalletReportTransaction($xmlWalletReportTransaction)
isset($xmlWalletReportTransaction->currency) ? parseLinkIDCurrency($xmlWalletReportTransaction->currency) : null,
isset($xmlWalletReportTransaction->walletCoin) ? $xmlWalletReportTransaction->walletCoin : null,
isset($xmlWalletReportTransaction->userId) ? $xmlWalletReportTransaction->userId : null,
isset($xmlWalletReportTransaction->applicationName) ? $xmlWalletReportTransaction->applicationName : null
isset($xmlWalletReportTransaction->applicationName) ? $xmlWalletReportTransaction->applicationName : null,
isset($xmlWalletReportTransaction->applicationFriendly) ? $xmlWalletReportTransaction->applicationFriendly : null,
isset($xmlWalletReportTransaction->type) ? parseLinkIDWalletReportType($xmlWalletReportTransaction->type) : null,
$reportInfo
);
}
42 changes: 42 additions & 0 deletions linkid-sdk-php/LinkIDWalletReportType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

abstract class LinkIDWalletReportType
{

const USER_TRANSACTION = 1;
const WALLET_ADD = 2;
const WALLET_REMOVE = 2;
const WALLET_UNREMOVE = 2;
const APPLICATION_ADD_CREDIT_INITIAL = 2;
const APPLICATION_ADD_CREDIT = 2;
const APPLICATION_REMOVE_CREDIT = 2;
const APPLICATION_REFUND = 2;

}

function parseLinkIDWalletReportType($type)
{

if (null == $type) return null;

if ($type == "USER_TRANSACTION") {
return LinkIDWalletReportType::USER_TRANSACTION;
} else if ($type == "WALLET_ADD") {
return LinkIDWalletReportType::WALLET_ADD;
} else if ($type == "WALLET_REMOVE") {
return LinkIDWalletReportType::WALLET_REMOVE;
} else if ($type == "WALLET_UNREMOVE") {
return LinkIDWalletReportType::WALLET_UNREMOVE;
} else if ($type == "APPLICATION_ADD_CREDIT_INITIAL") {
return LinkIDWalletReportType::APPLICATION_ADD_CREDIT_INITIAL;
} else if ($type == "APPLICATION_ADD_CREDIT") {
return LinkIDWalletReportType::APPLICATION_ADD_CREDIT;
} else if ($type == "APPLICATION_REMOVE_CREDIT") {
return LinkIDWalletReportType::APPLICATION_REMOVE_CREDIT;
} else if ($type == "APPLICATION_REFUND") {
return LinkIDWalletReportType::APPLICATION_REFUND;
}

throw new Exception("Unexpected wallet report type: " . $type);

}

0 comments on commit 4d78a06

Please sign in to comment.