Class: SendgridNotification::SendgridClient::Response
- Inherits:
-
SendGrid::Response
- Object
- SendGrid::Response
- SendgridNotification::SendgridClient::Response
- Defined in:
- app/models/sendgrid_notification/sendgrid_client.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(send_grid_response) ⇒ Response
constructor
SendGrid::Response, has status_code, body, headers.
- #status_code ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(send_grid_response) ⇒ Response
SendGrid::Response, has status_code, body, headers
18 19 20 |
# File 'app/models/sendgrid_notification/sendgrid_client.rb', line 18 def initialize(send_grid_response) # SendGrid::Response, has status_code, body, headers @raw = send_grid_response end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
16 17 18 |
# File 'app/models/sendgrid_notification/sendgrid_client.rb', line 16 def raw @raw end |
Instance Method Details
#body ⇒ Object
30 31 32 |
# File 'app/models/sendgrid_notification/sendgrid_client.rb', line 30 def body JSON.parse(raw.body) rescue {} end |
#status_code ⇒ Object
22 23 24 |
# File 'app/models/sendgrid_notification/sendgrid_client.rb', line 22 def status_code raw.try(:status_code).try(:to_i) end |
#success? ⇒ Boolean
26 27 28 |
# File 'app/models/sendgrid_notification/sendgrid_client.rb', line 26 def success? status_code && status_code < 300 end |