Class: Io::Flow::V0::Models::PaymentDuty

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PaymentDuty

Returns a new instance of PaymentDuty.



52540
52541
52542
52543
52544
52545
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52540

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:amount], 'PaymentDuty')
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @name = HttpClient::Preconditions.assert_class('name', (x = opts.delete(:name); x.nil? ? "Duty" : x), String)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



52538
52539
52540
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52538

def amount
  @amount
end

#nameObject (readonly)

Returns the value of attribute name.



52538
52539
52540
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52538

def name
  @name
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



52551
52552
52553
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52551

def copy(incoming={})
  PaymentDuty.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



52555
52556
52557
52558
52559
52560
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52555

def to_hash
  {
    :amount => amount.to_f.to_s,
    :name => name
  }
end

#to_jsonObject



52547
52548
52549
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 52547

def to_json
  JSON.dump(to_hash)
end