Folder::folder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace ViniciusRBezerra\Autentique;
4
5
class Folder extends Autentique
6
{
7
    public function __construct()
8
    {
9
        parent::__construct();
10
    }
11
12
    /**
13
     * @param string $name
14
     * @return $this
15
     */
16
    public function createFolder(string $name): Autentique
17
    {
18
        $this->data->query = 'mutation CreateFolderMutation($folder: FolderInput!) {  createFolder(folder: $folder) { id name type created_at}}';
19
        $this->data->variables = ["folder" => ["name" => $name]];
20
21
        $this->execute();
22
        return $this;
23
    }
24
25
    /**
26
     * @param string $folderId
27
     * @return object
28
     */
29
    public function folder(string $folderId): object
30
    {
31
        $this->data->query = "query { folder(id: \"{$folderId}\") { id name type created_at } }";
32
        $this->execute();
33
        return $this->callback();
34
    }
35
36
    /**
37
     * @param int|null $limit
38
     * @return object
39
     */
40
    public function folders(?int $limit = null): object
41
    {
42
        $limit = empty($limit) ? 60 : $limit;
43
        $this->data->query = "query { folders(limit: {$limit}, page: 1) { total data { id name type created_at } } }";
44
        $this->execute();
45
        return $this->callback();
46
    }
47
48
    /**
49
     * @param string $folderId
50
     * @return $this
51
     */
52
    public function deleteFolder(string $folderId): Autentique
53
    {
54
        $this->data->query = "mutation { deleteFolder(id: \"{$folderId}\") }";
55
        $this->execute();
56
        return $this;
57
    }
58
59
    public function documentsByFolder(string $folderId): object
60
    {
61
        $this->data->query = "query { documentsByFolder(folder_id: \"{$folderId}\", limit: 60, page: 1) { total data { id name created_at files { original signed } signatures { public_id name email action { name } viewed { created_at } signed { created_at } rejected { created_at } } } } }";
62
        $this->execute();
63
        return $this->callback();
64
    }
65
}