Class: Io::Flow::V0::Models::Statement

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

Returns a new instance of Statement.



68688
68689
68690
68691
68692
68693
68694
68695
68696
68697
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 68688

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :account, :ending_balance, :settlement, :attachments, :created_at], 'Statement')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @account = (x = opts.delete(:account); x.is_a?(::Io::Flow::V0::Models::AccountReference) ? x : ::Io::Flow::V0::Models::AccountReference.new(x))
  @ending_balance = HttpClient::Preconditions.assert_class('ending_balance', HttpClient::Helper.to_big_decimal(opts.delete(:ending_balance)), BigDecimal)
  @settlement = (x = opts.delete(:settlement); x.is_a?(::Io::Flow::V0::Models::Settlement) ? x : ::Io::Flow::V0::Models::Settlement.from_json(x))
  @attachments = HttpClient::Preconditions.assert_class('attachments', opts.delete(:attachments), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Attachment) ? x : ::Io::Flow::V0::Models::Attachment.new(x)) }
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



68686
68687
68688
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 68686

def 
  @account
end

#attachmentsObject (readonly)

Returns the value of attribute attachments.



68686
68687
68688
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 68686

def attachments
  @attachments
end

#created_atObject (readonly)

Returns the value of attribute created_at.



68686
68687
68688
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 68686

def created_at
  @created_at
end

#ending_balanceObject (readonly)

Returns the value of attribute ending_balance.



68686
68687
68688
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 68686

def ending_balance
  @ending_balance
end

#idObject (readonly)

Returns the value of attribute id.



68686
68687
68688
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 68686

def id
  @id
end

#settlementObject (readonly)

Returns the value of attribute settlement.



68686
68687
68688
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 68686

def settlement
  @settlement
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



68703
68704
68705
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 68703

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

#to_hashObject



68707
68708
68709
68710
68711
68712
68713
68714
68715
68716
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 68707

def to_hash
  {
    :id => id,
    :account => .to_hash,
    :ending_balance => ending_balance.to_f.to_s,
    :settlement => settlement.to_hash,
    :attachments => attachments.map { |o| o.to_hash },
    :created_at => created_at
  }
end

#to_jsonObject



68699
68700
68701
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 68699

def to_json
  JSON.dump(to_hash)
end