class ShipitAPI::Quotation
Public Class Methods
get_prices(opts = {})
click to toggle source
# File lib/shipit_api/quotation.rb, line 3 def self.get_prices(opts = {}) new(opts).get_prices end
new(opts = {})
click to toggle source
# File lib/shipit_api/quotation.rb, line 7 def initialize(opts = {}) @opts = opts @api_call = ShipitAPI::Session.connection('prices', 3) build! end
Public Instance Methods
build!()
click to toggle source
# File lib/shipit_api/quotation.rb, line 32 def build! @opts.each do |k,v| singleton_class.send(:attr_accessor, k) instance_variable_set("@#{k}", v) end end
get_commune()
click to toggle source
# File lib/shipit_api/quotation.rb, line 24 def get_commune ShipitAPI::Commune.find_by_name({ name: @opts[:commune_name] }) end
get_prices()
click to toggle source
# File lib/shipit_api/quotation.rb, line 13 def get_prices if !@opts[:commune_name].nil? commune = get_commune @opts.merge!({ to_commune_id: commune[:id]}) end package = { package: @opts } response = @api_call.post('', package.to_json) JSON.parse(response.body, symbolize_names: true) end
quotaiton_attrs()
click to toggle source
# File lib/shipit_api/quotation.rb, line 28 def quotaiton_attrs { width: 10, length: 10, height: 10, weight: 1, destinty: 'Domicilio' } end