You are here

protected function Mollie_API_Resource_Base::performApiCall in Commerce Mollie 7

Perform an API call, and interpret the results and convert them to correct objects.

Parameters

$http_method:

$api_method:

null $http_body:

Return value

object

Throws

Mollie_API_Exception

4 calls to Mollie_API_Resource_Base::performApiCall()
Mollie_API_Resource_Base::rest_create in Mollie/API/Resource/Base.php
Mollie_API_Resource_Base::rest_list in Mollie/API/Resource/Base.php
Get a collection of objects from the REST API.
Mollie_API_Resource_Base::rest_read in Mollie/API/Resource/Base.php
Retrieves a single object from the REST API.
Mollie_API_Resource_Payments::refund in Mollie/API/Resource/Payments.php

File

Mollie/API/Resource/Base.php, line 205

Class

Mollie_API_Resource_Base
Copyright (c) 2013, Mollie B.V. All rights reserved.

Code

protected function performApiCall($http_method, $api_method, $http_body = NULL) {
  $body = $this->api
    ->performHttpCall($http_method, $api_method, $http_body);
  if (!($object = @json_decode($body))) {
    throw new Mollie_API_Exception("Unable to decode Mollie response: \"{$body}\".");
  }
  if (!empty($object->error)) {
    $exception = new Mollie_API_Exception("Error executing API call ({$object->error->type}): {$object->error->message}.");
    if (!empty($object->error->field)) {
      $exception
        ->setField($object->error->field);
    }
    throw $exception;
  }
  return $object;
}