/** * @param \stdClass $data * * @return UserPromotion */ public static function createFromStdClass(\stdClass $data) { $userPromotion = new self(); $userPromotion->setId($data->id)->setPromotion(Promotion::createFromStdClass($data->promotion))->setRealValue($data->real_value)->setAuthData($data->auth_data); if ($data->expires_at !== null) { $userPromotion->setExpiresAt((new \DateTime(null, new \DateTimeZone('UTC')))->setTimestamp($data->expires_at)); } return $userPromotion; }
/** * {@inheritdoc} */ public function getOrganizationPromotions() { $response = $this->prepareRequest(Http::GET, $this->getUrl(self::PROMOTIONS))->send(); $data = $this->getSuccessData($response); $result = []; foreach ($data as $promotionData) { $result[] = Promotion::createFromStdClass($promotionData); } return $result; }