Class: JPush::Message

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Message

Returns a new instance of Message.


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

def initialize(opts  =  {})
  @title = opts[:title]
  @msg_content = opts[:msg_content]
  @content_type = opts[:content_type]
  @extras = opts[:extras]
end

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type


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

def content_type
  @content_type
end

#extrasObject

Returns the value of attribute extras


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

def extras
  @extras
end

#msg_contentObject

Returns the value of attribute msg_content


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

def msg_content
  @msg_content
end

#titleObject

Returns the value of attribute title


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

def title
  @title
end

Class Method Details

.build(opts = {}) ⇒ Object


28
29
30
31
32
33
34
# File 'lib/jpush/model/message.rb', line 28

def self.build(opts = {})
  message = JPush::Message.new(opts)
  if nil == message.msg_content
    raise ArgumentError.new('msgContent should be set')
  end
  return message
end

Instance Method Details

#toJSONObject


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

def toJSON
  array = {}
  if @title != nil then
    array['title'] = @title
  end
  if @msg_content != nil then
    array['msg_content'] = @msg_content
  end
  if @content_type != nil then
    array['content_type'] = @content_type
  end
  if @extras != nil then
    array['extras'] = @extras
  end
  return array
end