Model/SalesRule/DotmailerCouponGenerator.php
public function generateCoupon($priceRuleId, $expireDate)
    {
        $rule   = $this->getPriceRule($priceRuleId);
        $coupon = $rule->acquireCoupon();
        $coupon = $this->setUpCoupon($expireDate, $coupon, $rule);
        $this->couponResourceInterface->save($coupon);

        return $coupon->getCode();
    }
public function generateCoupon($priceRuleId, $expireDate)
    {
        $rule   = $this->getPriceRule($priceRuleId);
        $coupon = $rule->acquireCoupon();
        $coupon = $this->setUpCoupon($expireDate, $coupon, $rule);
        $this->couponResourceInterface->save($coupon);

        return $coupon->getCode();
    }
public function generateCoupon ( $ priceRuleId , $ expireDate ) { $ rule = $ this -> getPriceRule ( $ priceRuleId ) ; $ coupon = $ rule -> acquireCoupon ( ) ; $ coupon = $ this -> setUpCoupon ( $ expireDate , $ coupon , $ rule ) ; $ this -> couponResourceInterface -> save ( $ coupon ) ; return $ coupon -> getCode ( ) ; }
Generate coupon.

@param int $priceRuleId
@param \DateTime $expireDate

@return bool
@throws \Magento\Framework\Exception\LocalizedException
Generate coupon .