/** * @return array */ public function serialize() { $parentData = parent::serialize(); if ($this->promotion === null) { throw new NotEnoughDataException('promotion is null'); } if ($this->promotion->getAlias() === null) { throw new NotEnoughDataException('promotion->alias is null'); } if ($this->user === null) { throw new NotEnoughDataException('user is null'); } if ($this->user->getId() === null) { throw new NotEnoughDataException('user->id is null'); } $parentData['promotion_alias'] = $this->promotion->getAlias(); $parentData['user_id'] = $this->user->getId(); return $parentData; }
/** * {@inheritdoc} */ public function getUserPromotions(User $user) { $promotionsUrl = sprintf(self::USER_PROMOTIONS, $user->getId()); $url = $this->getUrl($promotionsUrl); $response = $this->prepareRequest(Http::GET, $url)->send(); $data = $this->getSuccessData($response); $result = []; foreach ($data as $userPromotionData) { $result[] = UserPromotion::createFromStdClass($userPromotionData); } return $result; }