/** * @param ECheepAPIInterface $api * * @return bool */ function sampleUserGift(ECheepAPIInterface $api) { $promotions = sampleOrganizationPromotions($api); $user = sampleUserByPhone($api); $gift = new Gift(); $gift->setValue(20)->setUser($user)->setPromotion($promotions[0])->setAuthData('some-auth-data')->setExpiresAt(new \DateTime('+4 days')); return $api->createUserGift($gift); }
/** * {@inheritdoc} */ public function createUserGift(GiftRequest $gift) { $giftUrl = sprintf(self::USER_GIFT, $gift->getUser()->getId()); $response = $this->prepareRequest(Http::POST, $this->getUrl($giftUrl))->body($gift->serialize(), 'application/json')->send(); $this->getSuccessData($response); return true; }