Class: MistApi::WebhookZoneEvent

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

Overview

WebhookZoneEvent Model.

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(map_id = nil, site_id = nil, timestamp = nil, trigger = nil, type = nil, zone_id = nil, asset_id = SKIP, id = SKIP, mac = SKIP, name = SKIP) ⇒ WebhookZoneEvent

Returns a new instance of WebhookZoneEvent.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/mist_api/models/webhook_zone_event.rb', line 83

def initialize(map_id = nil, site_id = nil, timestamp = nil, trigger = nil,
               type = nil, zone_id = nil, asset_id = SKIP, id = SKIP,
               mac = SKIP, name = SKIP)
  @asset_id = asset_id unless asset_id == SKIP
  @id = id unless id == SKIP
  @mac = mac unless mac == SKIP
  @map_id = map_id
  @name = name unless name == SKIP
  @site_id = site_id
  @timestamp = timestamp
  @trigger = trigger
  @type = type
  @zone_id = zone_id
end

Instance Attribute Details

#asset_idUUID | String

Only if ‘type`==`asset`. UUID of named asset

Returns:

  • (UUID | String)


14
15
16
# File 'lib/mist_api/models/webhook_zone_event.rb', line 14

def asset_id
  @asset_id
end

#idUUID | String

Only if ‘type`==`sdk`. UUID of the SDK Client

Returns:

  • (UUID | String)


18
19
20
# File 'lib/mist_api/models/webhook_zone_event.rb', line 18

def id
  @id
end

#macString

MAC address of Wi-Fi client, SDK Client or Asset

Returns:

  • (String)


22
23
24
# File 'lib/mist_api/models/webhook_zone_event.rb', line 22

def mac
  @mac
end

#map_idUUID | String

Map id

Returns:

  • (UUID | String)


26
27
28
# File 'lib/mist_api/models/webhook_zone_event.rb', line 26

def map_id
  @map_id
end

#nameString

Name of the client, may be empty

Returns:

  • (String)


30
31
32
# File 'lib/mist_api/models/webhook_zone_event.rb', line 30

def name
  @name
end

#site_idUUID | String

Name of the client, may be empty

Returns:

  • (UUID | String)


34
35
36
# File 'lib/mist_api/models/webhook_zone_event.rb', line 34

def site_id
  @site_id
end

#timestampFloat

Epoch (seconds)

Returns:

  • (Float)


38
39
40
# File 'lib/mist_api/models/webhook_zone_event.rb', line 38

def timestamp
  @timestamp
end

#triggerWebhookZoneEventTriggerEnum

enum: ‘enter`, `exit`



42
43
44
# File 'lib/mist_api/models/webhook_zone_event.rb', line 42

def trigger
  @trigger
end

#typeWebhookZoneEventTypeEnum

Type of client. enum: ‘asset` (BLE Tag), `sdk`, `wifi`



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

def type
  @type
end

#zone_idUUID | String

Zone id

Returns:

  • (UUID | String)


50
51
52
# File 'lib/mist_api/models/webhook_zone_event.rb', line 50

def zone_id
  @zone_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/mist_api/models/webhook_zone_event.rb', line 99

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  map_id = hash.key?('map_id') ? hash['map_id'] : nil
  site_id = hash.key?('site_id') ? hash['site_id'] : nil
  timestamp = hash.key?('timestamp') ? hash['timestamp'] : nil
  trigger = hash.key?('trigger') ? hash['trigger'] : nil
  type = hash.key?('type') ? hash['type'] : nil
  zone_id = hash.key?('zone_id') ? hash['zone_id'] : nil
  asset_id = hash.key?('asset_id') ? hash['asset_id'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  mac = hash.key?('mac') ? hash['mac'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP

  # Create object from extracted values.
  WebhookZoneEvent.new(map_id,
                       site_id,
                       timestamp,
                       trigger,
                       type,
                       zone_id,
                       asset_id,
                       id,
                       mac,
                       name)
end

.namesObject

A mapping from model property names to API property names.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/mist_api/models/webhook_zone_event.rb', line 53

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['asset_id'] = 'asset_id'
  @_hash['id'] = 'id'
  @_hash['mac'] = 'mac'
  @_hash['map_id'] = 'map_id'
  @_hash['name'] = 'name'
  @_hash['site_id'] = 'site_id'
  @_hash['timestamp'] = 'timestamp'
  @_hash['trigger'] = 'trigger'
  @_hash['type'] = 'type'
  @_hash['zone_id'] = 'zone_id'
  @_hash
end

.nullablesObject

An array for nullable fields



79
80
81
# File 'lib/mist_api/models/webhook_zone_event.rb', line 79

def self.nullables
  []
end

.optionalsObject

An array for optional fields



69
70
71
72
73
74
75
76
# File 'lib/mist_api/models/webhook_zone_event.rb', line 69

def self.optionals
  %w[
    asset_id
    id
    mac
    name
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/mist_api/models/webhook_zone_event.rb', line 129

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.map_id,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.site_id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.timestamp,
                              ->(val) { val.instance_of? Float }) and
        APIHelper.valid_type?(value.trigger,
                              ->(val) { WebhookZoneEventTriggerEnum.validate(val) }) and
        APIHelper.valid_type?(value.type,
                              ->(val) { WebhookZoneEventTypeEnum.validate(val) }) and
        APIHelper.valid_type?(value.zone_id,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['map_id'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['site_id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['timestamp'],
                            ->(val) { val.instance_of? Float }) and
      APIHelper.valid_type?(value['trigger'],
                            ->(val) { WebhookZoneEventTriggerEnum.validate(val) }) and
      APIHelper.valid_type?(value['type'],
                            ->(val) { WebhookZoneEventTypeEnum.validate(val) }) and
      APIHelper.valid_type?(value['zone_id'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



174
175
176
177
178
179
180
# File 'lib/mist_api/models/webhook_zone_event.rb', line 174

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} asset_id: #{@asset_id.inspect}, id: #{@id.inspect}, mac: #{@mac.inspect},"\
  " map_id: #{@map_id.inspect}, name: #{@name.inspect}, site_id: #{@site_id.inspect},"\
  " timestamp: #{@timestamp.inspect}, trigger: #{@trigger.inspect}, type: #{@type.inspect},"\
  " zone_id: #{@zone_id.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



166
167
168
169
170
171
# File 'lib/mist_api/models/webhook_zone_event.rb', line 166

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} asset_id: #{@asset_id}, id: #{@id}, mac: #{@mac}, map_id: #{@map_id}, name:"\
  " #{@name}, site_id: #{@site_id}, timestamp: #{@timestamp}, trigger: #{@trigger}, type:"\
  " #{@type}, zone_id: #{@zone_id}>"
end