Class: Unit::Account::Credit::ListAccountParams

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/account/credit/list_account_params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(limit = ACCOUNT_LIST_LIMIT, offset = ACCOUNT_LIST_OFFSET, customer_id = nil, tags = nil, status = nil, from_balance = nil, to_balance = nil, include = nil, type = nil) ⇒ ListAccountParams

Returns a new instance of ListAccountParams.

Parameters:

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

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

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

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

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

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

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

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

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



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/unit/models/account/credit/list_account_params.rb', line 21

def initialize(limit = ACCOUNT_LIST_LIMIT, offset = ACCOUNT_LIST_OFFSET, customer_id = nil, tags = nil,
               status = nil, from_balance = nil, to_balance = nil, include = nil, type = nil)
  @limit = limit
  @offset = offset
  @customer_id = customer_id
  @tags = tags
  @status = status
  @from_balance = from_balance
  @to_balance = to_balance
  @include = include
  @type = type
end

Instance Attribute Details

#customer_idObject (readonly)

Returns the value of attribute customer_id.



9
10
11
# File 'lib/unit/models/account/credit/list_account_params.rb', line 9

def customer_id
  @customer_id
end

#from_balanceObject (readonly)

Returns the value of attribute from_balance.



9
10
11
# File 'lib/unit/models/account/credit/list_account_params.rb', line 9

def from_balance
  @from_balance
end

#includeObject (readonly)

Returns the value of attribute include.



9
10
11
# File 'lib/unit/models/account/credit/list_account_params.rb', line 9

def include
  @include
end

#limitObject (readonly)

Returns the value of attribute limit.



9
10
11
# File 'lib/unit/models/account/credit/list_account_params.rb', line 9

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



9
10
11
# File 'lib/unit/models/account/credit/list_account_params.rb', line 9

def offset
  @offset
end

#statusObject (readonly)

Returns the value of attribute status.



9
10
11
# File 'lib/unit/models/account/credit/list_account_params.rb', line 9

def status
  @status
end

#tagsObject (readonly)

Returns the value of attribute tags.



9
10
11
# File 'lib/unit/models/account/credit/list_account_params.rb', line 9

def tags
  @tags
end

#to_balanceObject (readonly)

Returns the value of attribute to_balance.



9
10
11
# File 'lib/unit/models/account/credit/list_account_params.rb', line 9

def to_balance
  @to_balance
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/unit/models/account/credit/list_account_params.rb', line 9

def type
  @type
end

Instance Method Details

#to_hashObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/unit/models/account/credit/list_account_params.rb', line 34

def to_hash
  params = { "page[limit]": limit,
             "page[offset]": offset,
             "filter[customerId]": customer_id,
             "filter[tags]": tags,
             "filter[fromBalance]": from_balance,
             "filter[toBalance]": to_balance,
             "filter[type]": type,
             "include": include&.join(",") }
  status&.each_with_index&.map do |val, index|
    params.merge!({ "filter[status][#{index}]": val })
  end
  params.compact
end