Class: MistApi::Beacon

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

Overview

Beacon

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(created_time = SKIP, eddystone_instance = SKIP, eddystone_namespace = SKIP, eddystone_url = SKIP, for_site = SKIP, ibeacon_major = SKIP, ibeacon_minor = SKIP, ibeacon_uuid = SKIP, id = SKIP, mac = SKIP, map_id = SKIP, modified_time = SKIP, name = SKIP, org_id = SKIP, power = -12,, site_id = SKIP, type = BeaconTypeEnum::EDDYSTONEUID, x = SKIP, y = SKIP, additional_properties = nil) ⇒ Beacon

Returns a new instance of Beacon.



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/mist_api/models/beacon.rb', line 148

def initialize(created_time = SKIP, eddystone_instance = SKIP,
               eddystone_namespace = SKIP, eddystone_url = SKIP,
               for_site = SKIP, ibeacon_major = SKIP, ibeacon_minor = SKIP,
               ibeacon_uuid = SKIP, id = SKIP, mac = SKIP, map_id = SKIP,
               modified_time = SKIP, name = SKIP, org_id = SKIP,
               power = -12, site_id = SKIP,
               type = BeaconTypeEnum::EDDYSTONEUID, x = SKIP, y = SKIP,
               additional_properties = nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @created_time = created_time unless created_time == SKIP
  @eddystone_instance = eddystone_instance unless eddystone_instance == SKIP
  @eddystone_namespace = eddystone_namespace unless eddystone_namespace == SKIP
  @eddystone_url = eddystone_url unless eddystone_url == SKIP
  @for_site = for_site unless for_site == SKIP
  @ibeacon_major = ibeacon_major unless ibeacon_major == SKIP
  @ibeacon_minor = ibeacon_minor unless ibeacon_minor == SKIP
  @ibeacon_uuid = ibeacon_uuid unless ibeacon_uuid == SKIP
  @id = id unless id == SKIP
  @mac = mac unless mac == SKIP
  @map_id = map_id unless map_id == SKIP
  @modified_time = modified_time unless modified_time == SKIP
  @name = name unless name == SKIP
  @org_id = org_id unless org_id == SKIP
  @power = power unless power == SKIP
  @site_id = site_id unless site_id == SKIP
  @type = type unless type == SKIP
  @x = x unless x == SKIP
  @y = y unless y == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#created_timeFloat

When the object has been created, in epoch

Returns:

  • (Float)


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

def created_time
  @created_time
end

#eddystone_instanceString

Eddystone-UID instance (6 bytes) in hexstring format

Returns:

  • (String)


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

def eddystone_instance
  @eddystone_instance
end

#eddystone_namespaceString

Eddystone-UID namespace (10 bytes) in hexstring format

Returns:

  • (String)


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

def eddystone_namespace
  @eddystone_namespace
end

#eddystone_urlString

Eddystone-URL url

Returns:

  • (String)


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

def eddystone_url
  @eddystone_url
end

#for_siteTrueClass | FalseClass

Eddystone-URL url

Returns:

  • (TrueClass | FalseClass)


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

def for_site
  @for_site
end

#ibeacon_majorInteger

Major number for iBeacon

Returns:

  • (Integer)


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

def ibeacon_major
  @ibeacon_major
end

#ibeacon_minorInteger

Minor number for iBeacon

Returns:

  • (Integer)


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

def ibeacon_minor
  @ibeacon_minor
end

#ibeacon_uuidUUID | String

Minor number for iBeacon

Returns:

  • (UUID | String)


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

def ibeacon_uuid
  @ibeacon_uuid
end

#idUUID | String

Unique ID of the object instance in the Mist Organization

Returns:

  • (UUID | String)


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

def id
  @id
end

#macString

Optional, MAC of the beacon, currently used only to identify battery voltage

Returns:

  • (String)


51
52
53
# File 'lib/mist_api/models/beacon.rb', line 51

def mac
  @mac
end

#map_idUUID | String

Map where the device belongs to

Returns:

  • (UUID | String)


55
56
57
# File 'lib/mist_api/models/beacon.rb', line 55

def map_id
  @map_id
end

#modified_timeFloat

When the object has been modified for the last time, in epoch

Returns:

  • (Float)


59
60
61
# File 'lib/mist_api/models/beacon.rb', line 59

def modified_time
  @modified_time
end

#nameString

Name / label of the device

Returns:

  • (String)


63
64
65
# File 'lib/mist_api/models/beacon.rb', line 63

def name
  @name
end

#org_idUUID | String

Name / label of the device

Returns:

  • (UUID | String)


67
68
69
# File 'lib/mist_api/models/beacon.rb', line 67

def org_id
  @org_id
end

#powerInteger

In dBm

Returns:

  • (Integer)


71
72
73
# File 'lib/mist_api/models/beacon.rb', line 71

def power
  @power
end

#site_idUUID | String

In dBm

Returns:

  • (UUID | String)


75
76
77
# File 'lib/mist_api/models/beacon.rb', line 75

def site_id
  @site_id
end

#typeBeaconTypeEnum

enum: ‘eddystone-uid`, `eddystone-url`, `ibeacon`

Returns:



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

def type
  @type
end

#xFloat

X in pixel

Returns:

  • (Float)


83
84
85
# File 'lib/mist_api/models/beacon.rb', line 83

def x
  @x
end

#yFloat

Y in pixel

Returns:

  • (Float)


87
88
89
# File 'lib/mist_api/models/beacon.rb', line 87

def y
  @y
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/mist_api/models/beacon.rb', line 182

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  created_time = hash.key?('created_time') ? hash['created_time'] : SKIP
  eddystone_instance =
    hash.key?('eddystone_instance') ? hash['eddystone_instance'] : SKIP
  eddystone_namespace =
    hash.key?('eddystone_namespace') ? hash['eddystone_namespace'] : SKIP
  eddystone_url = hash.key?('eddystone_url') ? hash['eddystone_url'] : SKIP
  for_site = hash.key?('for_site') ? hash['for_site'] : SKIP
  ibeacon_major = hash.key?('ibeacon_major') ? hash['ibeacon_major'] : SKIP
  ibeacon_minor = hash.key?('ibeacon_minor') ? hash['ibeacon_minor'] : SKIP
  ibeacon_uuid = hash.key?('ibeacon_uuid') ? hash['ibeacon_uuid'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  mac = hash.key?('mac') ? hash['mac'] : SKIP
  map_id = hash.key?('map_id') ? hash['map_id'] : SKIP
  modified_time = hash.key?('modified_time') ? hash['modified_time'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  org_id = hash.key?('org_id') ? hash['org_id'] : SKIP
  power = hash['power'] ||= -12
  site_id = hash.key?('site_id') ? hash['site_id'] : SKIP
  type = hash['type'] ||= BeaconTypeEnum::EDDYSTONEUID
  x = hash.key?('x') ? hash['x'] : SKIP
  y = hash.key?('y') ? hash['y'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  Beacon.new(created_time,
             eddystone_instance,
             eddystone_namespace,
             eddystone_url,
             for_site,
             ibeacon_major,
             ibeacon_minor,
             ibeacon_uuid,
             id,
             mac,
             map_id,
             modified_time,
             name,
             org_id,
             power,
             site_id,
             type,
             x,
             y,
             additional_properties)
end

.namesObject

A mapping from model property names to API property names.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/mist_api/models/beacon.rb', line 90

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['created_time'] = 'created_time'
  @_hash['eddystone_instance'] = 'eddystone_instance'
  @_hash['eddystone_namespace'] = 'eddystone_namespace'
  @_hash['eddystone_url'] = 'eddystone_url'
  @_hash['for_site'] = 'for_site'
  @_hash['ibeacon_major'] = 'ibeacon_major'
  @_hash['ibeacon_minor'] = 'ibeacon_minor'
  @_hash['ibeacon_uuid'] = 'ibeacon_uuid'
  @_hash['id'] = 'id'
  @_hash['mac'] = 'mac'
  @_hash['map_id'] = 'map_id'
  @_hash['modified_time'] = 'modified_time'
  @_hash['name'] = 'name'
  @_hash['org_id'] = 'org_id'
  @_hash['power'] = 'power'
  @_hash['site_id'] = 'site_id'
  @_hash['type'] = 'type'
  @_hash['x'] = 'x'
  @_hash['y'] = 'y'
  @_hash
end

.nullablesObject

An array for nullable fields



140
141
142
143
144
145
146
# File 'lib/mist_api/models/beacon.rb', line 140

def self.nullables
  %w[
    ibeacon_major
    ibeacon_minor
    ibeacon_uuid
  ]
end

.optionalsObject

An array for optional fields



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/mist_api/models/beacon.rb', line 115

def self.optionals
  %w[
    created_time
    eddystone_instance
    eddystone_namespace
    eddystone_url
    for_site
    ibeacon_major
    ibeacon_minor
    ibeacon_uuid
    id
    mac
    map_id
    modified_time
    name
    org_id
    power
    site_id
    type
    x
    y
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/mist_api/models/beacon.rb', line 251

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} created_time: #{@created_time.inspect}, eddystone_instance:"\
  " #{@eddystone_instance.inspect}, eddystone_namespace: #{@eddystone_namespace.inspect},"\
  " eddystone_url: #{@eddystone_url.inspect}, for_site: #{@for_site.inspect}, ibeacon_major:"\
  " #{@ibeacon_major.inspect}, ibeacon_minor: #{@ibeacon_minor.inspect}, ibeacon_uuid:"\
  " #{@ibeacon_uuid.inspect}, id: #{@id.inspect}, mac: #{@mac.inspect}, map_id:"\
  " #{@map_id.inspect}, modified_time: #{@modified_time.inspect}, name: #{@name.inspect},"\
  " org_id: #{@org_id.inspect}, power: #{@power.inspect}, site_id: #{@site_id.inspect}, type:"\
  " #{@type.inspect}, x: #{@x.inspect}, y: #{@y.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



239
240
241
242
243
244
245
246
247
248
# File 'lib/mist_api/models/beacon.rb', line 239

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} created_time: #{@created_time}, eddystone_instance: #{@eddystone_instance},"\
  " eddystone_namespace: #{@eddystone_namespace}, eddystone_url: #{@eddystone_url}, for_site:"\
  " #{@for_site}, ibeacon_major: #{@ibeacon_major}, ibeacon_minor: #{@ibeacon_minor},"\
  " ibeacon_uuid: #{@ibeacon_uuid}, id: #{@id}, mac: #{@mac}, map_id: #{@map_id},"\
  " modified_time: #{@modified_time}, name: #{@name}, org_id: #{@org_id}, power: #{@power},"\
  " site_id: #{@site_id}, type: #{@type}, x: #{@x}, y: #{@y}, additional_properties:"\
  " #{@additional_properties}>"
end