Class: Report::ShippingRates::ShippingRatesCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Report::ShippingRates::ShippingRatesCommand
- Defined in:
- app/services/report/shipping_rates/shipping_rates_command.rb
Overview
Service object: shipping rates command.
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
8 9 10 11 12 |
# File 'app/services/report/shipping_rates/shipping_rates_command.rb', line 8 def execute return unless valid? @result = Report::ShippingRates::ShippingRates.result(attributes) end |
#success? ⇒ Boolean
29 30 31 |
# File 'app/services/report/shipping_rates/shipping_rates_command.rb', line 29 def success? valid? && @result.success? end |
#to_csv ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/report/shipping_rates/shipping_rates_command.rb', line 14 def to_csv return unless valid? @result = Report::ShippingRates::ShippingRates.result(attributes) return if @result.shipping_rates.blank? attributes = @result.shipping_rates.first.keys CSV.generate(headers: true) do |csv| csv << attributes @result.shipping_rates.each do |r| csv << r end end end |