Created
November 4, 2016 15:03
-
-
Save rickybell/56bae2878bcb7ecfea5cd28823170c58 to your computer and use it in GitHub Desktop.
Este Gist, foi criado com o intuito de gerar cupons em batch(quantidades). Tem alguns parâmetros meio q intuitivos...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateCouponsByBatchAmount | |
def self.go(amount,coupon_type,value,lifetime,gift_card = true,separator = ",") | |
puts "Start:\n" | |
labels = "" | |
(amount).times do |x| | |
tmp_coupon = Basico::Coupon.random_coupon(coupon_type,value) | |
tmp_coupon.valid_until = DateTime.now + lifetime.days | |
tmp_coupon.gift_card = gift_card || nil | |
tmp_coupon.save | |
labels += [tmp_coupon.label.upcase,separator].join("") | |
end | |
puts "\nThats the End." | |
labels | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment