/** * @param $path * @param array $data * @param string $method * @param array $params * @param array $requestOptions * @return mixed|null */ public function getData($path, array $data = null, $method = 'POST', array $params = [], $requestOptions = []) { $requestOptions = array_merge_recursive(['body' => json_encode($data), 'headers' => ['puszek-client-name' => $this->config['client']['name'], 'Content-type' => 'application/json']], $requestOptions); $request = $this->getRequest($path, $params, $method, $requestOptions); $hash = $this->puszekUtils->hash($request->getBody()); $request->setHeader('puszek-security-hash', $hash); return $this->getClient()->send($request)->json(); }
/** * @param $receiver * @param array $subscribe * @param int $expire * @return string */ public function getSocketUrl($receiver, array $subscribe, $expire = 600) { return $this->puszekUtils->getSocketUrl($receiver, $subscribe, $expire); }
/** * */ public function testGetSocketUrl() { $utils = new PuszekUtils($this->getConfig()); $this->assertRegExp('#ws://localhost:5001/hash:[\\w]+\\?receiver=receiver&subscribe%5B0%5D=receiver1&subscribe%5B1%5D=user2&client=name&expire=#', $utils->getSocketUrl('receiver', ['receiver1', 'user2'], 450)); }