Class: Unit::Authorization::ListRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/authorization/list_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(limit = AUTHORIZATION_LIMIT, offset = AUTHORIZATION_OFFSET, account_id = nil, customer_id = nil, card_id = nil, since = nil, until_ = nil, include_non_authorized = nil, status = nil, merchant_category_code = nil, from_amount = nil, to_amount = nil, sort = nil) ⇒ ListRequest

Returns a new instance of ListRequest.

Parameters:

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

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

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

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

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

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

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

  • include_non_authorized (Boolean) (defaults to: nil)
    • optional

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

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

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

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

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



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/unit/models/authorization/list_request.rb', line 25

def initialize(limit = AUTHORIZATION_LIMIT, offset = AUTHORIZATION_OFFSET,  = nil, customer_id = nil, card_id = nil,
               since = nil, until_ = nil, include_non_authorized = nil, status = nil, merchant_category_code = nil,
               from_amount = nil, to_amount = nil, sort = nil)
  @limit = limit
  @offset = offset
  @account_id = 
  @customer_id = customer_id
  @card_id = card_id
  @since = since
  @until_ = until_
  @include_non_authorized = include_non_authorized
  @status = status
  @merchant_category_code = merchant_category_code
  @from_amount = from_amount
  @to_amount = to_amount
  @sort = sort
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def 
  @account_id
end

#card_idObject (readonly)

Returns the value of attribute card_id.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def card_id
  @card_id
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def customer_id
  @customer_id
end

#from_amountObject (readonly)

Returns the value of attribute from_amount.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def from_amount
  @from_amount
end

#include_non_authorizedObject (readonly)

Returns the value of attribute include_non_authorized.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def include_non_authorized
  @include_non_authorized
end

#limitObject (readonly)

Returns the value of attribute limit.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def limit
  @limit
end

#merchant_category_codeObject (readonly)

Returns the value of attribute merchant_category_code.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def merchant_category_code
  @merchant_category_code
end

#offsetObject (readonly)

Returns the value of attribute offset.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def offset
  @offset
end

#sinceObject (readonly)

Returns the value of attribute since.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def since
  @since
end

#sortObject (readonly)

Returns the value of attribute sort.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def sort
  @sort
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def status
  @status
end

#to_amountObject (readonly)

Returns the value of attribute to_amount.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def to_amount
  @to_amount
end

#until_Object (readonly)

Returns the value of attribute until_.



8
9
10
# File 'lib/unit/models/authorization/list_request.rb', line 8

def until_
  @until_
end

Instance Method Details

#to_hashObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/unit/models/authorization/list_request.rb', line 43

def to_hash
  payload = {
    "page[limit]": limit,
    "page[offset]": offset,
    "filter[accountId]": ,
    "filter[customerId]": customer_id,
    "filter[cardId]": card_id,
    "filter[since]": since,
    "filter[until]": until_,
    "filter[includeNonAuthorized]": include_non_authorized,
    "filter[fromAmount]": from_amount,
    "filter[toAmount]": to_amount,
    sort: sort
  }
  merchant_category_code&.each_with_index&.map do |val, index|
    params.merge!({ "filter[merchantCategoryCode][#{index}]": val })
  end
  status&.each_with_index&.map do |val, index|
    params.merge!({ "filter[status][#{index}]": val })
  end
  payload.compact
end