Class: Kiik::Compensation

Inherits:
Resource show all
Includes:
Rest::GetAll
Defined in:
lib/kiik/compensation.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#created, #errors, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Rest::GetAll

#get_all, included

Methods inherited from Resource

build, class_name, opts, request, url, #valid?

Constructor Details

#initialize(attributes = {}) ⇒ Compensation

Returns a new instance of Compensation.



22
23
24
# File 'lib/kiik/compensation.rb', line 22

def initialize(attributes = {})
  super(attributes)
end

Instance Attribute Details

#aditional_infoObject

Returns the value of attribute aditional_info.



5
6
7
# File 'lib/kiik/compensation.rb', line 5

def aditional_info
  @aditional_info
end

#amountObject

Returns the value of attribute amount.



5
6
7
# File 'lib/kiik/compensation.rb', line 5

def amount
  @amount
end

#charge_idObject

Returns the value of attribute charge_id.



5
6
7
# File 'lib/kiik/compensation.rb', line 5

def charge_id
  @charge_id
end

#compensated_atObject

Returns the value of attribute compensated_at.



5
6
7
# File 'lib/kiik/compensation.rb', line 5

def compensated_at
  @compensated_at
end

#expected_compensation_dateObject

Returns the value of attribute expected_compensation_date.



5
6
7
# File 'lib/kiik/compensation.rb', line 5

def expected_compensation_date
  @expected_compensation_date
end

#history_typeObject

Returns the value of attribute history_type.



5
6
7
# File 'lib/kiik/compensation.rb', line 5

def history_type
  @history_type
end

#received_atObject

Returns the value of attribute received_at.



5
6
7
# File 'lib/kiik/compensation.rb', line 5

def received_at
  @received_at
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/kiik/compensation.rb', line 5

def status
  @status
end

#totalObject

Returns the value of attribute total.



5
6
7
# File 'lib/kiik/compensation.rb', line 5

def total
  @total
end

Class Method Details

.consolidated(customer = nil, start_date = nil, end_date = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kiik/compensation.rb', line 9

def consolidated(customer = nil, start_date = nil, end_date = nil)
  url = customer.nil? ? '' : "#{customer}/"
  url += "consolidated"
  params = []
  params << "start_date=#{start_date.strftime('%Y-%m-%d %H:%M:%S')}" if start_date
  params << "end_date=#{end_date.strftime('%Y-%m-%d %H:%M:%S')}" if end_date
  url += "?#{params.join('&')}" if params.length
  result = request(url, {}, :GET, {})
  raise result if result.kind_of? StandardError
  result.total
end

Instance Method Details

#to_jsonObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/kiik/compensation.rb', line 26

def to_json
  super.merge!(super([
    :status,
    :received_at,
    :history_type,
    :expected_compensation_date,
    :compensated_at,
    :charge_id,
    :amount,
    :aditional_info
  ]))
end