Completed
Push — master ( f7db99...180f32 )
by Dmitry
03:22
created

Campaigns   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 158
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 158
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 1

8 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 9 1
A archive() 0 9 1
A delete() 0 9 1
A get() 0 16 1
A resume() 0 9 1
A suspend() 0 9 1
A unarchive() 0 9 1
A update() 0 9 1
1
<?php
2
/**
3
 * @author Dmitry Gladyshev <[email protected]>
4
 * @date 26/08/2016 14:03
5
 */
6
7
namespace Yandex\Direct\Service;
8
9
use Yandex\Direct\Exception\Exception;
10
use Yandex\Direct\Service;
11
use function Yandex\Direct\get_param_names;
12
13
/**
14
 * Class Campaigns
15
 * @package Yandex\Direct\Service
16
 */
17
final class Campaigns extends Service
18
{
19
    /**
20
     * @param array $Campaigns
21
     * @return array
22
     * @throws Exception
23
     *
24
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/add-docpage/
25
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/add-text-campaign-docpage/
26
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/add-dynamic-text-campaign-docpage/
27
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/add-mobile-app-campaign-docpage/
28
     */
29
    public function add($Campaigns)
30
    {
31
        return $this->request([
32
            'method' => 'add',
33
            'params' => [
34
                'Campaigns' => $Campaigns
35
            ]
36
        ]);
37
    }
38
39
    /**
40
     * @param array $SelectionCriteria
41
     * @return array
42
     * @throws Exception
43
     *
44
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/archive-docpage/
45
     */
46
    public function archive($SelectionCriteria)
47
    {
48
        return $this->request([
49
            'method' => 'archive',
50
            'params' => [
51
                'SelectionCriteria' => $SelectionCriteria
52
            ]
53
        ]);
54
    }
55
56
    /**
57
     * @param array $SelectionCriteria
58
     * @return array
59
     * @throws Exception
60
     *
61
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/delete-docpage/
62
     */
63
    public function delete($SelectionCriteria)
64
    {
65
        return $this->request([
66
            'method' => 'delete',
67
            'params' => [
68
                'SelectionCriteria' => $SelectionCriteria
69
            ]
70
        ]);
71
    }
72
73
    /**
74
     * @param array $SelectionCriteria
75
     * @param array $FieldNames
76
     * @param array $TextCampaignFieldNames
77
     * @param array $MobileAppCampaignFieldNames
78
     * @param array $DynamicTextCampaignFieldNames
79
     * @param array $CpmBannerCampaignFieldNames
80
     * @param array $Page
81
     * @return array
82
     * @throws Exception
83
     * @throws \ReflectionException
84
     *
85
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/get-docpage/
86
     */
87
    public function get(
88
        $SelectionCriteria,
89
        $FieldNames,
90
        $TextCampaignFieldNames = null,
91
        $MobileAppCampaignFieldNames = null,
92
        $DynamicTextCampaignFieldNames = null,
93
        $CpmBannerCampaignFieldNames = null,
94
        $Page = null
95
    ) {
96
        $params = compact(get_param_names(__METHOD__));
97
98
        return $this->request([
99
            'method' => 'get',
100
            'params' => $params
101
        ]);
102
    }
103
104
    /**
105
     * @param $SelectionCriteria
106
     * @return array
107
     * @throws Exception
108
     *
109
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/resume-docpage/
110
     */
111
    public function resume($SelectionCriteria)
112
    {
113
        return $this->request([
114
            'method' => 'resume',
115
            'params' => [
116
                'SelectionCriteria' => $SelectionCriteria
117
            ]
118
        ]);
119
    }
120
121
    /**
122
     * @param array $SelectionCriteria
123
     * @return array
124
     * @throws Exception
125
     *
126
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/suspend-docpage/
127
     */
128
    public function suspend($SelectionCriteria)
129
    {
130
        return $this->request([
131
            'method' => 'suspend',
132
            'params' => [
133
                'SelectionCriteria' => $SelectionCriteria
134
            ]
135
        ]);
136
    }
137
138
    /**
139
     * @param array $SelectionCriteria
140
     * @return array
141
     * @throws Exception
142
     *
143
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/unarchive-docpage/
144
     */
145
    public function unarchive($SelectionCriteria)
146
    {
147
        return $this->request([
148
            'method' => 'unarchive',
149
            'params' => [
150
                'SelectionCriteria' => $SelectionCriteria
151
            ]
152
        ]);
153
    }
154
155
    /**
156
     * @param array $Campaigns
157
     * @return array
158
     * @throws Exception
159
     *
160
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/update-docpage/
161
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/update-text-campaign-docpage/
162
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/update-dynamic-text-campaign-docpage/
163
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/update-mobile-app-campaign-docpage/
164
     */
165
    public function update($Campaigns)
166
    {
167
        return $this->request([
168
            'method' => 'update',
169
            'params' => [
170
                'Campaigns' => $Campaigns
171
            ]
172
        ]);
173
    }
174
}
175