Sha256: 9c2788d676a920f99ce50588e7e04b8daf5cff3711b50ddd4d02e707e65a27aa

Contents?: true

Size: 830 Bytes

Versions: 6

Compression:

Stored size: 830 Bytes

Contents

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

    def perform(starting_after = nil)
      # Do something later
      stripe_plans = Stripe::Plan.list(limit: 100, starting_after: starting_after)
      stripe_plans.each do |stripe_plan|
        Plan.find_or_create_by(stripe_id: stripe_plan.id) do |p|
          p.amount = stripe_plan.amount
          p.currency = stripe_plan.currency
          p.interval = stripe_plan.interval
          p.interval_count = stripe_plan.interval_count
          p.name = stripe_plan.name
          p.statement_descriptor = stripe_plan.statement_descriptor
          p.trial_period_days = stripe_plan.trial_period_days
        end
      end

      if stripe_plans.has_more
        Tang::ImportPlansJob.perform_now(stripe_plans.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_plans_job.rb
tang-0.2.1 app/jobs/tang/import_plans_job.rb
tang-0.2.0 app/jobs/tang/import_plans_job.rb
tang-0.1.0 app/jobs/tang/import_plans_job.rb
tang-0.0.9 app/jobs/tang/import_plans_job.rb
tang-0.0.8 app/jobs/tang/import_plans_job.rb