Class: Io::Flow::V0::Models::BillingDiscount

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 = {}) ⇒ BillingDiscount

Returns a new instance of BillingDiscount.



32418
32419
32420
32421
32422
32423
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32418

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

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



32416
32417
32418
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32416

def amount
  @amount
end

#descriptionObject (readonly)

Returns the value of attribute description.



32416
32417
32418
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32416

def description
  @description
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



32429
32430
32431
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32429

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

#to_hashObject



32433
32434
32435
32436
32437
32438
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32433

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

#to_jsonObject



32425
32426
32427
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32425

def to_json
  JSON.dump(to_hash)
end