Class: JPush::UserResult

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUserResult

Returns a new instance of UserResult.


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

def initialize
  @isok = false
end

Instance Attribute Details

#durationObject

Returns the value of attribute duration


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

def duration
  @duration
end

#isokObject

Returns the value of attribute isok


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

def isok
  @isok
end

#itemsObject

Returns the value of attribute items


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

def items
  @items
end

#startObject

Returns the value of attribute start


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

def start
  @start
end

#time_unitObject

Returns the value of attribute time_unit


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

def time_unit
  @time_unit
end

Instance Method Details

#fromResponse(wrapper) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jpush/model/user_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)
  @time_unit = hash['time_unit']
  @start = hash['start']
  @duration = hash['duration']
  @itmes = hash['items']
  @isok = true
  return self
end

#toJSONObject


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

def toJSON
  array = {}
  array['time_unit'] = @time_unit
  array['start'] = @start
  array['duration'] = @duration
  array['items'] = @items
  return array.to_json
end