Class: ApnsGatling::Response
- Inherits:
-
Object
- Object
- ApnsGatling::Response
- Defined in:
- lib/apns_gatling/response.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
- #ok? ⇒ Boolean
- #parse_data ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
8 9 10 11 |
# File 'lib/apns_gatling/response.rb', line 8 def initialize() @headers = {} @data = '' end |
Instance Attribute Details
#data ⇒ Object
6 7 8 |
# File 'lib/apns_gatling/response.rb', line 6 def data @data end |
#headers ⇒ Object
6 7 8 |
# File 'lib/apns_gatling/response.rb', line 6 def headers @headers end |
Instance Method Details
#error ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/apns_gatling/response.rb', line 25 def 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 |
#ok? ⇒ Boolean
17 18 19 |
# File 'lib/apns_gatling/response.rb', line 17 def ok? status == '200' end |
#parse_data ⇒ Object
21 22 23 |
# File 'lib/apns_gatling/response.rb', line 21 def parse_data JSON.parse(@data) rescue @data end |
#status ⇒ Object
13 14 15 |
# File 'lib/apns_gatling/response.rb', line 13 def status @headers[':status'] if @headers end |