Client::getFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 8
Ratio 88.89 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 8
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace CloudyCity\UCMarketingSDK\Report;
4
5
use CloudyCity\UCMarketingSDK\Kernel\BaseClient;
6
7
class Client extends BaseClient
8
{
9
    /**
10
     * 获取账户报表.
11
     *
12
     * @param array $params
13
     *
14
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\ApiException
15
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\InvalidArgumentException
16
     * @throws \GuzzleHttp\Exception\GuzzleException
17
     *
18
     * @return array|\Doctrine\Common\Collections\ArrayCollection|object|\Psr\Http\Message\ResponseInterface|string
19
     */
20
    public function getAccountReports(array $params)
21
    {
22
        return $this->httpPostJson('report/account', $params);
23
    }
24
25
    /**
26
     * 获取推广组报表.
27
     *
28
     * @param array $params
29
     *
30
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\ApiException
31
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\InvalidArgumentException
32
     * @throws \GuzzleHttp\Exception\GuzzleException
33
     *
34
     * @return array|\Doctrine\Common\Collections\ArrayCollection|object|\Psr\Http\Message\ResponseInterface|string
35
     */
36
    public function getAdGroupReports(array $params)
37
    {
38
        return $this->httpPostJson('report/adgroup', $params);
39
    }
40
41
    /**
42
     * 获取推广计划报表.
43
     *
44
     * @param array $params
45
     *
46
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\ApiException
47
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\InvalidArgumentException
48
     * @throws \GuzzleHttp\Exception\GuzzleException
49
     *
50
     * @return array|\Doctrine\Common\Collections\ArrayCollection|object|\Psr\Http\Message\ResponseInterface|string
51
     */
52
    public function getCampaignReports(array $params)
53
    {
54
        return $this->httpPostJson('report/campaign', $params);
55
    }
56
57
    /**
58
     * 获取推广创意报表.
59
     *
60
     * @param array $params
61
     *
62
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\ApiException
63
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\InvalidArgumentException
64
     * @throws \GuzzleHttp\Exception\GuzzleException
65
     *
66
     * @return array|\Doctrine\Common\Collections\ArrayCollection|object|\Psr\Http\Message\ResponseInterface|string
67
     */
68
    public function getCreativeReports(array $params)
69
    {
70
        return $this->httpPostJson('report/creative', $params);
71
    }
72
73
    /**
74
     * 获取app报表.
75
     *
76
     * @param array $params
77
     *
78
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\ApiException
79
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\InvalidArgumentException
80
     * @throws \GuzzleHttp\Exception\GuzzleException
81
     *
82
     * @return array|\Doctrine\Common\Collections\ArrayCollection|object|\Psr\Http\Message\ResponseInterface|string
83
     */
84
    public function getAppReports(array $params)
85
    {
86
        return $this->httpPostJson('report/app', $params);
87
    }
88
89
    /**
90
     * 获取受众分析报表.
91
     *
92
     * @param array $params
93
     *
94
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\ApiException
95
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\InvalidArgumentException
96
     * @throws \GuzzleHttp\Exception\GuzzleException
97
     *
98
     * @return array|\Doctrine\Common\Collections\ArrayCollection|object|\Psr\Http\Message\ResponseInterface|string
99
     */
100
    public function getAudienceReports(array $params)
101
    {
102
        return $this->httpPostJson('report/audience', $params);
103
    }
104
105
    /**
106
     * 获取视频报表.
107
     *
108
     * @param array $params
109
     *
110
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\ApiException
111
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\InvalidArgumentException
112
     * @throws \GuzzleHttp\Exception\GuzzleException
113
     *
114
     * @return array|\Doctrine\Common\Collections\ArrayCollection|object|\Psr\Http\Message\ResponseInterface|string
115
     */
116
    public function getVideoReports(array $params)
117
    {
118
        return $this->httpPostJson('report/video', $params);
119
    }
120
121
    /**
122
     * 查询下载任务状态.
123
     *
124
     * @param number $taskId
125
     * @param bool   $adReport
126
     *
127
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\ApiException
128
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\InvalidArgumentException
129
     * @throws \GuzzleHttp\Exception\GuzzleException
130
     *
131
     * @return array|\Doctrine\Common\Collections\ArrayCollection|object|\Psr\Http\Message\ResponseInterface|string
132
     */
133 View Code Duplication
    public function getFile($taskId, $adReport = true)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
134
    {
135
        $params = [
136
            'taskId'   => $taskId,
137
            'adReport' => $adReport,
138
        ];
139
140
        return $this->httpPostJson('report/getFile', $params);
141
    }
142
143
    /**
144
     * 下载报表文件并转为数组.
145
     *
146
     * @param number $taskId
147
     * @param bool   $adReport
148
     *
149
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\ApiException
150
     * @throws \CloudyCity\UCMarketingSDK\Kernel\Exceptions\InvalidArgumentException
151
     * @throws \GuzzleHttp\Exception\GuzzleException
152
     *
153
     * @return array|\Doctrine\Common\Collections\ArrayCollection|object|\Psr\Http\Message\ResponseInterface|string
154
     */
155 View Code Duplication
    public function downloadFile($taskId, $adReport = true)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
156
    {
157
        $params = [
158
            'taskId'   => $taskId,
159
            'adReport' => $adReport,
160
        ];
161
162
        return $this->httpPostJson('report/downloadFile', $params);
163
    }
164
}
165