Skip to content

Instantly share code, notes, and snippets.

@rickybell
Created November 4, 2016 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickybell/56bae2878bcb7ecfea5cd28823170c58 to your computer and use it in GitHub Desktop.
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...
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