Completed
Push — master ( 88b393...0bf120 )
by Carlos
05:23 queued 02:21
created

Stats::userPortrait()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
/**
13
 * Stats.php.
14
 *
15
 * Part of Overtrue\WeChat.
16
 *
17
 * For the full copyright and license information, please view the LICENSE
18
 * file that was distributed with this source code.
19
 *
20
 * @author    mingyoung <[email protected]>
21
 * @copyright 2017
22
 *
23
 * @see      https://github.com/overtrue
24
 * @see      http://overtrue.me
25
 */
26
27
namespace EasyWeChat\MiniProgram\Stats;
28
29
use EasyWeChat\MiniProgram\Core\AbstractMiniProgram;
30
31
class Stats extends AbstractMiniProgram
32
{
33
    const SUMMARY_TREND = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailysummarytrend';
34
    const DAILY_VISIT_TREND = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend';
35
    const WEEKLY_VISIT_TREND = 'https://api.weixin.qq.com/datacube/getweanalysisappidweeklyvisittrend';
36
    const MONTHLY_VISIT_TREND = 'https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyvisittrend';
37
    const VISIT_DISTRIBUTION = 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitdistribution';
38
    const DAILY_RETAIN_INFO = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailyretaininfo';
39
    const WEEKLY_RETAIN_INFO = 'https://api.weixin.qq.com/datacube/getweanalysisappidweeklyretaininfo';
40
    const MONTHLY_RETAIN_INFO = 'https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyretaininfo';
41
    const VISIT_PAGE = 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitpage';
42
    const USER_PORTRAIT = 'https://api.weixin.qq.com/datacube/getweanalysisappiduserportrait';
43
44
    /**
45
     * Get summary trend.
46
     *
47
     * @param string $from
48
     * @param string $to
49
     *
50
     * @return \EasyWeChat\Support\Collection
51
     */
52 1
    public function summaryTrend($from, $to)
53
    {
54 1
        return $this->query(self::SUMMARY_TREND, $from, $to);
55
    }
56
57
    /**
58
     * Get daily visit trend.
59
     *
60
     * @param string $from
61
     * @param string $to
62
     *
63
     * @return \EasyWeChat\Support\Collection
64
     */
65 1
    public function dailyVisitTrend($from, $to)
66
    {
67 1
        return $this->query(self::DAILY_VISIT_TREND, $from, $to);
68
    }
69
70
    /**
71
     * Get weekly visit trend.
72
     *
73
     * @param string $from
74
     * @param string $to
75
     *
76
     * @return \EasyWeChat\Support\Collection
77
     */
78 1
    public function weeklyVisitTrend($from, $to)
79
    {
80 1
        return $this->query(self::WEEKLY_VISIT_TREND, $from, $to);
81
    }
82
83
    /**
84
     * Get monthly visit trend.
85
     *
86
     * @param string $from
87
     * @param string $to
88
     *
89
     * @return \EasyWeChat\Support\Collection
90
     */
91 1
    public function monthlyVisitTrend($from, $to)
92
    {
93 1
        return $this->query(self::MONTHLY_VISIT_TREND, $from, $to);
94
    }
95
96
    /**
97
     * Get visit distribution.
98
     *
99
     * @param string $from
100
     * @param string $to
101
     *
102
     * @return \EasyWeChat\Support\Collection
103
     */
104 1
    public function visitDistribution($from, $to)
105
    {
106 1
        return $this->query(self::VISIT_DISTRIBUTION, $from, $to);
107
    }
108
109
    /**
110
     * Get daily retain info.
111
     *
112
     * @param string $from
113
     * @param string $to
114
     *
115
     * @return \EasyWeChat\Support\Collection
116
     */
117 1
    public function dailyRetainInfo($from, $to)
118
    {
119 1
        return $this->query(self::DAILY_RETAIN_INFO, $from, $to);
120
    }
121
122
    /**
123
     * Get weekly retain info.
124
     *
125
     * @param string $from
126
     * @param string $to
127
     *
128
     * @return \EasyWeChat\Support\Collection
129
     */
130 1
    public function weeklyRetainInfo($from, $to)
131
    {
132 1
        return $this->query(self::WEEKLY_RETAIN_INFO, $from, $to);
133
    }
134
135
    /**
136
     * Get monthly retain info.
137
     *
138
     * @param string $from
139
     * @param string $to
140
     *
141
     * @return \EasyWeChat\Support\Collection
142
     */
143 1
    public function montylyRetainInfo($from, $to)
144
    {
145 1
        return $this->query(self::MONTHLY_RETAIN_INFO, $from, $to);
146
    }
147
148
    /**
149
     * Get visit page.
150
     *
151
     * @param string $from
152
     * @param string $to
153
     *
154
     * @return \EasyWeChat\Support\Collection
155
     */
156 1
    public function visitPage($from, $to)
157
    {
158 1
        return $this->query(self::VISIT_PAGE, $from, $to);
159
    }
160
161
    /**
162
     * Get user portrait.
163
     *
164
     * @param string $from
165
     * @param string $to
166
     *
167
     * @return \EasyWeChat\Support\Collection
168
     */
169
    public function userPortrait($from, $to)
170
    {
171
        return $this->query(self::USER_PORTRAIT, $from, $to);
172
    }
173
    
174
    /**
175
     * Unify query.
176
     *
177
     * @param string $from
178
     * @param string $to
179
     *
180
     * @return \EasyWeChat\Support\Collection
181
     */
182 9
    protected function query($api, $from, $to)
183
    {
184
        $params = [
185 9
            'begin_date' => $from,
186 9
            'end_date' => $to,
187 9
        ];
188
189 9
        return $this->parseJSON('json', [$api, $params]);
190
    }
191
}
192