/** * Retrive the package stock * * @param $number customer number * @return object */ public function find($number) { $resources = new Resources(); $resources->setHeaders(array('Accept' => 'application/json')); $resources->setBaseUrl(Config::get("resources::gemba.baseUrl")); $json = $resources->get("packagesstock.{$number}"); $stock = json_decode($json); if ($stock->status > 0) { return array(); } return $stock->data->PackageStock; }
/** * Get all packages * @return array of packages */ public function all() { $resources = new Resources(); $resources->setAuthorization(); $resources->setBaseUrl(Config::get("resources::gemba.baseUrl")); $resources->setHeaders(array("Accept" => "application/json")); $json = $resources->get("packagesrequest"); $packagesRequest = json_decode($json, true); if (empty($packagesRequest)) { return array(); } $listPackages = array(); return $packagesRequest; }
/** * Get user * @param user number * @return bool */ private function retrive($number) { $resources = new Resources(); $resources->setAuthorization(); $resources->setHeaders(array('Accept' => 'application/json')); $json = $resources->get("users.{$number}"); $user = json_decode($json, true); if (!$user || count($user) == 0) { return false; } $this->fill($user); return true; }
/** * Calculate budget finalPrice. * @return bool */ public function calculate() { $resources = new Resources(); $resources->setAuthorization(); $resources->setHeaders(array("Content-Type" => "application/json")); $resources->setContent($this->toArray(), 'json'); $json = $resources->post("budget"); $budget = json_decode($json); return $budget; }
/** * Get customer * @param customer number * @return bool */ private function retrive($number) { $resources = new Resources(); $resources->setHeaders(array('Accept' => 'application/json')); $json = $resources->get("customer.{$number}"); $customer = json_decode($json); if ($customer->status > 0) { return false; } $this->number = $customer->data->customer[0][0]->Cliente; $this->password = $customer->data->customer[0][0]->CDU_Password; $this->name = $customer->data->customer[0][0]->Nome; $this->address = $customer->data->customer[0][0]->Fac_Mor; $this->local = $customer->data->customer[0][0]->Fac_Local; $this->zipCode = $customer->data->customer[0][0]->Fac_Cp; $this->city = $customer->data->customer[0][0]->Fac_Cploc; $this->phone = $customer->data->customer[0][0]->Fac_Tel; $this->fax = $customer->data->customer[0][0]->Fac_Fax; $this->country = $customer->data->customer[0][0]->Pais; $this->fiscalNumber = $customer->data->customer[0][0]->NumContrib; $this->creditStatus = $customer->data->customer[0][0]->CDU_CampoVar1; $this->fares = $customer->data->customer[0][0]->CDU_CampoVar2; $this->contactCycle = $customer->data->customer[0][0]->CDU_CampoVar4; $this->cutOff = $customer->data->customer[0][0]->CDU_ObsOps; $this->seller = $customer->data->customer[0][0]->Vendedor; $this->delegation = $customer->data->customer[0][0]->Delegacao; $this->creationDate = $customer->data->customer[0][0]->DataCriacao; $this->updateDate = $customer->data->customer[0][0]->DataUltimaActualizacao; return true; }
/** * Get * @param customer number * @return bool */ private function retrive($number) { $resources = new Resources(); $resources->setHeaders(array('Accept' => 'application/json', 'Authorization' => 'Basic bG9nbWU6MTIzbG9nbWUwOTg=')); $json = $resources->get("country.{$number}"); $country = json_decode($json); if (!$country) { return false; } $this->id = $country->Id; $this->code = $country->Code; $this->alpha2 = $country->Alpha2; $this->alpha3 = $country->Alpha3; $this->name_en = $country->Name_en; $this->name_pt = $country->Name_pt; $this->transports = $country->transports; return true; }