public function testConvertToPagarMeObject() { $response = array("status"=> "paid", "object" => 'transaction', "refuse_reason" => null, "date_created" => "2013-09-26T03:19:36.000Z", "amount" => 1590, "installments" => 1, "id" => 1379, "card_holder_name" => "Jose da Silva", "card_last_digits" => "4448", "card_brand" => "visa", "postback_url" => null, "payment_method" => "credit_card", "customer" => array( 'object' => 'customer', "document_number" => "51472745531", 'address' => array( 'object' => "address", 'street' => 'asdas' ) )); $obj = PagarMe_Util::convertToPagarMeObject($response); $this->assertTrue($obj instanceof PagarMe_Transaction); $this->assertTrue($obj->customer instanceof PagarMe_Customer); $this->assertTrue($obj->customer->address instanceof PagarMe_Address); }
public function getTransactions() { $request = new PagarMe_Request(self::getUrl() . '/' . $this->id . '/transactions', 'GET'); $response = $request->run(); $this->transactions = PagarMe_Util::convertToPagarMeObject($response); return $this->transactions; }
public function refresh($response) { $removed = array_diff(array_keys($this->_attributes), array_keys($response)); foreach ($removed as $k) { unset($this->{$k}); } foreach ($response as $key => $value) { $this->_attributes[$key] = PagarMe_Util::convertToPagarMeObject($value); $this->_unsavedAttributes->remove($key); } return $this->_attributes; }