Class: Sendgrid::Response
- Inherits:
-
Object
- Object
- Sendgrid::Response
- Defined in:
- lib/sendgrid/response.rb
Instance Method Summary collapse
- #body ⇒ Object
- #errors? ⇒ Boolean
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #successful? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
3 4 5 |
# File 'lib/sendgrid/response.rb', line 3 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
18 19 20 |
# File 'lib/sendgrid/response.rb', line 18 def body JSON.parse(@response.body) end |
#errors? ⇒ Boolean
7 8 9 10 11 12 |
# File 'lib/sendgrid/response.rb', line 7 def errors? return false if Array === body return true if body.key?("error") return false unless body.key?("message") ["error", "User not found"].include?(body["message"]) end |
#successful? ⇒ Boolean
14 15 16 |
# File 'lib/sendgrid/response.rb', line 14 def successful? ! errors? end |