2 namespace PayPal\Transport;
3 use PayPal\Core\PPLoggingManager;
4 use PayPal\Core\PPHttpConfig;
5 use PayPal\Core\PPHttpConnection;
11 * @var PPLoggingManager logger interface
17 public function __construct($apiContext) {
18 $this->apiContext = $apiContext;
19 $this->logger = new PPLoggingManager(__CLASS__, $apiContext->getConfig());
23 * @param array $handlers array of handlers
24 * @param string $path Resource path relative to base service endpoint
25 * @param string $method HTTP method - one of GET, POST, PUT, DELETE, PATCH etc
26 * @param string $data Request payload
27 * @param array $headers HTTP headers
29 public function execute($handlers, $path, $method, $data='', $headers=array()) {
31 $config = $this->apiContext->getConfig();
32 $httpConfig = new PPHttpConfig(null, $method);
33 $httpConfig->setHeaders($headers +
35 'Content-Type' => 'application/json'
39 foreach($handlers as $handler) {
40 $handler = new $handler($this->apiContext);
41 $handler->handle($httpConfig, $data, array('path' => $path));
43 $connection = new PPHttpConnection($httpConfig, $config);
44 $response = $connection->execute($data);
45 $this->logger->fine($response);