/** * sendEvent: * -------------------------------------------------- * Dispatches an event based on the arguments. * @param (dict) (eventData) The event data * (string) (ec) [Req] Event Category. * (string) (ea) [Req] Event Action. * (string) (el) Event label. * (int) (ev) Event value. * @return (boolean) true * -------------------------------------------------- */ public function sendEvent($eventData) { /* Make the analytics url */ $url = $this->makeEventUrl($eventData['ec'], $eventData['ea'], array_key_exists('el', $eventData) ? $eventData['el'] : null, array_key_exists('ev', $eventData) ? $eventData['ev'] : null); /* Send the request */ $client = new GuzzleClient(); $client->post($url['endpoint'], ['query' => $url['params']]); //$response = SiteFunctions::postUrl($url); /* Return */ return true; }
/** * Returns available releases * * @return array */ public function getReleases() { if ($this->releases) { return $this->releases; } try { $response = $this->httpClient->get(static::releasesURL); if (Response::HTTP_OK === $response->getStatusCode()) { $this->releases = json_decode($response->getBody()); return $this->releases; } return false; } catch (RequestException $e) { return false; } }
public function testRunnerWithoutValidator() { $urlProvider = new UrlProvider(['urls' => ['google' => ['url' => 'https://www.google.fr', 'method' => 'GET', 'headers' => [], 'timeout' => 1, 'validator' => [], 'status_code' => 200]]]); $client = GuzzleClient::createClient($this->io, ['handler' => $this->mockClient()]); $runner = new Runner($urlProvider, $client); $resultCollection = $runner->run(); $this->assertCount(1, $urlProvider->getUrls()); $this->assertInstanceOf(UrlInfo::class, $urlProvider->getUrls()['google']); $this->assertInstanceOf(ResultCollection::class, $resultCollection); $this->assertInstanceOf(Result::class, $resultCollection['google']); $this->assertEquals(new Result($this->createUrlInfo(false), 200, 0, null, null), $resultCollection['google']); }
/** * Test for GuzzleClient class factory method. * * @test * @covers GuzzleClient::factory */ public function test_construction() { $client = GuzzleClient::factory(); $this->assertEquals('GuzzleHttp\\Client', get_class($client)); }
/** * Authenticated Request * * @param string $type Request Type * @param string $path Request URL * @param string $token Twitch OAuth Token * * @return \GuzzleHttp\Message\Request|\GuzzleHttp\Message\RequestInterface */ public function sendRequest($type = 'GET', $path = '', $token = false, $options = [], $availableOptions = []) { $response = $this->client->request($type, $path, $this->generateHeaders($token, $options, $availableOptions)); return json_decode(str_replace('http://', 'https://', $response->getBody()), true); }
/** * testClientModifiedOptions. */ public function testClientModifiedOptions() { $client = GuzzleClient::createClient($this->io, ['allow_redirects' => true, 'handler' => new MockHandler()]); $this->assertSame(true, $client->getConfig()['allow_redirects']); $this->assertInstanceOf(MockHandler::class, $client->getConfig()['handler']); }
/** * Creates an authorized request * * @param $type * @param $url * @param $token * * @return \GuzzleHttp\Message\Request|\GuzzleHttp\Message\RequestInterface */ protected function createRequest($type, $url, $token) { return $this->client->createRequest($type, $url, $this->getDefaultHeaders($token)); }