예제 #1
0
 /**
  * @param string $endpointUrl
  * @param array  $putData
  *
  * @return \stdClass
  *
  * @throws GenericHTTPError
  * @throws InvalidCredentials
  * @throws MissingEndpoint
  * @throws MissingRequiredParameters
  */
 public function put($endpointUrl, $putData)
 {
     $request = $this->mgClient->createRequest('PUT', $endpointUrl, ['body' => $putData]);
     /** @var \GuzzleHttp\Post\PostBodyInterface $postBody */
     $postBody = $request->getBody();
     $postBody->setAggregator(Query::duplicateAggregator());
     $response = $this->mgClient->send($request);
     return $this->responseHandler($response);
 }
 /**
  * @ticket https://github.com/guzzle/guzzle/issues/706
  */
 public function testDoesNotApplyPostBodyRightAway()
 {
     $request = (new MessageFactory())->createRequest('POST', 'http://f.cn', ['body' => ['foo' => ['bar', 'baz']]]);
     $this->assertEquals('', $request->getHeader('Content-Type'));
     $this->assertEquals('', $request->getHeader('Content-Length'));
     $request->getBody()->setAggregator(Query::duplicateAggregator());
     $request->getBody()->applyRequestHeaders($request);
     $this->assertEquals('foo=bar&foo=baz', $request->getBody());
 }
예제 #3
0
 public function testCanSpecifyQueryAggregator()
 {
     $b = new PostBody();
     $b->setField('foo', ['baz', 'bar']);
     $this->assertEquals('foo%5B0%5D=baz&foo%5B1%5D=bar', (string) $b);
     $b = new PostBody();
     $b->setField('foo', ['baz', 'bar']);
     $agg = Query::duplicateAggregator();
     $b->setAggregator($agg);
     $this->assertEquals('foo=baz&foo=bar', (string) $b);
 }
예제 #4
0
 public function testDuplicateEncodesNoNumericIndices()
 {
     $agg = Query::duplicateAggregator();
     $result = $agg($this->encodeData);
     $this->assertEquals(array('t[v1]' => ['a', '1'], 't[v2]' => ['b'], 't[v3][v4]' => ['c'], 't[v3][v5]' => ['d']), $result);
 }
예제 #5
0
 /**
  * @param Service $api      Service API description
  * @param string  $endpoint Endpoint to connect to
  */
 public function __construct(Service $api, $endpoint)
 {
     $this->api = $api;
     $this->endpoint = Url::fromString($endpoint);
     $this->aggregator = Query::duplicateAggregator();
 }