You are here

public function Mollie_API_Resource_Base::create in Commerce Mollie 7

Create a resource with the remote API.

Parameters

array $data An array containing details on the resource. Fields supported depend on the resource created.:

Return value

object

Throws

Mollie_API_Exception

File

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

Class

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

Code

public function create(array $data = array()) {
  $encoded = json_encode($data);
  if (version_compare(phpversion(), "5.3.0", ">=")) {
    if (json_last_error() != JSON_ERROR_NONE) {
      throw new Mollie_API_Exception("Error encoding parameters into JSON: \"" . json_last_error() . "\".");
    }
  }
  else {
    if ($encoded === FALSE) {
      throw new Mollie_API_Exception("Error encoding parameters into JSON.");
    }
  }
  return $this
    ->rest_create($this
    ->getResourceName(), $encoded);
}