Class: Exponent::Push::ResponseHandler
- Inherits:
-
Object
- Object
- Exponent::Push::ResponseHandler
- Defined in:
- lib/exponent-server-sdk-jm.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#invalid_push_tokens ⇒ Object
readonly
Returns the value of attribute invalid_push_tokens.
-
#receipt_ids ⇒ Object
readonly
Returns the value of attribute receipt_ids.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #errors? ⇒ Boolean
- #handle(response) ⇒ Object deprecated Deprecated.
-
#initialize(error_builder = ErrorBuilder.new) ⇒ ResponseHandler
constructor
A new instance of ResponseHandler.
- #process_response(response) ⇒ Object
Constructor Details
#initialize(error_builder = ErrorBuilder.new) ⇒ ResponseHandler
Returns a new instance of ResponseHandler.
114 115 116 117 118 119 120 |
# File 'lib/exponent-server-sdk-jm.rb', line 114 def initialize(error_builder = ErrorBuilder.new) @error_builder = error_builder @response = nil @receipt_ids = [] @invalid_push_tokens = [] @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
112 113 114 |
# File 'lib/exponent-server-sdk-jm.rb', line 112 def errors @errors end |
#invalid_push_tokens ⇒ Object (readonly)
Returns the value of attribute invalid_push_tokens.
112 113 114 |
# File 'lib/exponent-server-sdk-jm.rb', line 112 def invalid_push_tokens @invalid_push_tokens end |
#receipt_ids ⇒ Object (readonly)
Returns the value of attribute receipt_ids.
112 113 114 |
# File 'lib/exponent-server-sdk-jm.rb', line 112 def receipt_ids @receipt_ids end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
112 113 114 |
# File 'lib/exponent-server-sdk-jm.rb', line 112 def response @response end |
Instance Method Details
#errors? ⇒ Boolean
133 134 135 |
# File 'lib/exponent-server-sdk-jm.rb', line 133 def errors? @errors.any? end |
#handle(response) ⇒ Object
Deprecated.
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/exponent-server-sdk-jm.rb', line 138 def handle(response) warn '[DEPRECATION] `handle` is deprecated. Please use `process_response` instead.' @response = response case response.code.to_s when /(^4|^5)/ raise build_error_from_failure else extract_data end end |
#process_response(response) ⇒ Object
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/exponent-server-sdk-jm.rb', line 122 def process_response(response) @response = response case response.code.to_s when /(^4|^5)/ raise @error_builder.parse_response(response) else sort_results end end |