Class: CED::EmailResponse
- Inherits:
-
Object
- Object
- CED::EmailResponse
- Defined in:
- lib/ced/email_response.rb
Constant Summary collapse
- SUCCESS_STATUS_CODE =
200
- EMPTY_JSON =
"{}"
Instance Method Summary collapse
-
#initialize(response) ⇒ EmailResponse
constructor
A new instance of EmailResponse.
- #raw_email ⇒ Object
- #successful? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ EmailResponse
Returns a new instance of EmailResponse.
8 9 10 |
# File 'lib/ced/email_response.rb', line 8 def initialize(response) @response = response end |
Instance Method Details
#raw_email ⇒ Object
16 17 18 19 |
# File 'lib/ced/email_response.rb', line 16 def raw_email body = successful? ? @response.body : EMPTY_JSON JSON.parse(body) end |
#successful? ⇒ Boolean
12 13 14 |
# File 'lib/ced/email_response.rb', line 12 def successful? @response.code.to_i == SUCCESS_STATUS_CODE end |