Sha256: 09e3828b1bac5513877ba558289739adb853ed71e107e63102d3a43ad88bb377

Contents?: true

Size: 461 Bytes

Versions: 6

Compression:

Stored size: 461 Bytes

Contents

module Tang
  class ImportCouponsJob < ActiveJob::Base
    queue_as :default

    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tang-0.2.2 app/jobs/tang/import_coupons_job.rb
tang-0.2.1 app/jobs/tang/import_coupons_job.rb
tang-0.2.0 app/jobs/tang/import_coupons_job.rb
tang-0.1.0 app/jobs/tang/import_coupons_job.rb
tang-0.0.9 app/jobs/tang/import_coupons_job.rb
tang-0.0.8 app/jobs/tang/import_coupons_job.rb