Class: Unit::Event::ListEventParams

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/event/list_event_params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(limit = EVENT_LIST_LIMIT, offset = EVENT_LIST_OFFSET, type = nil, since = nil, _until = nil) ⇒ ListEventParams

Returns a new instance of ListEventParams.

Parameters:

  • limit (Integer) (defaults to: EVENT_LIST_LIMIT)
  • offset (Integer) (defaults to: EVENT_LIST_OFFSET)
  • type (Array<String>) (defaults to: nil)
    • optional

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

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



15
16
17
18
19
20
21
# File 'lib/unit/models/event/list_event_params.rb', line 15

def initialize(limit = EVENT_LIST_LIMIT, offset = EVENT_LIST_OFFSET, type = nil, since = nil, _until = nil)
  @limit = limit
  @offset = offset
  @type = type
  @since = since
  @_until = _until
end

Instance Attribute Details

#_untilObject (readonly)

Returns the value of attribute _until.



8
9
10
# File 'lib/unit/models/event/list_event_params.rb', line 8

def _until
  @_until
end

#limitObject (readonly)

Returns the value of attribute limit.



8
9
10
# File 'lib/unit/models/event/list_event_params.rb', line 8

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



8
9
10
# File 'lib/unit/models/event/list_event_params.rb', line 8

def offset
  @offset
end

#sinceObject (readonly)

Returns the value of attribute since.



8
9
10
# File 'lib/unit/models/event/list_event_params.rb', line 8

def since
  @since
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/unit/models/event/list_event_params.rb', line 8

def type
  @type
end

Instance Method Details

#to_hashObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/unit/models/event/list_event_params.rb', line 23

def to_hash
  params = {
    "page[limit]": limit,
    "page[offset]": offset,
    "filter[since]": since,
    "filter[until]": _until
  }
  type&.each_with_index&.map do |val, index|
    params.merge!({ "filter[type][#{index}]": val })
  end
  params.compact
end