Ejemplo n.º 1
0
 /**
  * @throws NotEnoughDataException
  *
  * @return array
  */
 public function serialize()
 {
     $parentData = parent::serialize();
     $parentData['expires_at'] = $this->expiresAt !== null && $this->expiresAt instanceof \DateTime ? $this->expiresAt->getTimestamp() : $this->expiresAt;
     return $parentData;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function createUserPromotion(UserPromotionIssuance $issuance)
 {
     if ($issuance->getUser() === null || $issuance->getUser()->getId() === null) {
         throw new NotEnoughDataException('user is null or user->id is null');
     }
     $promotionsUrl = sprintf(self::USER_PROMOTIONS, $issuance->getUser()->getId());
     $response = $this->prepareRequest(Http::POST, $this->getUrl($promotionsUrl))->body($issuance->serialize(), 'application/json')->send();
     return UserPromotion::createFromStdClass($this->getSuccessData($response));
 }