Class: DeviceCloud::PushNotification

Inherits:
Object
  • Object
show all
Defined in:
lib/device_cloud/push_notification.rb

Defined Under Namespace

Classes: AlertNotification, BaseNotification, DataNotification, EventNotification, Message

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_body) ⇒ PushNotification

Returns a new instance of PushNotification.



5
6
7
# File 'lib/device_cloud/push_notification.rb', line 5

def initialize(response_body)
  @messages = DeviceCloud::PushNotification::Message.parse_raw_messages(response_body)
end

Instance Attribute Details

#messagesObject (readonly)

Returns the value of attribute messages.



3
4
5
# File 'lib/device_cloud/push_notification.rb', line 3

def messages
  @messages
end

Instance Method Details

#handle_each!Object



9
10
11
12
13
14
15
16
17
# File 'lib/device_cloud/push_notification.rb', line 9

def handle_each!
  messages.each do |message|
    next unless message.valid?

    klass = class_type(message.topic_type)

    message.no_content? ? klass.handle_no_content!(message.parsed_file_data) : klass.handle!(message.parsed_file_data)
  end
end