Class: Urbanairship::Push::PushResponse
- Inherits:
-
Object
- Object
- Urbanairship::Push::PushResponse
- Includes:
- Common
- Defined in:
- lib/urbanairship/push/push.rb
Overview
Response to a successful push notification send or schedule.
Constant Summary
Constants included from Common
Instance Attribute Summary collapse
-
#ok ⇒ Object
readonly
Returns the value of attribute ok.
-
#operation_id ⇒ Object
readonly
Returns the value of attribute operation_id.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#push_ids ⇒ Object
readonly
Returns the value of attribute push_ids.
-
#schedule_url ⇒ Object
readonly
Returns the value of attribute schedule_url.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#format ⇒ Object
String Formatting of the PushResponse.
-
#initialize(http_response_body: nil, http_response_code: nil) ⇒ PushResponse
constructor
A new instance of PushResponse.
Methods included from Common
#apid_path, #channel_path, #compact_helper, #create_and_send_path, #custom_events_path, #device_token_path, #experiments_path, #lists_path, #named_users_path, #open_channel_path, #pipelines_path, #push_path, #reports_path, #required, #schedules_path, #segments_path, #tag_lists_path, #try_helper
Constructor Details
#initialize(http_response_body: nil, http_response_code: nil) ⇒ PushResponse
Returns a new instance of PushResponse.
194 195 196 197 198 199 200 201 |
# File 'lib/urbanairship/push/push.rb', line 194 def initialize(http_response_body: nil, http_response_code: nil) @payload = ((http_response_body.nil? || http_response_body.empty?) ? {} : http_response_body) @ok = @payload['ok'] @push_ids = @payload['push_ids'] @schedule_url = try_helper(:first, @payload['schedule_urls']) @operation_id = @payload['operation_id'] @status_code = http_response_code end |
Instance Attribute Details
#ok ⇒ Object (readonly)
Returns the value of attribute ok.
191 192 193 |
# File 'lib/urbanairship/push/push.rb', line 191 def ok @ok end |
#operation_id ⇒ Object (readonly)
Returns the value of attribute operation_id.
191 192 193 |
# File 'lib/urbanairship/push/push.rb', line 191 def operation_id @operation_id end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
191 192 193 |
# File 'lib/urbanairship/push/push.rb', line 191 def payload @payload end |
#push_ids ⇒ Object (readonly)
Returns the value of attribute push_ids.
191 192 193 |
# File 'lib/urbanairship/push/push.rb', line 191 def push_ids @push_ids end |
#schedule_url ⇒ Object (readonly)
Returns the value of attribute schedule_url.
191 192 193 |
# File 'lib/urbanairship/push/push.rb', line 191 def schedule_url @schedule_url end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
191 192 193 |
# File 'lib/urbanairship/push/push.rb', line 191 def status_code @status_code end |
Instance Method Details
#format ⇒ Object
String Formatting of the PushResponse
206 207 208 209 210 211 212 213 |
# File 'lib/urbanairship/push/push.rb', line 206 def format base = "Received [#{@status_code}] response code. \nHeaders: \tBody:\n" payload.each do |key, value| safe_value = value.to_s || 'None' base << "#{key}:\t#{safe_value}\n" end base end |