logHelper = $logHelper; } public function setEmail($email) { $this->email = $email; } public function increaseOffset($number) { $this->offset = $this->offset + $number; } public function setTimefromAndTo($time_from, $time_to) { $this->time_from = $time_from; $this->time_to = $time_to; } public function getOffset() { return $this->offset; } public function setOffset($offset) { $this->offset = $offset; } public function login() { $response = $this->post(self::API_LOGIN_URL, array("userEmail" => "admin@apactech.io", "password" => "work1234@ct") ); if ($response->getStatusCode() == 200) { $data = json_decode($response->getBody()->getContents(), true); if (is_array($data) && array_key_exists("token", $data) ) { $this->setToken($data["token"]); return true; } } //$this->logHelper->write(" Can not login "); //$this->logHelper->write($response->getStatusCode()); //$this->logHelper->write($response->getBody()); return false; } public function saveQuoteInToERP($data) { // $this->logHelper->write(self::API_POST_DATA_QUOTE_IN); // $this->logHelper->write(json_encode($data)); // $this->logHelper->write(json_encode($this->getHeaders())); $response = $this->postV2(self::API_POST_DATA_QUOTE_IN, $data); //$this->logHelper($response->getBody()->getContents()); if ($response->getStatusCode() == 200) { $data = json_decode($response->getBody()->getContents(), true); if (is_array($data) && array_key_exists("Status", $data) && $data["Status"] == "OK") { return true; } } return false; } public function buildParamForTime(){ if ($this->time_from != null) { //1 year //$year = 60*60*24*365; $param = "&timefrom=".$this->time_from."&timeto=".$this->time_to; return $param; } return ""; } public function buildParamUrl(){ $paramUrl = json_decode(self::FILTER, true); $paramUrl["skip"] = $this->offset*$this->limit; $paramUrl["limit"] = $this->limit; $paramUrl["where"]["email"] = $this->email; return urlencode(json_encode($paramUrl)); } public function getData($email) { $this->setEmail($email); //$this->logHelper->write("offset :".$this->offset); $url = self::API_GET_DATA_URL."filter=".$this->buildParamUrl(); //$this->logHelper->write($url); $response = $this->get( $url ); return $response; } }