Class: JPush::PushResult

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePushResult

Returns a new instance of PushResult.


6
7
8
# File 'lib/jpush/model/push_result.rb', line 6

def initialize
  @isok=false
end

Instance Attribute Details

#isokObject

Returns the value of attribute isok


5
6
7
# File 'lib/jpush/model/push_result.rb', line 5

def isok
  @isok
end

#msg_idObject

Returns the value of attribute msg_id


5
6
7
# File 'lib/jpush/model/push_result.rb', line 5

def msg_id
  @msg_id
end

#sendnoObject

Returns the value of attribute sendno


5
6
7
# File 'lib/jpush/model/push_result.rb', line 5

def sendno
  @sendno
end

Instance Method Details

#fromResponse(wrapper) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jpush/model/push_result.rb', line 9

def fromResponse(wrapper)
  if wrapper.code != 200
    logger = Logger.new(STDOUT)
    logger.error('Error response from JPush server. Should review and fix it. ')
    logger.info("HTTP Status: #{wrapper.code.to_s}")
    logger.info("Error Message: #{wrapper.error.to_s}")
    raise JPush::ApiConnectionException.new(wrapper)
  end
  content = wrapper.getResponseContent
  hash = JSON.parse(content)
  @sendno = hash['sendno']
  @msg_id = hash['msg_id']
  @isok=true
  return self
end

#toJSONObject


25
26
27
28
29
30
# File 'lib/jpush/model/push_result.rb', line 25

def toJSON
  array={}
  array['sendno'] = @sendno
  array['msg_id'] = @msg_id
  return array.to_json
end