Example #1
0
 public function sendRequest($params, $method)
 {
     // use 'fn.requests.php' methods
     // to use separately from cart
     // 'fn_https_request', 'fn_http_request'
     // methods  should be replaced by new
     // functions
     list($url, $params) = $this->getRequest($this->service_url, $params, $method);
     if (empty($url)) {
         return false;
     }
     if (strtolower($method) == 'post') {
         $response = Http::post($url, $params);
     } else {
         $response = Http::get($url, $params);
     }
     $this->response_doc = $response;
     $parser = new ApiData($this->api_version);
     if (!$parser->parseResponse($response, $this->api_format)) {
         return false;
     }
     $this->response_data = $parser->getData();
     $this->meta = $parser->getMeta();
     $this->errors = $parser->getErrors();
     if (!empty($this->errors)) {
         return false;
     }
     return true;
 }