Created
May 17, 2020 15:02
-
-
Save vitorvargasdev/0968aaa154518bb8315184cf4b51d4d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Domains\Asaas; | |
use \App\Domains\Asaas\Connection; | |
class Cobranca | |
{ | |
private $connection; | |
public function __construct(Connection $connection) | |
{ | |
return $this->connection = $connection; | |
} | |
public function find($id) | |
{ | |
return $this->connection->get('/payments/'.$id); | |
} | |
public function filter($filter) | |
{ | |
return $this->connection->get('/payments?'.$filter); | |
} | |
public function create($data) | |
{ | |
$cobranca = $this->setCobranca($data); | |
return $this->connection->post('/payments', ['form_params' => $cobranca]); | |
} | |
public function update($id, $data) | |
{ | |
$cobranca = $this->setCobranca($data); | |
return $this->connection->post('/payments/'.$id, ['form_params' => $cobranca]); | |
} | |
public function setCobranca($cobranca) | |
{ | |
try { | |
$cobrancaArr = array( | |
'customer' => '', | |
'billingType' => '', | |
'value' => '', | |
'dueDate' => '', | |
'description' => '', | |
'externalReference' => '', | |
'installmentCount' => '', | |
'installmentValue' => '', | |
); | |
$cobrancaArr = array_merge($cobrancaArr, $cobranca); | |
return $cobrancaArr; | |
} catch (\Exception $e) { | |
return 'Erro ao criar cobrança. - ' . $e->getMessage(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment