Class: Tang::ImportCouponsJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
app/jobs/tang/import_coupons_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(starting_after = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'app/jobs/tang/import_coupons_job.rb', line 5

def perform(starting_after = nil)
  # Do something later
  stripe_coupons = Stripe::Coupon.list(limit: 100, starting_after: starting_after)
  stripe_coupons.each do |stripe_coupon|
    Coupon.from_stripe(stripe_coupon)
  end

  if stripe_coupons.has_more
    Tang::ImportCouponsJob.perform_now(stripe_coupons.data.last.id)
  end
end