1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
4
|
|
|
* |
5
|
|
|
* You are hereby granted a non-exclusive, worldwide, royalty-free license to |
6
|
|
|
* use, copy, modify, and distribute this software in source code or binary |
7
|
|
|
* form for use in connection with the web services and APIs provided by |
8
|
|
|
* Facebook. |
9
|
|
|
* |
10
|
|
|
* As with any software that integrates with the Facebook platform, your use |
11
|
|
|
* of this software is subject to the Facebook Developer Principles and |
12
|
|
|
* Policies [http://developers.facebook.com/policy/]. This copyright notice |
13
|
|
|
* shall be included in all copies or substantial portions of the software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
20
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21
|
|
|
* DEALINGS IN THE SOFTWARE. |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace FacebookAds\Object; |
26
|
|
|
|
27
|
|
|
use FacebookAds\Http\RequestInterface; |
28
|
|
|
|
29
|
|
|
abstract class AbstractArchivableCrudObject extends AbstractCrudObject { |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
const STATUS_PARAM_NAME = 'status'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
const STATUS_ACTIVE = 'ACTIVE'; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
const STATUS_PAUSED = 'PAUSED'; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
const STATUS_DELETED = 'DELETED'; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
const STATUS_ARCHIVED = 'ARCHIVED'; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
public function getStatusParamName() { |
60
|
|
|
return self::STATUS_PARAM_NAME; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Archive this object |
65
|
|
|
* |
66
|
|
|
* @deprecated use api_update instead |
67
|
|
|
* @param array $params |
68
|
|
|
* @return void |
69
|
|
|
*/ |
70
|
|
|
public function archive(array $params = array()) { |
71
|
|
|
$this->getApi()->call( |
72
|
|
|
$this->getNodePath(), |
73
|
|
|
RequestInterface::METHOD_POST, |
74
|
|
|
array_merge($params, array( |
75
|
|
|
$this->getStatusParamName() => static::STATUS_ARCHIVED))); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Delete this object |
80
|
|
|
* |
81
|
|
|
* @deprecated use api_update instead |
82
|
|
|
* @param array $params |
83
|
|
|
* @return void |
84
|
|
|
*/ |
85
|
|
|
public function delete(array $params = array()) { |
86
|
|
|
$this->getApi()->call( |
87
|
|
|
$this->getNodePath(), |
88
|
|
|
RequestInterface::METHOD_POST, |
89
|
|
|
array_merge($params, array( |
90
|
|
|
$this->getStatusParamName() => static::STATUS_DELETED))); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Pause this object |
95
|
|
|
* |
96
|
|
|
* @param array $params |
97
|
|
|
* @return void |
98
|
|
|
*/ |
99
|
|
|
public function pause(array $params = array()) { |
100
|
|
|
$this->getApi()->call( |
101
|
|
|
$this->getNodePath(), |
102
|
|
|
RequestInterface::METHOD_POST, |
103
|
|
|
array_merge($params, array( |
104
|
|
|
$this->getStatusParamName() => static::STATUS_PAUSED))); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Activate this object |
109
|
|
|
* |
110
|
|
|
* @param array $params |
111
|
|
|
* @return void |
112
|
|
|
*/ |
113
|
|
|
public function activate(array $params = array()) { |
114
|
|
|
$this->getApi()->call( |
115
|
|
|
$this->getNodePath(), |
116
|
|
|
RequestInterface::METHOD_POST, |
117
|
|
|
array_merge($params, array( |
118
|
|
|
$this->getStatusParamName() => static::STATUS_ACTIVE))); |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|