Issues (9)

src/Certificates.php (2 issues)

1
<?php
2
3
namespace WagnerMontanini\ApiNfeFasa;
4
5
6
/**
7
 * Class Certificates
8
 * @package WagnerMontanini\ApiNfeFasa
9
 */
10
class Certificates extends ApiNfeFasa
11
{
12
    /** @var array */
13
    private $headers;
0 ignored issues
show
The private property $headers is not used, and could be removed.
Loading history...
14
15
    /**
16
     * Certificates constructor.
17
     * @param string $apiUrl
18
     * @param string $token
19
     * @param string $company_id
20
     */
21
    public function __construct(string $apiUrl, string $token, string $company_id)
22
    {
23
        parent::__construct($apiUrl, $token);
24
        $this->company = $company_id;
0 ignored issues
show
Bug Best Practice introduced by
The property company does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
25
    }
26
27
    /**
28
     * @param array|null $headers
29
     * @return Certificates
30
     */
31
    public function index(?array $headers): Certificates
32
    {
33
        $this->request(
34
            "GET",
35
            "/companies/{$this->company}/certificates",
36
            null,
37
            $headers
38
        );
39
40
        return $this;
41
    }
42
43
    /**
44
     * @param array $files
45
     * @return Certificates
46
     */
47
    public function create(array $files): Certificates
48
    {
49
        $this->request(
50
            "POST",
51
            "/companies/{$this->company}/certificates",
52
            array(
53
                "files" => true,
54
                "certificate" => curl_file_create($files["certificate"],"application/x-pkcs12"),
55
                "password" => $files["password"]
56
            )
57
        );
58
59
        return $this;
60
    }
61
62
    /**
63
     * @param string $certificate_id
64
     * @return Certificates
65
     */
66
    public function read(string $certificate_id): Certificates
67
    {
68
        $this->request(
69
            "GET",
70
            "/companies/{$this->company}/certificates/{$certificate_id}"
71
        );
72
73
        return $this;
74
    }
75
76
    /**
77
     * @param string $certificate_id
78
     * @return Certificates
79
     */
80
    public function delete(string $certificate_id): Certificates
81
    {
82
        $this->request(
83
            "DELETE",
84
            "/companies/{$this->company}/certificates/{$certificate_id}"
85
        );
86
87
        return $this;
88
    }
89
}