class ApnsGatling::Response
Attributes
headers[RW]
message[R]
Public Class Methods
new(message)
click to toggle source
# File lib/apns_gatling/response.rb, line 9 def initialize(message) @headers = {} @data = '' @message = message @internal_error = nil end
Public Instance Methods
error()
click to toggle source
# File lib/apns_gatling/response.rb, line 32 def error return @internal_error if @internal_error if status != '200' e = {} e.merge!(status: @headers[':status']) if @headers[':status'] e.merge!('apns-id' => @headers['apns-id']) if @headers['apns-id'] data = parse_data e.merge!(reason: data['reason']) if data['reason'] e.merge!(timestamp: data['timestamp']) if data['timestamp'] e end end
error_with(reason)
click to toggle source
# File lib/apns_gatling/response.rb, line 28 def error_with(reason) @internal_error = {reason: reason, 'apns-id': @message.apns_id, status: '0'} end
ok?()
click to toggle source
# File lib/apns_gatling/response.rb, line 20 def ok? status == '200' end
parse_data()
click to toggle source
# File lib/apns_gatling/response.rb, line 24 def parse_data JSON.parse(@data) rescue @data end
status()
click to toggle source
# File lib/apns_gatling/response.rb, line 16 def status @headers[':status'] if @headers end