Class: JPush::Notification

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Notification

Returns a new instance of Notification.


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

def initialize(opts = {})
  @alert = opts[:alert]
  @android = opts[:android]
  @ios = opts[:ios]
  @winphone = opts[:winphone]
end

Instance Attribute Details

#alertObject

Returns the value of attribute alert


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

def alert
  @alert
end

#androidObject

Returns the value of attribute android


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

def android
  @android
end

#iosObject

Returns the value of attribute ios


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

def ios
  @ios
end

#winphoneObject

Returns the value of attribute winphone


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

def winphone
  @winphone
end

Class Method Details

.build(opts = {}) ⇒ Object


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

def self.build(opts = {})
  notification=JPush::Notification.new(opts)
  return notification
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/notification.rb', line 11

def toJSON
  array = {}
  if @alert != nil && alert.lstrip.length > 0
    array['alert'] = @alert
  end
  if @android != nil
    array['android'] = @android.toJSON
  end
  if @ios != nil
    array['ios'] = @ios.toJSON
  end
  if @winphone != nil
    array['winphone'] = @winphone.toJSON
  end

  return array
end