Class: Workarea::Listrak::Models::EventForm

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/listrak/models/event_form.rb

Constant Summary collapse

STATUSES =
['Active', 'Blocked']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, status: nil, group_ip: nil, **options) ⇒ EventForm

Returns a new instance of EventForm.



8
9
10
11
12
13
# File 'app/services/workarea/listrak/models/event_form.rb', line 8

def initialize(name:, status: nil, group_ip: nil, **options)
  @name = name
  @status = status.presence_in(STATUSES) || STATUSES.first
  @group_ip = group_ip
  @options = options
end

Instance Attribute Details

#group_ipObject (readonly)

Returns the value of attribute group_ip.



6
7
8
# File 'app/services/workarea/listrak/models/event_form.rb', line 6

def group_ip
  @group_ip
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'app/services/workarea/listrak/models/event_form.rb', line 6

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'app/services/workarea/listrak/models/event_form.rb', line 6

def options
  @options
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'app/services/workarea/listrak/models/event_form.rb', line 6

def status
  @status
end

Instance Method Details

#to_jsonObject



15
16
17
18
19
20
21
# File 'app/services/workarea/listrak/models/event_form.rb', line 15

def to_json
  {
    eventName: name,
    eventGroupId: group_ip,
    status: status
  }.compact.to_json
end