Class: SendgridNotification::SendgridClient::Response

Inherits:
SendGrid::Response
  • Object
show all
Defined in:
app/models/sendgrid_notification/sendgrid_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#rawObject (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

#bodyObject



30
31
32
# File 'app/models/sendgrid_notification/sendgrid_client.rb', line 30

def body
  JSON.parse(raw.body) rescue {}
end

#status_codeObject



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

Returns:

  • (Boolean)


26
27
28
# File 'app/models/sendgrid_notification/sendgrid_client.rb', line 26

def success?
  status_code && status_code < 300
end