示例#1
0
 /**
  * Loads the shop data.
  *
  * @author David Pauli <*****@*****.**>
  * @param Array $product The product in an array.
  * @since 0.1.3
  */
 private function load()
 {
     // if request method is blocked
     if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
         return;
     }
     $content = RESTClient::send();
     // if respond has no name, slogan, logoUrl, sfUrl and mboUrl
     if (InputValidator::isExistsArrayKey($content, "name") || InputValidator::isExistsArrayKey($content, "slogan") || InputValidator::isExistsArrayKey($content, "logoUrl") || InputValidator::isExistsArrayKey($content, "sfUrl") || InputValidator::isExistsArrayKey($content, "mboUrl")) {
         Logger::error("Respond for " . $this->shop . " can not be interpreted.");
         self::errorSet("C-1");
         return;
     }
     // reset values
     $this->resetValues();
     // save the attributes
     $this->name = $content['name'];
     $this->slogan = $content['slogan'];
     $this->logo = new Image($content['logoUrl']);
     $this->storefrontURL = new URL($content['sfUrl']);
     $this->backofficeURL = new URL($content['mboUrl']);
     // update timestamp when make the next request
     $timestamp = (int) (microtime(true) * 1000);
     $this->NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME;
 }
 /**
  * Sets the configured Currency.
  *
  * @author David Pauli <*****@*****.**>
  * @param String $currency The new used Locale.
  * @return boolean True if set the Currency works, false if not.
  * @since 0.1.0
  * @since 0.1.2 Add error reporting.
  */
 public static function setCurrency($currency)
 {
     self::errorReset();
     self::reload();
     if (InputValidator::isExistsArrayKey(self::$ITEMS, $currency)) {
         self::$USED = $currency;
         return true;
     }
     Logger::error("Can't set currency " . $currency . ". It is not available in the shop.");
     self::errorSet("C-2");
     return false;
 }
示例#3
0
 /**
  * Sets the configured Locale.
  *
  * @author David Pauli <*****@*****.**>
  * @param String $locale The new used Locale.
  * @return boolean True if set the Locale works, false if not.
  * @since 0.1.0
  * @since 0.1.2 Add error reporting.
  */
 public static function setLocale($locale)
 {
     self::errorReset();
     self::reload();
     if (InputValidator::isExistsArrayKey(self::$ITEMS, $locale)) {
         self::$USED = $locale;
         return true;
     }
     Logger::error("Can't set locale " . $locale . ". It is not available in the shop.");
     self::errorSet("L-2");
     return false;
 }