Class: Triggers

Inherits:
Base
  • Object
show all
Defined in:
lib/zapix/proxies/triggers.rb

Defined Under Namespace

Classes: NonExistingTrigger

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Base

Instance Method Details

#create(options) ⇒ Object



8
9
10
# File 'lib/zapix/proxies/triggers.rb', line 8

def create(options)
  client.trigger_create(options) unless exists?(options)
end

#delete(*trigger_ids) ⇒ Object



12
13
14
# File 'lib/zapix/proxies/triggers.rb', line 12

def delete(*trigger_ids)
  client.trigger_delete(trigger_ids)
end

#exists?(options) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/zapix/proxies/triggers.rb', line 4

def exists?(options)
  client.trigger_exists(options)
end

#get_id(options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/zapix/proxies/triggers.rb', line 16

def get_id(options)
  result = client.trigger_get({'output' => 'extend',
    'expandExpression' => true})
  id = extract_id(result, options['expression'])
  unless id.nil?
    id
  else
    raise NonExistingTrigger, "Trigger with expression #{options['expression']} not found."
  end
end