codephix /
asaas-sdk
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace CodePhix\Asaas; |
||||
| 4 | |||||
| 5 | |||||
| 6 | class Assinatura { |
||||
| 7 | // |
||||
| 8 | public $http; |
||||
| 9 | |||||
| 10 | public function __construct(Connection $connection) |
||||
| 11 | { |
||||
| 12 | $this->http = $connection; |
||||
| 13 | } |
||||
| 14 | |||||
| 15 | // Retorna a listagem de assinaturas |
||||
| 16 | public function getAll(array $filtros){ |
||||
| 17 | $filtro = ''; |
||||
| 18 | if(is_array($filtros)){ |
||||
| 19 | if($filtros){ |
||||
|
0 ignored issues
–
show
|
|||||
| 20 | foreach($filtros as $key => $f){ |
||||
| 21 | if(!empty($f)){ |
||||
| 22 | if($filtro){ |
||||
| 23 | $filtro .= '&'; |
||||
| 24 | } |
||||
| 25 | $filtro .= $key.'='.$f; |
||||
| 26 | } |
||||
| 27 | } |
||||
| 28 | $filtro = '?'.$filtro; |
||||
| 29 | } |
||||
| 30 | } |
||||
| 31 | return $this->http->get('/subscriptions'.$filtro); |
||||
| 32 | |||||
| 33 | } |
||||
| 34 | |||||
| 35 | // Retorna os dados da assinatura de acordo com o Id |
||||
| 36 | public function getById($id){ |
||||
| 37 | return $this->http->get('/subscriptions/'.$id); |
||||
| 38 | |||||
| 39 | } |
||||
| 40 | |||||
| 41 | // Retorna a listagem de assinaturas de acordo com o Id do Cliente |
||||
| 42 | public function getByCustomer($customer_id){ |
||||
| 43 | return $this->http->get('/subscriptions?customer='.$customer_id); |
||||
| 44 | } |
||||
| 45 | |||||
| 46 | |||||
| 47 | // Retorna a listagem de todos os pagamentos da assinatura |
||||
| 48 | public function getByPayment($subscription_id){ |
||||
| 49 | return $this->http->get('/subscriptions/'.$subscription_id.'/payments'); |
||||
| 50 | } |
||||
| 51 | |||||
| 52 | // Insere uma nova assinatura |
||||
| 53 | |||||
| 54 | public function create(array $dadosAssinatura){ |
||||
| 55 | return $this->http->post('/subscriptions', $dadosAssinatura); |
||||
| 56 | } |
||||
| 57 | |||||
| 58 | // Atualiza os dados da assinatura |
||||
| 59 | public function update($id, array $dadosAssinatura){ |
||||
| 60 | |||||
| 61 | return $this->http->post('/subscriptions/' . $id, $dadosAssinatura); |
||||
| 62 | } |
||||
| 63 | |||||
| 64 | public function getNotaFiscal($id, array $parametos){ |
||||
| 65 | $filtro = ''; |
||||
| 66 | if(is_array($parametos)){ |
||||
| 67 | if($parametos){ |
||||
|
0 ignored issues
–
show
The expression
$parametos of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||||
| 68 | foreach($parametos as $key => $f){ |
||||
| 69 | if(!empty($f)){ |
||||
| 70 | if($filtro){ |
||||
| 71 | $filtro .= '&'; |
||||
| 72 | } |
||||
| 73 | $filtro .= $key.'='.$f; |
||||
| 74 | } |
||||
| 75 | } |
||||
| 76 | $filtro = '?'.$filtro; |
||||
| 77 | } |
||||
| 78 | } |
||||
| 79 | return $this->http->get('/subscriptions/'.$id.$filtro); |
||||
| 80 | //https://www.asaas.com/api/v3/subscriptions/id/invoices?offset=&limit=&status= |
||||
| 81 | } |
||||
| 82 | |||||
| 83 | public function createNotaFiscal($subscription_id, $dadosAssinatura){ |
||||
|
0 ignored issues
–
show
The parameter
$subscription_id is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 84 | |||||
| 85 | return $this->http->post('/subscriptions', $dadosAssinatura); |
||||
| 86 | //https://www.asaas.com/api/v3/subscriptions/id/invoiceSettings |
||||
| 87 | } |
||||
| 88 | |||||
| 89 | // Atualiza Nota Fiscal da assinatura |
||||
| 90 | public function updateNotaFiscal($subscription_id, $dadosAssinatura){ |
||||
|
0 ignored issues
–
show
The parameter
$subscription_id is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 91 | |||||
| 92 | return $this->http->post('/subscriptions', $dadosAssinatura); |
||||
| 93 | //https://www.asaas.com/api/v3/subscriptions/id/invoiceSettings |
||||
| 94 | } |
||||
| 95 | |||||
| 96 | // Recuperar configuração para emissão de Notas Fiscais |
||||
| 97 | public function getConfigNotaFiscal($subscription_id){ |
||||
| 98 | return $this->http->get('/subscriptions/'.$subscription_id.'/invoiceSettings'); |
||||
| 99 | //https://www.asaas.com/api/v3/subscriptions/id/invoiceSettings |
||||
| 100 | } |
||||
| 101 | |||||
| 102 | // Deleta configuração para emissão de Notas Fiscais |
||||
| 103 | public function deleteConfigNotaFiscal($id){ |
||||
|
0 ignored issues
–
show
The parameter
$id is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 104 | return $this->http->get('/subscriptions/'.$subscription_id.'/invoiceSettings','','DELETE'); |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 105 | } |
||||
| 106 | |||||
| 107 | // Deleta uma assinatura |
||||
| 108 | public function delete($id){ |
||||
| 109 | return $this->http->get('/subscriptions/'.$id,'','DELETE'); |
||||
| 110 | } |
||||
| 111 | |||||
| 112 | } |
||||
| 113 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.