Issues (33)

src/Notificacao.php (1 issue)

1
<?php
2
3
namespace CodePhix\Asaas;
4
5
6
class Notificacao {
7
    //
8
9
    public $http;
10
11
    public function __construct(Connection $connection)
12
    {
13
        $this->http = $connection;
14
    }
15
16
    // Retorna a listagem de notificações
17
    public function getAll(array $filtros){
18
        $filtro = '';
19
        if(is_array($filtros)){
0 ignored issues
show
The condition is_array($filtros) is always true.
Loading history...
20
            if($filtros){
21
                foreach($filtros as $key => $f){
22
                    if(!empty($f)){
23
                        if($filtro){
24
                            $filtro .= '&';
25
                        }
26
                        $filtro .= $key.'='.$f;
27
                    }
28
                }
29
                $filtro = '?'.$filtro;
30
            }
31
        }
32
        return $this->http->get('/notifications'.$filtro);
33
    }
34
    
35
    // Retorna os dados da notificação de acordo com o Id
36
    public function getById($id){
37
        return $this->http->get('/notifications/'.$id);
38
    }
39
    
40
    // Retorna a listagem de notificações de acordo com o Id do Cliente
41
    public function getByCustomer($customer_id){
42
        return $this->http->get('/customers/'.$customer_id.'/notifications');
43
    }
44
    
45
    // Insere uma nova notificação
46
    public function create(array $dadosNotificacao){
47
        return $this->http->post('/notifications', $dadosNotificacao);
48
    }
49
    
50
    // Atualiza os dados da notificação
51
    public function update($id, array $dadosNotificacao){
52
        return $this->http->post('/notifications', $dadosNotificacao);
53
    }
54
55
    // Deleta uma notificação
56
    public function delete($id){
57
        return $this->http->get('/notifications/'.$id,'','DELETE');
58
    }
59
60
}
61