Class: Ruby::Miradore::Device

Inherits:
Request
  • Object
show all
Includes:
HTTParty
Defined in:
lib/ruby/miradore.rb

Overview

Ruby::Miradore::Device class This class is used to perform actions on devices using the API v2 version. Device class implements the following methods to perform actions on devices:

  • lock - Lock the device remotely

  • lostmode - Activates the lost mode actions on cellphone devices (Android, iOS, WindowsPhone) only.

  • reboot - Reboot the device remotely, this action depends on the device OS.

  • wipe - Wipe the device remotely, this action depends on the device OS.

  • location - Retrieve the device location remotely only on mobile devices.

Examples:

Usage example for Ruby::Miradore::Device actions

Miradore::Device.new(subdomain: 'subdomain', auth: 'api_token').lock(id: 1)

Usage example for Ruby::Miradore::Device actions but getting the device first using Request class

Miradore::Request.new(subdomain: 'subdomain', auth: 'api_token').call(id: 1).lock

Instance Attribute Summary

Attributes inherited from Request

#auth, #json, #subdomain

Instance Method Summary collapse

Methods inherited from Request

#all, #as_json, #http_method_v1, #initialize, #transform

Constructor Details

This class inherits a constructor from Ruby::Miradore::Request

Instance Method Details

#activate(args = {}) ⇒ Object



187
188
189
# File 'lib/ruby/miradore.rb', line 187

def activate(args = {})
  http_method(args.merge(method: :post, action: __method__))
end

#call(args = {}) ⇒ Object



211
212
213
# File 'lib/ruby/miradore.rb', line 211

def call(args = {})
  http_method(args)
end

#device_modelObject



199
200
201
# File 'lib/ruby/miradore.rb', line 199

def device_model
  invdevice.marketing_name || invdevice.product_name
end

#device_serial_numberObject



195
196
197
# File 'lib/ruby/miradore.rb', line 195

def device_serial_number
  invdevice.serial_number || invdevice.hardware_serial_number
end

#family(args = {}) ⇒ Object



179
180
181
# File 'lib/ruby/miradore.rb', line 179

def family(args = {})
  http_method(args.merge(method: :put, action: :category))
end

#location(args = {}) ⇒ Object



175
176
177
# File 'lib/ruby/miradore.rb', line 175

def location(args = {})
  http_method(args.merge(method: :get, action: __method__))
end

#lock(args = {}) ⇒ Object



155
156
157
# File 'lib/ruby/miradore.rb', line 155

def lock(args = {})
  http_method(args.merge(method: :post, id: id, action: __method__))
end

#lostmode(args = {}) ⇒ Object



159
160
161
162
163
164
165
# File 'lib/ruby/miradore.rb', line 159

def lostmode(args = {})
  if args.fetch(:enable, false)
    http_method(args.merge(method: :post, id: id, action: __method__, body: Miradore.commands[:mobile][:lostmode]))
  else
    http_method(args.merge(method: :delete, id: id, action: __method__))
  end
end

#model(args = {}) ⇒ Object



183
184
185
# File 'lib/ruby/miradore.rb', line 183

def model(args = {})
  http_method(args.merge(method: :put, action: __method__))
end

#online?Boolean

Returns:

  • (Boolean)


203
204
205
# File 'lib/ruby/miradore.rb', line 203

def online?
  onlinestatus.downcase.to_sym == :active
end

#phone?Boolean

Returns:

  • (Boolean)


207
208
209
# File 'lib/ruby/miradore.rb', line 207

def phone?
  Miradore.phone_types.include?(platform)
end

#reboot(args = {}) ⇒ Object



167
168
169
# File 'lib/ruby/miradore.rb', line 167

def reboot(args = {})
  http_method(args.merge(method: :post, id: id, action: __method__))
end

#retire(args = {}) ⇒ Object



191
192
193
# File 'lib/ruby/miradore.rb', line 191

def retire(args = {})
  http_method(args.merge(method: :delete, id: id, action: nil))
end

#wipe(args = {}) ⇒ Object



171
172
173
# File 'lib/ruby/miradore.rb', line 171

def wipe(args = {})
  http_method(args.merge(method: :post, id: id, action: __method__))
end