@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $dadosCliente = $this->setCliente($dadosCliente); |
| 74 | 74 | if(!empty($dadosCliente['error'])){ |
| 75 | 75 | return $dadosCliente; |
| 76 | - }else { |
|
| 76 | + } else { |
|
| 77 | 77 | return $this->http->post('/customers', $dadosCliente); |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $dadosCliente = $this->setCliente($dadosCliente); |
| 84 | 84 | if(!empty($dadosCliente['error'])){ |
| 85 | 85 | return $dadosCliente; |
| 86 | - }else { |
|
| 86 | + } else { |
|
| 87 | 87 | return $this->http->post('/customers/' . $id, $dadosCliente); |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -53,58 +53,58 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Retorna a listagem de clientes |
| 56 | - public function getAll($filtros = false){ |
|
| 56 | + public function getAll($filtros = false) { |
|
| 57 | 57 | $filtro = ''; |
| 58 | - if(is_array($filtros)){ |
|
| 59 | - if($filtros){ |
|
| 60 | - foreach($filtros as $key => $f){ |
|
| 61 | - if(!empty($f)){ |
|
| 62 | - if($filtro){ |
|
| 58 | + if (is_array($filtros)) { |
|
| 59 | + if ($filtros) { |
|
| 60 | + foreach ($filtros as $key => $f) { |
|
| 61 | + if (!empty($f)) { |
|
| 62 | + if ($filtro) { |
|
| 63 | 63 | $filtro .= '&'; |
| 64 | 64 | } |
| 65 | - $filtro .= $key.'='.$f; |
|
| 65 | + $filtro .= $key . '=' . $f; |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | - $filtro = '?'.$filtro; |
|
| 68 | + $filtro = '?' . $filtro; |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | - return $this->http->get('/customers'.$filtro); |
|
| 71 | + return $this->http->get('/customers' . $filtro); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Retorna os dados do cliente de acordo com o Id |
| 75 | - public function getById($id){ |
|
| 76 | - return $this->http->get('/customers/'.$id); |
|
| 75 | + public function getById($id) { |
|
| 76 | + return $this->http->get('/customers/' . $id); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // Retorna os dados do cliente de acordo com o Email |
| 80 | - public function getByEmail($email){ |
|
| 80 | + public function getByEmail($email) { |
|
| 81 | 81 | $option = 'limit=1&email=' . $email; |
| 82 | 82 | return $this->http->get('/customers', $option); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Insere um novo cliente |
| 86 | - public function create(array $dadosCliente){ |
|
| 86 | + public function create(array $dadosCliente) { |
|
| 87 | 87 | $dadosCliente = $this->setCliente($dadosCliente); |
| 88 | - if(!empty($dadosCliente['error'])){ |
|
| 88 | + if (!empty($dadosCliente['error'])) { |
|
| 89 | 89 | return $dadosCliente; |
| 90 | - }else { |
|
| 90 | + } else { |
|
| 91 | 91 | return $this->http->post('/customers', $dadosCliente); |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Atualiza os dados do cliente |
| 96 | - public function update($id, array $dadosCliente){ |
|
| 96 | + public function update($id, array $dadosCliente) { |
|
| 97 | 97 | $dadosCliente = $this->setCliente($dadosCliente); |
| 98 | - if(!empty($dadosCliente['error'])){ |
|
| 98 | + if (!empty($dadosCliente['error'])) { |
|
| 99 | 99 | return $dadosCliente; |
| 100 | - }else { |
|
| 100 | + } else { |
|
| 101 | 101 | return $this->http->post('/customers/' . $id, $dadosCliente); |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Deleta uma cliente |
| 106 | - public function delete($id){ |
|
| 107 | - return $this->http->get('/customers/'.$id,'','DELETE'); |
|
| 106 | + public function delete($id) { |
|
| 107 | + return $this->http->get('/customers/' . $id, '', 'DELETE'); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | public function setCliente($cliente) |
| 140 | 140 | { |
| 141 | 141 | try { |
| 142 | - if ( ! $this->cliente_valid($cliente) ) { |
|
| 142 | + if (!$this->cliente_valid($cliente)) { |
|
| 143 | 143 | return ClienteException::invalidClient(); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -175,6 +175,6 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public function cliente_valid($cliente) |
| 177 | 177 | { |
| 178 | - return ! ( (empty($cliente['name']) OR empty($cliente['cpfCnpj']) OR empty($cliente['email'])) ? 1 : '' ); |
|
| 178 | + return !((empty($cliente['name']) OR empty($cliente['cpfCnpj']) OR empty($cliente['email'])) ? 1 : ''); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | \ No newline at end of file |
@@ -14,77 +14,77 @@ discard block |
||
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | // Retorna a listagem de cobranças |
| 17 | - public function getAll(array $filtros){ |
|
| 17 | + public function getAll(array $filtros) { |
|
| 18 | 18 | $filtro = ''; |
| 19 | - if(is_array($filtros)){ |
|
| 20 | - if($filtros){ |
|
| 21 | - foreach($filtros as $key => $f){ |
|
| 22 | - if(!empty($f)){ |
|
| 23 | - if($filtro){ |
|
| 19 | + if (is_array($filtros)) { |
|
| 20 | + if ($filtros) { |
|
| 21 | + foreach ($filtros as $key => $f) { |
|
| 22 | + if (!empty($f)) { |
|
| 23 | + if ($filtro) { |
|
| 24 | 24 | $filtro .= '&'; |
| 25 | 25 | } |
| 26 | - $filtro .= $key.'='.$f; |
|
| 26 | + $filtro .= $key . '=' . $f; |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | - $filtro = '?'.$filtro; |
|
| 29 | + $filtro = '?' . $filtro; |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | - return $this->http->get('/payments'.$filtro); |
|
| 32 | + return $this->http->get('/payments' . $filtro); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // Retorna os dados da cobrança de acordo com o Id |
| 36 | - public function getById($id){ |
|
| 37 | - return $this->http->get('/payments/'.$id); |
|
| 36 | + public function getById($id) { |
|
| 37 | + return $this->http->get('/payments/' . $id); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // Retorna a listagem de cobranças de acordo com o Id do Cliente |
| 41 | - public function getByCustomer($customer_id){ |
|
| 42 | - return $this->http->get('/payments?customer='.$customer_id); |
|
| 41 | + public function getByCustomer($customer_id) { |
|
| 42 | + return $this->http->get('/payments?customer=' . $customer_id); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Retorna a listagem de cobranças de acordo com o Id da Assinaturas |
| 46 | - public function getBySubscription($subscription_id){ |
|
| 47 | - return $this->http->get('/payments?subscription='.$subscription_id); |
|
| 46 | + public function getBySubscription($subscription_id) { |
|
| 47 | + return $this->http->get('/payments?subscription=' . $subscription_id); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // Insere uma nova cobrança |
| 51 | - public function create(array $dadosCobranca){ |
|
| 51 | + public function create(array $dadosCobranca) { |
|
| 52 | 52 | $dadosCobranca = $this->setCobranca($dadosCobranca); |
| 53 | - if(!empty($dadosCobranca['error'])){ |
|
| 53 | + if (!empty($dadosCobranca['error'])) { |
|
| 54 | 54 | return $dadosCobranca; |
| 55 | - }else { |
|
| 55 | + } else { |
|
| 56 | 56 | return $this->http->post('/payments', $dadosCobranca); |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Insere uma nova cobrança parcelada |
| 61 | - public function parcelada(array $dadosCobranca){ |
|
| 61 | + public function parcelada(array $dadosCobranca) { |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Insere uma nova cobrança com split |
| 66 | 66 | /* Saldo dividido em multiplas contas do Asaas*/ |
| 67 | - public function split(array $dadosCobranca){ |
|
| 67 | + public function split(array $dadosCobranca) { |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // Atualiza os dados da cobrança |
| 72 | - public function update($id, array $dadosCobranca){ |
|
| 72 | + public function update($id, array $dadosCobranca) { |
|
| 73 | 73 | |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // Restaura cobrança removida |
| 77 | - public function restore($id){ |
|
| 77 | + public function restore($id) { |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // Estorna cobrança |
| 82 | - public function estorno($id){ |
|
| 82 | + public function estorno($id) { |
|
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // Confirmação em dinheiro |
| 87 | - public function confirmacao($id, $dados){ |
|
| 87 | + public function confirmacao($id, $dados) { |
|
| 88 | 88 | $data = array( |
| 89 | 89 | "paymentDate" => "2019-09-03", |
| 90 | 90 | "value" => 100.00, |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Deleta uma cobrança |
| 96 | - public function delete($id){ |
|
| 97 | - return $this->http->get('/payments/'.$id,'','DELETE'); |
|
| 96 | + public function delete($id) { |
|
| 97 | + return $this->http->get('/payments/' . $id, '', 'DELETE'); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | $dadosCobranca = $this->setCobranca($dadosCobranca); |
| 53 | 53 | if(!empty($dadosCobranca['error'])){ |
| 54 | 54 | return $dadosCobranca; |
| 55 | - }else { |
|
| 55 | + } else { |
|
| 56 | 56 | return $this->http->post('/payments', $dadosCobranca); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | public function __construct($token, $status) { |
| 13 | 13 | |
| 14 | - if($status == 'producao'){ |
|
| 14 | + if ($status == 'producao') { |
|
| 15 | 15 | $this->api_status = false; |
| 16 | - }elseif($status == 'homologacao'){ |
|
| 16 | + }elseif ($status == 'homologacao') { |
|
| 17 | 17 | $this->api_status = 1; |
| 18 | - }else{ |
|
| 18 | + } else { |
|
| 19 | 19 | die('Tipo de homologação invalida'); |
| 20 | 20 | } |
| 21 | 21 | $this->api_key = $token; |
@@ -26,21 +26,21 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - public function get($url, $option = false, $custom = false ) |
|
| 29 | + public function get($url, $option = false, $custom = false) |
|
| 30 | 30 | { |
| 31 | 31 | |
| 32 | 32 | $ch = curl_init(); |
| 33 | - curl_setopt($ch, CURLOPT_URL, $this->base_url .'.asaas.com/api/v3'. $url."?".$option); |
|
| 33 | + curl_setopt($ch, CURLOPT_URL, $this->base_url . '.asaas.com/api/v3' . $url . "?" . $option); |
|
| 34 | 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); |
| 35 | 35 | curl_setopt($ch, CURLOPT_HEADER, FALSE); |
| 36 | 36 | |
| 37 | - if(!empty($custom)){ |
|
| 37 | + if (!empty($custom)) { |
|
| 38 | 38 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $custom); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
| 42 | 42 | "Content-Type: application/json", |
| 43 | - "access_token: ".$this->api_key |
|
| 43 | + "access_token: " . $this->api_key |
|
| 44 | 44 | )); |
| 45 | 45 | |
| 46 | 46 | $response = curl_exec($ch); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $params = json_encode($params); |
| 58 | 58 | $ch = curl_init(); |
| 59 | 59 | |
| 60 | - curl_setopt($ch, CURLOPT_URL, $this->base_url .'.asaas.com/api/v3'. $url); |
|
| 60 | + curl_setopt($ch, CURLOPT_URL, $this->base_url . '.asaas.com/api/v3' . $url); |
|
| 61 | 61 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); |
| 62 | 62 | curl_setopt($ch, CURLOPT_HEADER, FALSE); |
| 63 | 63 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
| 69 | 69 | "Content-Type: application/json", |
| 70 | - "access_token: ".$this->api_key |
|
| 70 | + "access_token: " . $this->api_key |
|
| 71 | 71 | )); |
| 72 | 72 | |
| 73 | 73 | $response = curl_exec($ch); |
@@ -13,9 +13,9 @@ |
||
| 13 | 13 | |
| 14 | 14 | if($status == 'producao'){ |
| 15 | 15 | $this->api_status = false; |
| 16 | - }elseif($status == 'homologacao'){ |
|
| 16 | + } elseif($status == 'homologacao'){ |
|
| 17 | 17 | $this->api_status = 1; |
| 18 | - }else{ |
|
| 18 | + } else{ |
|
| 19 | 19 | die('Tipo de homologação invalida'); |
| 20 | 20 | } |
| 21 | 21 | $this->api_key = $token; |