/** * @param Mandate $mandate * @return Mandate */ public function cancelMandate(Mandate $mandate) { try { $body = '{"data":{}}'; $endpoint = self::ENDPOINT_MANDATE; $path = $mandate->getId() . "/actions/cancel"; $response = $this->client->post($this->makeUrl($endpoint, $path), $this->defaultHeaders + ["Content-Type" => "application/vnd.api+json"], $body)->send(); $responseArray = json_decode($response->getBody(true), true); $response = $responseArray[$endpoint]; $mandate->fromArray($response); return $mandate; } catch (BadResponseException $e) { throw ApiException::fromBadResponseException($e); } }
public function fromArray($data) { parent::fromArray($data); $this->setCreatedAt(new \DateTime($this->getCreatedAt())); }