Completed
Pull Request — master (#262)
by Sergey
02:36
created

Topics   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 62
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A info() 0 4 1
A pins() 0 9 1
A explore() 0 9 1
1
<?php
2
3
namespace seregazhuk\PinterestBot\Api\Providers;
4
5
use seregazhuk\PinterestBot\Helpers\Pagination;
6
use seregazhuk\PinterestBot\Helpers\UrlBuilder;
7
use seregazhuk\PinterestBot\Api\Traits\Followable;
8
use seregazhuk\PinterestBot\Api\Traits\HasRelatedTopics;
9
use seregazhuk\PinterestBot\Api\Providers\Core\EntityProvider;
10
11
class Topics extends EntityProvider
12
{
13
    use Followable, HasRelatedTopics;
14
15
    /**
16
     * @var array
17
     */
18
    protected $loginRequiredFor = [
19
        'follow',
20
        'unFollow',
21
    ];
22
23
    protected $followUrl   = UrlBuilder::RESOURCE_FOLLOW_INTEREST;
24
    protected $unFollowUrl = UrlBuilder::RESOURCE_UNFOLLOW_INTEREST;
25
26
    protected $entityIdName = 'interest_id';
27
28
    /**
29
     * Get category info
30
     *
31
     * @param string $topic
32
     * @return array|bool
33
     */
34
    public function info($topic)
35
    {
36
        return $this->get(["interest" => $topic], UrlBuilder::RESOURCE_GET_TOPIC);
37
    }
38
39
    /**
40
     * Returns a feed of pins.
41
     *
42
     * @param string $interest
43
     * @param int $limit
44
     * @return Pagination
45
     */
46
    public function pins($interest, $limit = Pagination::DEFAULT_LIMIT)
47
    {
48
        $data = [
49
            'interest'  => $interest,
50
            'pins_only' => false,
51
        ];
52
53
        return $this->paginate($data, UrlBuilder::RESOURCE_GET_TOPIC_FEED, $limit);
54
    }
55
56
    /**
57
     * Returns an array of trending topics from http://pinterest.com/discover page. Then
58
     * you can use an id of each topic to get trending pins for this topic with
59
     * $bot->pins->explore() method.
60
     *
61
     * @return array
62
     */
63
    public function explore()
64
    {
65
        $data = [
66
            "aux_fields" => [],
67
            "offset"     => 180,
68
        ];
69
70
        return $this->get($data, UrlBuilder::RESOURCE_EXPLORE_SECTIONS);
71
    }
72
}