Class: Mdm::Device

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/mdm/device.rb

Instance Method Summary collapse

Instance Method Details

#notifyObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/mdm/device.rb', line 10

def notify
  apn = Houston::Client.production
  apn.certificate = File.read("#{Rails.root}/certs/push.pem")

  notification = Houston::Notification.new(device: push_token)
  notification.custom_data = {
    mdm: push_magic
  }

  apn.push(notification)
end

#refresh!(data = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/mdm/device.rb', line 22

def refresh!(data = {})
  update!(
    name: data[:DeviceName],
    udid: data[:UDID],
    serial_number: data[:SerialNumber],
    device_model: data[:Model],
    device_model_name: data[:ModelName],
    os_version: data[:OSVersion],
    build_version: data[:BuildVersion],
    imei: data[:IMEI],
    is_roaming: data[:IsRoaming],
    is_supervised: data[:IsSupervised],
    device_capacity: data[:DeviceCapacity],
    available_capacity: data[:AvailableDeviceCapacity]
  )
end