Class: Urbanairship::CustomEvents::CustomEventResponse
- Inherits:
-
Object
- Object
- Urbanairship::CustomEvents::CustomEventResponse
- Defined in:
- lib/urbanairship/custom_events/custom_event.rb
Overview
Response to a successful custom event creation.
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.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#format ⇒ Object
String Formatting of the CustomEventResponse.
- #formatted_body ⇒ Object
-
#initialize(body: nil, code: nil) ⇒ CustomEventResponse
constructor
A new instance of CustomEventResponse.
Constructor Details
#initialize(body: nil, code: nil) ⇒ CustomEventResponse
Returns a new instance of CustomEventResponse.
39 40 41 42 43 44 |
# File 'lib/urbanairship/custom_events/custom_event.rb', line 39 def initialize(body: nil, code: nil) @payload = (body.nil? || body.empty?) ? {} : body @ok = payload['ok'] @operation_id = payload['operationId'] @status_code = code end |
Instance Attribute Details
#ok ⇒ Object (readonly)
Returns the value of attribute ok.
37 38 39 |
# File 'lib/urbanairship/custom_events/custom_event.rb', line 37 def ok @ok end |
#operation_id ⇒ Object (readonly)
Returns the value of attribute operation_id.
37 38 39 |
# File 'lib/urbanairship/custom_events/custom_event.rb', line 37 def operation_id @operation_id end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
37 38 39 |
# File 'lib/urbanairship/custom_events/custom_event.rb', line 37 def payload @payload end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
37 38 39 |
# File 'lib/urbanairship/custom_events/custom_event.rb', line 37 def status_code @status_code end |
Instance Method Details
#format ⇒ Object
String Formatting of the CustomEventResponse
49 50 51 |
# File 'lib/urbanairship/custom_events/custom_event.rb', line 49 def format "Received [#{status_code}] response code.\nBody:\n#{formatted_body}" end |
#formatted_body ⇒ Object
53 54 55 56 57 |
# File 'lib/urbanairship/custom_events/custom_event.rb', line 53 def formatted_body payload .map { |key, value| "#{key}:\t#{value.to_s || 'None'}" } .join("\n") end |