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

BoardSections::edit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
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