Class: Unit::RecurringPayment::ListRecurringPaymentParams

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/recurring_payment/list_recurring_payment_params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(limit = RECURRING_PAYMENT_LIMIT, offset = RECURRING_PAYMENT_OFFSET, account_id = nil, customer_id = nil, status = nil, type = nil, from_start_time = nil, to_start_time = nil, from_end_time = nil, to_end_time = nil, sort = nil) ⇒ ListRecurringPaymentParams

Returns a new instance of ListRecurringPaymentParams.

Parameters:

  • limit (Integer) (defaults to: RECURRING_PAYMENT_LIMIT)
    • optional

  • offset (Integer) (defaults to: RECURRING_PAYMENT_OFFSET)
    • optional

  • account_id (String) (defaults to: nil)
    • optional

  • customer_id (String) (defaults to: nil)
    • optional

  • status (Array) (defaults to: nil)
    • optional

  • type (Array) (defaults to: nil)
    • optional

  • from_start_time (String) (defaults to: nil)
    • optional

  • to_start_time (String) (defaults to: nil)
    • optional

  • from_end_time (String) (defaults to: nil)
    • optional

  • to_end_time (String) (defaults to: nil)
    • optional

  • sort (String) (defaults to: nil)
    • optional



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 22

def initialize(limit = RECURRING_PAYMENT_LIMIT, offset = RECURRING_PAYMENT_OFFSET,  = nil, customer_id = nil, status = nil, type = nil,
               from_start_time = nil, to_start_time = nil, from_end_time = nil, to_end_time = nil, sort = nil)
  @limit = limit
  @offset = offset
  @account_id = 
  @customer_id = customer_id
  @status = status
  @type = type
  @from_start_date = from_start_time
  @to_start_date = to_start_time
  @from_end_date = from_end_time
  @to_end_date = to_end_time
  @sort = sort
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



8
9
10
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 8

def 
  @account_id
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.



8
9
10
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 8

def customer_id
  @customer_id
end

#from_end_timeObject (readonly)

Returns the value of attribute from_end_time.



8
9
10
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 8

def from_end_time
  @from_end_time
end

#from_start_timeObject (readonly)

Returns the value of attribute from_start_time.



8
9
10
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 8

def from_start_time
  @from_start_time
end

#limitObject (readonly)

Returns the value of attribute limit.



8
9
10
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 8

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



8
9
10
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 8

def offset
  @offset
end

#sortObject (readonly)

Returns the value of attribute sort.



8
9
10
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 8

def sort
  @sort
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 8

def status
  @status
end

#to_end_timeObject (readonly)

Returns the value of attribute to_end_time.



8
9
10
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 8

def to_end_time
  @to_end_time
end

#to_start_timeObject (readonly)

Returns the value of attribute to_start_time.



8
9
10
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 8

def to_start_time
  @to_start_time
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 8

def type
  @type
end

Instance Method Details

#to_hashObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/unit/models/recurring_payment/list_recurring_payment_params.rb', line 37

def to_hash
  payload = {
    "page[limit]": limit,
    "page[offset]": offset,
    "filter[accountId]": ,
    "filter[customerId]": customer_id,
    "filter[fromStartTime]": from_start_time,
    "filter[toStartTime]": to_start_time,
    "filter[fromEndTime]": from_end_time,
    "filter[toEndTime]": to_end_time,
    "sort": sort
  }
  filters = %i[status type]
  filters.each do |filter|
    values = send(filter)
    values&.each_with_index&.map do |val, index|
      params.merge!({ "filter[#{filter}][#{index}]": val })
    end
  end
  payload.compact!
end