Class: Unit::Payment::ListPaymentParams

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/payment/list_payment_params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(limit = PAYMENT_LIMIT, offset = PAYMENT_OFFSET, account_id = nil, customer_id = nil, counterparty_account_id = nil, tags = nil, status = nil, type = nil, direction = nil, since = nil, _until = nil, from_amount = nil, to_amount = nil, recurring_payment_id = nil, feature = nil, sort = nil, include = nil) ⇒ ListPaymentParams

Returns a new instance of ListPaymentParams.

Parameters:

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

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

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

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

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

  • tags (Hash) (defaults to: nil)
    • optional

  • status (Array<String>) (defaults to: nil)
    • optional

  • type (Array<String>) (defaults to: nil)
    • optional

  • direction (Array<String>) (defaults to: nil)
    • optional

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

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

  • from_amount (Integer) (defaults to: nil)
    • optional

  • to_amount (Integer) (defaults to: nil)
    • optional

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

  • feature (Array<String>) (defaults to: nil)
    • optional

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

  • include (Array<String>) (defaults to: nil)
    • optional



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/unit/models/payment/list_payment_params.rb', line 28

def initialize(limit = PAYMENT_LIMIT, offset = PAYMENT_OFFSET,  = nil, customer_id = nil,
                = nil, tags = nil, status = nil,
               type = nil, direction = nil, since = nil, _until = nil,
               from_amount = nil, to_amount = nil, recurring_payment_id = nil,
               feature = nil, sort = nil, include = nil)
  @limit = limit
  @offset = offset
  @account_id = 
  @customer_id = customer_id
  @counterparty_account_id = 
  @tags = tags
  @status = status
  @type = type
  @direction = direction
  @since = since
  @until = _until
  @from_amount = from_amount
  @to_amount = to_amount
  @recurring_payment_id = recurring_payment_id
  @feature = feature
  @sort = sort
  @include = include
end

Instance Attribute Details

#_untilObject (readonly)

Returns the value of attribute _until.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def _until
  @_until
end

#account_idObject (readonly)

Returns the value of attribute account_id.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def 
  @account_id
end

#counterparty_account_idObject (readonly)

Returns the value of attribute counterparty_account_id.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def 
  @counterparty_account_id
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def customer_id
  @customer_id
end

#directionObject (readonly)

Returns the value of attribute direction.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def direction
  @direction
end

#featureObject (readonly)

Returns the value of attribute feature.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def feature
  @feature
end

#from_amountObject (readonly)

Returns the value of attribute from_amount.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def from_amount
  @from_amount
end

#includeObject (readonly)

Returns the value of attribute include.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def include
  @include
end

#limitObject (readonly)

Returns the value of attribute limit.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def offset
  @offset
end

#recurring_payment_idObject (readonly)

Returns the value of attribute recurring_payment_id.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def recurring_payment_id
  @recurring_payment_id
end

#sinceObject (readonly)

Returns the value of attribute since.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def since
  @since
end

#sortObject (readonly)

Returns the value of attribute sort.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def sort
  @sort
end

#statusObject (readonly)

Returns the value of attribute status.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def status
  @status
end

#tagsObject (readonly)

Returns the value of attribute tags.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def tags
  @tags
end

#to_amountObject (readonly)

Returns the value of attribute to_amount.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def to_amount
  @to_amount
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/unit/models/payment/list_payment_params.rb', line 9

def type
  @type
end

Instance Method Details

#to_hashObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/unit/models/payment/list_payment_params.rb', line 52

def to_hash
  params = {
    "page[limit]": limit,
    "page[offset]": offset,
    "filter[accountId]": ,
    "filter[customerId]": customer_id,
    "filter[counterpartyAccountId]": ,
    "filter[tags]": tags,
    "filter[since]": since,
    "filter[until]": _until,
    "filter[fromAmount]": from_amount,
    "filter[toAmount]": to_amount,
    "filter[recurringPaymentId]": recurring_payment_id,
    sort: sort,
    include: include&.join(",")
  }
  filters = %i[status type direction feature]
  filters.each do |filter|
    values = send(filter)
    values&.each_with_index&.map do |val, index|
      params.merge!({ "filter[#{filter}][#{index}]": val })
    end
  end
  params.compact
end