Class: JPush::AndroidNotification

Inherits:
Object
  • Object
show all
Defined in:
lib/jpush/model/notification/android_notification.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ AndroidNotification

Returns a new instance of AndroidNotification.


4
5
6
7
8
9
# File 'lib/jpush/model/notification/android_notification.rb', line 4

def initialize(opts = {})
  @alert = opts[:alert]
  @title = opts[:title]
  @builder_id = opts[:builder_id]
  @extras = opts[:extras]
end

Instance Attribute Details

#alertObject

Returns the value of attribute alert


3
4
5
# File 'lib/jpush/model/notification/android_notification.rb', line 3

def alert
  @alert
end

#builder_idObject

Returns the value of attribute builder_id


3
4
5
# File 'lib/jpush/model/notification/android_notification.rb', line 3

def builder_id
  @builder_id
end

#extrasObject

Returns the value of attribute extras


3
4
5
# File 'lib/jpush/model/notification/android_notification.rb', line 3

def extras
  @extras
end

#titleObject

Returns the value of attribute title


3
4
5
# File 'lib/jpush/model/notification/android_notification.rb', line 3

def title
  @title
end

Class Method Details

.build(opts = {}) ⇒ Object


29
30
31
32
33
34
35
# File 'lib/jpush/model/notification/android_notification.rb', line 29

def self.build(opts = {})
  android = JPush::AndroidNotification.new(opts)
  if android.alert == nil
    raise ArgumentError.new('android the alert should be setted')
  end
  return android
end

Instance Method Details

#toJSONObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jpush/model/notification/android_notification.rb', line 11

def toJSON
  array = {}
  if @alert != nil then
    array['alert'] = @alert
  end
  if @title != nil then
    array['title'] = @title
  end
  if @builder_id != nil then
    array['builder_id'] = @builder_id
  end
  if @extras != nil then
    array['extras'] = @extras
  end

  return array
end