Commit 404e0872 authored by BohdanDmytryshyn's avatar BohdanDmytryshyn
Browse files

Merge branch 'apiv4fix' into 'master'

ensure things don't break with apiv4

See merge request !41
parents 14d9fc64 0bf2d9b5
......@@ -31,6 +31,20 @@ class CRM_CiviMobileAPI_ApiWrapper_Contribution implements API_Wrapper {
return $result;
}
/**
* Check with API version is being called.
*
* @param $result - either apiv3 or apiv4 result
*
* @return Boolean - TRUE if the api result is from version 3.
*/
private static function isApiVersion3($result) {
if (is_array($result) && $result['version'] == 3) {
return TRUE;
}
return FALSE;
}
/**
* @param array $apiRequest
* @param array $result
......@@ -38,6 +52,10 @@ class CRM_CiviMobileAPI_ApiWrapper_Contribution implements API_Wrapper {
* @return mixed
*/
private function fillFinancialTypeName($apiRequest, $result) {
if (!self::isApiVersion3($result)) {
return $result;
}
if (empty($apiRequest['params']['return']) || stristr($apiRequest['params']['return'], 'financial_type_name') !== FALSE) {
if ($apiRequest['action'] == 'getsingle') {
$result['financial_type_name'] = $this->getFinancialTypeName($result);
......@@ -59,6 +77,10 @@ class CRM_CiviMobileAPI_ApiWrapper_Contribution implements API_Wrapper {
* @return mixed
*/
private function fillFormatTotalAmount($apiRequest, $result) {
if (!self::isApiVersion3($result)) {
return $result;
}
if (empty($apiRequest['params']['return']) || stristr($apiRequest['params']['return'], 'total_amount') !== FALSE) {
if ($apiRequest['action'] == 'getsingle') {
$result['format_total_amount'] = CRM_Utils_Money::format($result['total_amount'], $result['currency']);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment