DiscoverInfo::getDiscoverApi()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 19
rs 9.9
cc 1
nc 1
nop 5
1
<?php
2
3
namespace Daaner\TikTok\Models;
4
5
use Daaner\TikTok\TikTok;
6
7
class DiscoverInfo extends TikTok
8
{
9
    protected $url;
10
    protected $url_api;
11
12
    /**
13
     * @return $this
14
     */
15
    public function ModelSettings()
16
    {
17
        $this->url = config('tiktok.discover_info.link');
18
        $this->url_api = config('tiktok.discover_info.link_api');
19
    }
20
21
    /**
22
     * @return array
23
     */
24
    public function getDiscover()
25
    {
26
        /* add settings */
27
        $this->ModelSettings();
28
29
        $response = $this->getResponse($this->url);
30
31
        return $response;
32
    }
33
34
    /**
35
     * @param string $type
36
     * @param int|null $count
37
     * @param int|null $offset
38
     * @param bool $needItemList
39
     * @param bool $useRecommend
40
     *
41
     * $discoverType only 0
42
     * $keyWord not used
43
     *
44
     * @return array
45
     */
46
    public function getDiscoverApi($type, $count = 20, $offset = 0, $needItemList = true, $useRecommend = false)
47
    {
48
        /* add settings */
49
        $this->ModelSettings();
50
51
        $body = [
52
            'offset' => $offset,
53
            'count' => $count,
54
            'needItemList' => $needItemList,
55
            'useRecommend' => $useRecommend,
56
            'keyWord' => '',
57
            'discoverType' => 0,
58
        ];
59
60
        $body = array_merge($body, config('tiktok.primary_body_api'));
61
62
        $response = $this->getResponse($this->url_api.$type, $body);
63
64
        return $response;
65
    }
66
}
67