namespace :products do

desc "Create products in the database that come from stripe"
task sync: :environment do
  SaasPayments::ProductsService.new.sync
end

desc "Digitize a product by toggling the shippable flag"
task :digitize, [:product, :shippable] => :environment do |t, args|
  product = args.product
  shippable = args.shippable.to_s == 'true'

  if !['true', 'false'].include? args.shippable.to_s
    puts "Shippable must be a boolean"
    next
  end

  success = SaasPayments::ProductsService.new.shippable product, shippable
  puts "Could not digitize product: #{args.product}" unless success
end

end