/**
  * Default constructor.
  *
  * @param string $secret    the application secret
  * @param string $companyId the application company ID
  * @param bool   $testMode  specifies the mode of operation
  * @param string $url       the URL to use for communication end-points
  * @param string $urlOAuth       the URL to use for OAuth API calls
  *
  * @return void
  */
 public function __construct($secret, $companyId, $testMode = false, $url = null, $urlOAuth = null)
 {
     if ($url === null) {
         $url = ApiURLs::DEFAULT_PLENIGO_URL;
     }
     if ($urlOAuth === null) {
         $urlOAuth = ApiURLs::OAUTH_PLENIGO_URL;
     }
     $this->secret = $secret;
     $this->companyId = $companyId;
     $this->testMode = safe_boolval($testMode);
     $this->url = $url;
     $this->urlOAuth = $urlOAuth;
 }
Example #2
0
 /**
  * Sets the test mode flag.
  *
  * @param bool $ts The flag value.
  *
  * @return void
  */
 public function setTestMode($ts)
 {
     $this->testMode = safe_boolval($ts);
 }
 /**
  * Recovers the typified data of the cookie and returns a parsed object with variables
  * 
  * @param string $data the string representation of the data on the view cookie
  * @return MeteredUserData a parsed object with variables
  */
 private static function parseMeteredUserData($data)
 {
     $clazz = get_class();
     PlenigoManager::notice($clazz, "Metered Data: " . print_r($data, true));
     $arr = explode('|', $data);
     $activated = safe_boolval($arr[self::METERED_VIEW_ACTIVATED_IDX_POS]);
     $allowed = intval($arr[self::FREE_VIEWS_ALLOWED_IDX_POS]);
     $taken = intval($arr[self::FREE_VIEWS_TAKEN_IDX_POS]);
     $reached = safe_boolval($arr[self::FREE_VIEWS_LIMIT_REACHED_IDX_POS]);
     $logAllowed = intval($arr[self::LOGIN_FREE_VIEWS_ALLOWED_IDX_POS]);
     $logTaken = intval($arr[self::LOGIN_FREE_VIEWS_TAKEN_IDX_POS]);
     $logReached = safe_boolval($arr[self::LOGIN_FREE_VIEWS_LIMIT_REACHED_IDX_POS]);
     $res = new MeteredUserData($activated, $allowed, $taken, $reached, $logAllowed, $logTaken, $logReached);
     $res->setStartTime(intval($arr[self::START_TIME_IDX_POS]));
     $res->setMeteredPeriod(trim($arr[self::METERED_PERIOD_IDX_POS]));
     $res->setStartWithFirstDay(safe_boolval($arr[self::START_WITH_FIRST_DAY_IDX_POS]));
     $res->setCookieCreationTime(intval($arr[self::COOKIE_CREATION_TIME_IDX_POS]));
     return $res;
 }
 /**
  * Sets the custom ammount flag.
  *
  * @param bool $condition The condition to set.
  *
  * @return void
  */
 public function setCustomAmount($condition)
 {
     $this->customAmount = safe_boolval($condition);
 }