Class: MistApi::SiteZoneOccupancyAlert

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/site_zone_occupancy_alert.rb

Overview

Zone Occupancy alert site settings

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(email_notifiers = SKIP, enabled = false, threshold = 5) ⇒ SiteZoneOccupancyAlert

Returns a new instance of SiteZoneOccupancyAlert.



50
51
52
53
54
# File 'lib/mist_api/models/site_zone_occupancy_alert.rb', line 50

def initialize(email_notifiers = SKIP, enabled = false, threshold = 5)
  @email_notifiers = email_notifiers unless email_notifiers == SKIP
  @enabled = enabled unless enabled == SKIP
  @threshold = threshold unless threshold == SKIP
end

Instance Attribute Details

#email_notifiersArray[String]

List of email addresses to send email notifications when the alert threshold is reached

Returns:

  • (Array[String])


15
16
17
# File 'lib/mist_api/models/site_zone_occupancy_alert.rb', line 15

def email_notifiers
  @email_notifiers
end

#enabledTrueClass | FalseClass

Indicate whether zone occupancy alert is enabled for the site

Returns:

  • (TrueClass | FalseClass)


19
20
21
# File 'lib/mist_api/models/site_zone_occupancy_alert.rb', line 19

def enabled
  @enabled
end

#thresholdInteger

Sending zone-occupancy-alert webhook message only if a zone stays non-compliant (i.e. actual occupancy > occupancy_limit) for a minimum duration specified in the threshold, in minutes

Returns:

  • (Integer)


25
26
27
# File 'lib/mist_api/models/site_zone_occupancy_alert.rb', line 25

def threshold
  @threshold
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/mist_api/models/site_zone_occupancy_alert.rb', line 57

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  email_notifiers =
    hash.key?('email_notifiers') ? hash['email_notifiers'] : SKIP
  enabled = hash['enabled'] ||= false
  threshold = hash['threshold'] ||= 5

  # Create object from extracted values.
  SiteZoneOccupancyAlert.new(email_notifiers,
                             enabled,
                             threshold)
end

.namesObject

A mapping from model property names to API property names.



28
29
30
31
32
33
34
# File 'lib/mist_api/models/site_zone_occupancy_alert.rb', line 28

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['email_notifiers'] = 'email_notifiers'
  @_hash['enabled'] = 'enabled'
  @_hash['threshold'] = 'threshold'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
# File 'lib/mist_api/models/site_zone_occupancy_alert.rb', line 46

def self.nullables
  []
end

.optionalsObject

An array for optional fields



37
38
39
40
41
42
43
# File 'lib/mist_api/models/site_zone_occupancy_alert.rb', line 37

def self.optionals
  %w[
    email_notifiers
    enabled
    threshold
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



80
81
82
83
84
# File 'lib/mist_api/models/site_zone_occupancy_alert.rb', line 80

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} email_notifiers: #{@email_notifiers.inspect}, enabled: #{@enabled.inspect},"\
  " threshold: #{@threshold.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



73
74
75
76
77
# File 'lib/mist_api/models/site_zone_occupancy_alert.rb', line 73

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} email_notifiers: #{@email_notifiers}, enabled: #{@enabled}, threshold:"\
  " #{@threshold}>"
end