Пример #1
0
 public function testRequestFactory()
 {
     $client = new Client();
     // Query string
     $r = $client->createRequest('GET', 'http://whatever:8080/path', array('foo' => 'bar', 'baz' => 'qux'));
     $this->assertEquals('http', $r->getUri()->getScheme());
     $this->assertEquals('whatever', $r->getUri()->getHost());
     $this->assertEquals('8080', $r->getUri()->getPort());
     $this->assertEquals('/path', $r->getUri()->getPath());
     $this->assertEquals('foo=bar&baz=qux', $r->getUri()->getQuery());
     // URLEncoded
     $r = $client->createRequest('POST', 'http://whatever:8080/path', null, array('foo' => 'bar', 'baz' => 'qux'), array('content-type' => 'application/x-www-form-urlencoded'));
     $this->assertEquals('foo=bar&baz=qux', $r->getBody());
     // JSON
     $r = $client->createRequest('POST', 'http://whatever', null, array('foo' => 'bar', 'baz' => 'qux'), array('content-type' => 'application/json'));
     $this->assertEquals('{"foo":"bar","baz":"qux"}', $r->getBody());
     // JSON by default
     $r = $client->createRequest('POST', 'http://whatever', null, array('foo' => 'bar', 'baz' => 'qux'));
     $this->assertEquals('{"foo":"bar","baz":"qux"}', $r->getBody());
     // Foo content type
     $r = $client->createRequest('POST', 'http://whatever', null, 'foo-encoded-text', array('content-type' => 'foo'));
     $this->assertEquals('foo-encoded-text', $r->getBody());
 }
Пример #2
0
 /**
  * @param string $path
  * @param array  $body
  * @return ApiResponse
  */
 protected function requestToken($path = '', $body = array())
 {
     $headers = array('Authorization' => 'Basic ' . $this->apiKey(), 'Content-Type' => 'application/x-www-form-urlencoded');
     $request = $this->_client->createRequest('POST', $path, null, $body, $headers);
     return $this->sendRequest($request, array('skipAuthCheck' => true));
 }
Пример #3
0
 /**
  * @param string $url
  * @param array  $queryParameters
  * @param array  $body
  * @param array  $headers
  * @return Transaction
  */
 public function delete($url = '', $queryParameters = array(), $body = null, array $headers = array())
 {
     return $this->apiCall($this->client->requestFactory('DELETE', $url, $queryParameters, $body, $headers));
 }
Пример #4
0
 public function __construct(Registry $registry)
 {
     $this->_registry = $registry;
     parent::__construct();
 }