From 4d78a06c98d03cea36be1efafb3f4c6ff4ed4a74 Mon Sep 17 00:00:00 2001 From: Wim Vandenhaute Date: Tue, 5 Jan 2016 17:00:49 +0100 Subject: [PATCH] Wallet credit WS ops: reportInfo support --- linkid-sdk-php/LinkIDClient.php | 40 ++++++++++++++++-- linkid-sdk-php/LinkIDWalletReportInfo.php | 27 ++++++++++++ .../LinkIDWalletReportTransaction.php | 23 +++++++++- linkid-sdk-php/LinkIDWalletReportType.php | 42 +++++++++++++++++++ 4 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 linkid-sdk-php/LinkIDWalletReportInfo.php create mode 100644 linkid-sdk-php/LinkIDWalletReportType.php diff --git a/linkid-sdk-php/LinkIDClient.php b/linkid-sdk-php/LinkIDClient.php index 4b7baea..21e79cc 100644 --- a/linkid-sdk-php/LinkIDClient.php +++ b/linkid-sdk-php/LinkIDClient.php @@ -24,6 +24,7 @@ require_once('LinkIDWalletReportTransaction.php'); require_once('LinkIDWalletInfoReport.php'); require_once('LinkIDWalletInfo.php'); +require_once('LinkIDWalletReportInfo.php'); /* * linkID WS client @@ -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( @@ -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); @@ -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( @@ -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); @@ -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( @@ -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); diff --git a/linkid-sdk-php/LinkIDWalletReportInfo.php b/linkid-sdk-php/LinkIDWalletReportInfo.php new file mode 100644 index 0000000..0ccd950 --- /dev/null +++ b/linkid-sdk-php/LinkIDWalletReportInfo.php @@ -0,0 +1,27 @@ +reference = $reference; + $this->description = $description; + } + + +} \ No newline at end of file diff --git a/linkid-sdk-php/LinkIDWalletReportTransaction.php b/linkid-sdk-php/LinkIDWalletReportTransaction.php index a9a2f88..1739456 100644 --- a/linkid-sdk-php/LinkIDWalletReportTransaction.php +++ b/linkid-sdk-php/LinkIDWalletReportTransaction.php @@ -1,14 +1,19 @@ walletId = $walletId; $this->creationDate = $creationDate; @@ -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, @@ -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 ); } \ No newline at end of file diff --git a/linkid-sdk-php/LinkIDWalletReportType.php b/linkid-sdk-php/LinkIDWalletReportType.php new file mode 100644 index 0000000..fa0acb0 --- /dev/null +++ b/linkid-sdk-php/LinkIDWalletReportType.php @@ -0,0 +1,42 @@ +