Пример #1
0
 public function sync(array $ids)
 {
     $ids = $this->mapMultipleIdsForRequest($ids);
     $promises = ['base' => $this->client->putAsync($this->getEndpoint(), ['json' => $ids])];
     $response = $this->send($promises);
     $this->updateAttachmentsToModel($response);
     return true;
 }
Пример #2
0
 public function addMockResults(array $results, callable $onFulfilled = null, callable $onRejected = null)
 {
     $mock = new MockHandler($results, $onFulfilled, $onRejected);
     $handler = HandlerStack::create($mock);
     $handler->push(Middleware::history($this->history));
     $container = WpsContainer::getInstance();
     $container->container->add('WpsClient', function () use($handler) {
         return WpsClient::factory(['base_uri' => '/', 'defaults' => ['headers' => ['Content-Type' => 'application/json']], 'handler' => $handler], true);
     });
 }
Пример #3
0
 private function register()
 {
     $this->container->add('WpsClient', function () {
         $stack = new HandlerStack();
         $stack->setHandler(new CurlHandler());
         $stack->push(Middleware::mapRequest(function (RequestInterface $request) {
             //print_r((string)$request->getUri() . PHP_EOL);
             return $request;
         }));
         return WpsClient::factory(['handler' => $stack, 'base_uri' => $this->config['base_uri'], 'auth' => $this->config['auth'], 'headers' => ['Content-Type' => 'application/json']]);
     });
     $this->container->add('RequestBuilder', function ($args) {
         $client = $this->container->get('WpsClient');
         $uriGenerator = new UriGenerator();
         return new RequestBuilder($client, $uriGenerator, $args);
     });
 }