Completed
Push — master ( d4f420...53bf60 )
by Sergey
04:05 queued 01:54
created

BoardSections   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A forBoard() 0 3 1
A create() 0 9 1
A delete() 0 3 1
A update() 0 8 1
1
<?php
2
3
namespace seregazhuk\PinterestBot\Api\Providers;
4
5
use seregazhuk\PinterestBot\Api\Providers\Core\Provider;
6
use seregazhuk\PinterestBot\Helpers\UrlBuilder;
7
8
class BoardSections extends Provider
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $loginRequiredFor = [
14
        'create',
15
        'edit',
16
        'delete',
17
    ];
18
19
    /**
20
     * @param string $boardId
21
     * @return array|bool
22
     */
23
    public function forBoard($boardId)
24
    {
25
        return $this->get(UrlBuilder::RESOURCE_GET_BOARD_SECTIONS, ['board_id' => $boardId]);
26
    }
27
28
    /**
29
     * @param string $boardId
30
     * @param string $title
31
     * @return bool
32
     */
33
    public function create($boardId, $title)
34
    {
35
        $requestOptions = [
36
            'board_id' => $boardId,
37
            'name' => $title,
38
            'initial_pins' => []
39
        ];
40
41
        return $this->post(UrlBuilder::RESOURCE_ADD_BOARD_SECTION, $requestOptions);
42
    }
43
44
    /**
45
     * @param string $sectionId
46
     * @param string $title
47
     * @return bool
48
     */
49
    public function update($sectionId, $title)
50
    {
51
        $requestOptions = [
52
            'section_id' => $sectionId,
53
            'name' => $title,
54
        ];
55
56
        return $this->post(UrlBuilder::RESOURCE_EDIT_BOARD_SECTION, $requestOptions);
57
    }
58
59
    /**
60
     * @param string $sectionId
61
     * @return bool
62
     */
63
    public function delete($sectionId)
64
    {
65
        return $this->post(UrlBuilder::RESOURCE_DELETE_BOARD_SECTION, ['section_id' => $sectionId]);
66
    }
67
}
68