/**
  * @return array
  */
 public function serialize()
 {
     $parentData = parent::serialize();
     if ($this->userPromotion === null) {
         throw new NotEnoughDataException('userPromotion is null');
     }
     if ($this->userPromotion->getId() === null) {
         throw new NotEnoughDataException('userPromotion->id is null');
     }
     $parentData['id'] = $this->userPromotion->getId();
     return $parentData;
 }
예제 #2
0
 /**
  * {@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;
 }