1 | <?php |
||
33 | class Api { |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | const VERSION = ApiConfig::APIVersion; |
||
39 | |||
40 | /** |
||
41 | * @var Api |
||
42 | */ |
||
43 | protected static $instance; |
||
44 | |||
45 | /** |
||
46 | * @var SessionInterface |
||
47 | */ |
||
48 | private $session; |
||
49 | |||
50 | /** |
||
51 | * @var LoggerInterface |
||
52 | */ |
||
53 | protected $logger; |
||
54 | |||
55 | /** |
||
56 | * @var Client |
||
57 | */ |
||
58 | protected $httpClient; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | protected $defaultGraphVersion; |
||
64 | |||
65 | /** |
||
66 | * @param Client $http_client |
||
67 | * @param SessionInterface $session A Facebook API session |
||
68 | */ |
||
69 | 6 | public function __construct( |
|
70 | Client $http_client, |
||
71 | SessionInterface $session) { |
||
72 | 6 | $this->httpClient = $http_client; |
|
73 | 6 | $this->session = $session; |
|
74 | 6 | } |
|
75 | |||
76 | /** |
||
77 | * @param string $app_id |
||
78 | * @param string $app_secret |
||
79 | * @param string $access_token |
||
80 | * @return static |
||
81 | */ |
||
82 | 1 | public static function init($app_id, $app_secret, $access_token) { |
|
89 | |||
90 | /** |
||
91 | * @return Api|null |
||
92 | */ |
||
93 | 26 | public static function instance() { |
|
96 | |||
97 | /** |
||
98 | * @param Api $instance |
||
99 | */ |
||
100 | 2 | public static function setInstance(Api $instance) { |
|
103 | |||
104 | /** |
||
105 | * @param SessionInterface $session |
||
106 | * @return Api |
||
107 | */ |
||
108 | 1 | public function getCopyWithSession(SessionInterface $session) { |
|
114 | |||
115 | /** |
||
116 | * @param string $string |
||
117 | * @return string |
||
118 | */ |
||
119 | public static function base64UrlEncode($string) { |
||
124 | |||
125 | 1 | /** |
|
126 | 1 | * @param string $path |
|
127 | 1 | * @param string $method |
|
128 | 1 | * @param array $params |
|
129 | * @return RequestInterface |
||
130 | 1 | */ |
|
131 | 1 | public function prepareRequest( |
|
155 | |||
156 | /** |
||
157 | * @param RequestInterface $request |
||
158 | * @return ResponseInterface |
||
159 | */ |
||
160 | 2 | public function executeRequest(RequestInterface $request) { |
|
167 | |||
168 | 2 | /** |
|
169 | * @return string |
||
170 | */ |
||
171 | public function getDefaultGraphVersion() { |
||
181 | |||
182 | /** |
||
183 | * @param string $version |
||
184 | */ |
||
185 | public function setDefaultGraphVersion($version) { |
||
188 | |||
189 | /** |
||
190 | * Make graph api calls |
||
191 | 1 | * |
|
192 | * @param string $path Ads API endpoint |
||
193 | 1 | * @param string $method Ads API request type |
|
194 | * @param array $params Assoc of request parameters |
||
195 | * @return ResponseInterface Graph API responses |
||
196 | */ |
||
197 | public function call( |
||
206 | 2 | ||
207 | 2 | /** |
|
208 | 2 | * @return SessionInterface |
|
209 | */ |
||
210 | public function getSession() { |
||
213 | 2 | ||
214 | 2 | /** |
|
215 | 1 | * @param LoggerInterface $logger |
|
216 | 1 | */ |
|
217 | 2 | public function setLogger(LoggerInterface $logger) { |
|
220 | |||
221 | /** |
||
222 | * @return LoggerInterface |
||
223 | 2 | */ |
|
224 | 2 | public function getLogger() { |
|
230 | |||
231 | /** |
||
232 | * @return Client |
||
233 | */ |
||
234 | public function getHttpClient() { |
||
237 | } |
||
238 |