/** * @depends testListMandates * @param Mandate $old */ public function testGetMandate($old) { $new = $this->getClient()->getMandate($old->getId()); $newArray = $new->toArray(); $oldArray = $old->toArray(); $this->assertEquals($newArray, $oldArray); }
public function fromArray($data) { parent::fromArray($data); $this->setCreatedAt(new \DateTime($this->getCreatedAt())); }
/** * @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); } }
/** * @depends testListMandates * @param Mandate $old */ public function testGetMandatePdf($old) { $mandate = $this->getClient()->getMandatePdf($old->getId()); $this->assertEquals("%PDF", substr($mandate, 0, 4)); }