Class: Unit::Customer::ListCustomerParams

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/customer/list_customer_params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(limit = CUSTOMER_LIST_LIMIT, offset = CUSTOMER_LIST_OFFSET, query = nil, email = nil, tags = nil, status = nil, sort = nil) ⇒ ListCustomerParams

Returns a new instance of ListCustomerParams.

Parameters:

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

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

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

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

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

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

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



17
18
19
20
21
22
23
24
25
26
# File 'lib/unit/models/customer/list_customer_params.rb', line 17

def initialize(limit = CUSTOMER_LIST_LIMIT, offset = CUSTOMER_LIST_OFFSET, query = nil, email = nil, tags = nil, status = nil,
               sort = nil)
  @limit = limit
  @offset = offset
  @query = query
  @email = email
  @tags = tags
  @status = status
  @sort = sort
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



8
9
10
# File 'lib/unit/models/customer/list_customer_params.rb', line 8

def email
  @email
end

#limitObject (readonly)

Returns the value of attribute limit.



8
9
10
# File 'lib/unit/models/customer/list_customer_params.rb', line 8

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



8
9
10
# File 'lib/unit/models/customer/list_customer_params.rb', line 8

def offset
  @offset
end

#queryObject (readonly)

Returns the value of attribute query.



8
9
10
# File 'lib/unit/models/customer/list_customer_params.rb', line 8

def query
  @query
end

#sortObject (readonly)

Returns the value of attribute sort.



8
9
10
# File 'lib/unit/models/customer/list_customer_params.rb', line 8

def sort
  @sort
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/unit/models/customer/list_customer_params.rb', line 8

def status
  @status
end

#tagsObject (readonly)

Returns the value of attribute tags.



8
9
10
# File 'lib/unit/models/customer/list_customer_params.rb', line 8

def tags
  @tags
end

Instance Method Details

#to_hashObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/unit/models/customer/list_customer_params.rb', line 28

def to_hash
  params = { "page[limit]": limit,
             "page[offset]": offset,
             "filter[query]": query,
             "filter[email]": email,
             "filter[tags]": tags,
             "sort": sort }
  status&.each_with_index&.map do |val, index|
    params.merge!({ "filter[status][#{index}]": val })
  end
  params.compact
end