1 | <?php |
||
33 | class Client { |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | const DEFAULT_GRAPH_BASE_DOMAIN = 'facebook.com'; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | const DEFAULT_LAST_LEVEL_DOMAIN = 'graph'; |
||
44 | |||
45 | /** |
||
46 | * @var RequestInterface |
||
47 | */ |
||
48 | protected $requestPrototype; |
||
49 | |||
50 | /** |
||
51 | * @var ResponseInterface |
||
52 | */ |
||
53 | protected $responsePrototype; |
||
54 | |||
55 | /** |
||
56 | * @var Headers |
||
57 | */ |
||
58 | protected $defaultRequestHeaders; |
||
59 | |||
60 | /** |
||
61 | * @var AdapterInterface |
||
62 | */ |
||
63 | protected $adapter; |
||
64 | |||
65 | /** |
||
66 | * @var string |
||
67 | */ |
||
68 | protected $caBundlePath; |
||
69 | |||
70 | /** |
||
71 | * @var string |
||
72 | */ |
||
73 | protected $defaultGraphBaseDomain = self::DEFAULT_GRAPH_BASE_DOMAIN; |
||
74 | |||
75 | /** |
||
76 | * @return RequestInterface |
||
77 | */ |
||
78 | 1 | public function getRequestPrototype() { |
|
79 | 1 | if ($this->requestPrototype === null) { |
|
80 | 1 | $this->requestPrototype = new Request($this); |
|
81 | 1 | } |
|
82 | |||
83 | 1 | return $this->requestPrototype; |
|
84 | } |
||
85 | |||
86 | /** |
||
87 | * @param RequestInterface $prototype |
||
88 | */ |
||
89 | 1 | public function setRequestPrototype(RequestInterface $prototype) { |
|
92 | |||
93 | /** |
||
94 | * @return RequestInterface |
||
95 | */ |
||
96 | 1 | public function createRequest() { |
|
99 | |||
100 | /** |
||
101 | * @return ResponseInterface |
||
102 | */ |
||
103 | 2 | public function getResponsePrototype() { |
|
104 | 2 | if ($this->responsePrototype === null) { |
|
105 | 2 | $this->responsePrototype = new Response(); |
|
106 | 2 | } |
|
107 | |||
108 | 2 | return $this->responsePrototype; |
|
109 | } |
||
110 | |||
111 | /** |
||
112 | * @param ResponseInterface $prototype |
||
113 | */ |
||
114 | 1 | public function setResponsePrototype(ResponseInterface $prototype) { |
|
117 | |||
118 | /** |
||
119 | * @return ResponseInterface |
||
120 | */ |
||
121 | 2 | public function createResponse() { |
|
124 | |||
125 | /** |
||
126 | * @return Headers |
||
127 | */ |
||
128 | 1 | public function getDefaultRequestHeaderds() { |
|
129 | 1 | if ($this->defaultRequestHeaders === null) { |
|
130 | 1 | $this->defaultRequestHeaders = new Headers(array( |
|
131 | 1 | 'User-Agent' => 'fb-php-ads-'.Api::VERSION, |
|
132 | 1 | 'Accept-Encoding' => '*', |
|
133 | 1 | )); |
|
134 | 1 | } |
|
135 | |||
136 | 1 | return $this->defaultRequestHeaders; |
|
137 | } |
||
138 | |||
139 | /** |
||
140 | * @param Headers $headers |
||
141 | */ |
||
142 | 1 | public function setDefaultRequestHeaders(Headers $headers) { |
|
145 | |||
146 | /** |
||
147 | * @return string |
||
148 | */ |
||
149 | 1 | public function getDefaultGraphBaseDomain() { |
|
152 | |||
153 | /** |
||
154 | * @param string $domain |
||
155 | */ |
||
156 | 1 | public function setDefaultGraphBaseDomain($domain) { |
|
159 | |||
160 | /** |
||
161 | * @return AdapterInterface |
||
162 | */ |
||
163 | 2 | public function getAdapter() { |
|
164 | 2 | if ($this->adapter === null) { |
|
165 | 1 | $this->adapter = new CurlAdapter($this); |
|
166 | 1 | } |
|
167 | |||
168 | 2 | return $this->adapter; |
|
169 | } |
||
170 | |||
171 | /** |
||
172 | * @param AdapterInterface $adapter |
||
173 | */ |
||
174 | 2 | public function setAdapter(AdapterInterface $adapter) { |
|
177 | |||
178 | /** |
||
179 | * @return string |
||
180 | */ |
||
181 | 4 | public function getCaBundlePath() { |
|
190 | |||
191 | /** |
||
192 | * @param string $path |
||
193 | */ |
||
194 | 1 | public function setCaBundlePath($path) { |
|
197 | |||
198 | /** |
||
199 | * @param RequestInterface $request |
||
200 | * @return ResponseInterface |
||
201 | * @throws RequestException |
||
202 | */ |
||
203 | 1 | public function sendRequest(RequestInterface $request) { |
|
220 | } |
||
221 |