Class: JPush::ReceivedsResult

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReceivedsResult

Returns a new instance of ReceivedsResult.


6
7
8
# File 'lib/jpush/model/receiveds_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/receiveds_result.rb', line 5

def isok
  @isok
end

#listObject

Returns the value of attribute list


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

def list
  @list
end

Instance Method Details

#fromResponse(wrapper) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/jpush/model/receiveds_result.rb', line 10

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)
  i = 0
  @list = []
  while i < hash.length
    re = JPush::Receiveds.new
    re.msg_id = hash[i]['msg_id']
    re.ios_apns_sent = hash[i]['ios_apns_sent']
    re.android_received = hash[i]['android_received']
    list.push re
    i = i+1
  end
  @isok = true
  return self
end

#toJSONObject


34
35
36
37
38
39
40
41
42
# File 'lib/jpush/model/receiveds_result.rb', line 34

def toJSON
  array = []
  i = 0
  while i < @list.length
    array.push @list[i].toJSON
    i = i + 1
  end
  return array.to_json
end