Class: Io::Flow::V0::Models::Shipping
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Shipping
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#discounts ⇒ Object
readonly
Returns the value of attribute discounts.
-
#duty ⇒ Object
readonly
Returns the value of attribute duty.
-
#tax ⇒ Object
readonly
Returns the value of attribute tax.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Shipping
constructor
A new instance of Shipping.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Shipping
Returns a new instance of Shipping.
58471 58472 58473 58474 58475 58476 58477 58478 58479 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58471 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:description, :amount], 'Shipping') @description = HttpClient::Preconditions.assert_class('description', opts.delete(:description), String) @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal) @tax = (x = opts.delete(:tax); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PaymentTax) ? x : ::Io::Flow::V0::Models::PaymentTax.new(x))) @duty = (x = opts.delete(:duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PaymentDuty) ? x : ::Io::Flow::V0::Models::PaymentDuty.new(x))) @discounts = (x = opts.delete(:discounts); x.nil? ? nil : HttpClient::Preconditions.assert_class('discounts', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentDiscount) ? x : ::Io::Flow::V0::Models::PaymentDiscount.new(x)) }) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
58469 58470 58471 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58469 def amount @amount end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
58469 58470 58471 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58469 def description @description end |
#discounts ⇒ Object (readonly)
Returns the value of attribute discounts.
58469 58470 58471 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58469 def discounts @discounts end |
#duty ⇒ Object (readonly)
Returns the value of attribute duty.
58469 58470 58471 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58469 def duty @duty end |
#tax ⇒ Object (readonly)
Returns the value of attribute tax.
58469 58470 58471 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58469 def tax @tax end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
58485 58486 58487 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58485 def copy(incoming={}) Shipping.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
58489 58490 58491 58492 58493 58494 58495 58496 58497 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58489 def to_hash { :description => description, :amount => amount.to_f.to_s, :tax => tax.nil? ? nil : tax.to_hash, :duty => duty.nil? ? nil : duty.to_hash, :discounts => discounts.nil? ? nil : discounts.map { |o| o.to_hash } } end |
#to_json ⇒ Object
58481 58482 58483 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58481 def to_json JSON.dump(to_hash) end |