Module: SendgridToolkit::Common

Included in:
Bounces, InvalidEmails, SpamReports
Defined in:
lib/sendgrid_toolkit/common.rb

Instance Method Summary collapse

Instance Method Details

#delete(options = {}) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/sendgrid_toolkit/common.rb', line 23

def delete(options = {})
  response = api_post(module_name, 'delete', options)
  if !response["message"].nil?
    raise EmailDoesNotExist if response['message'].include?('does not exist')
  end
  response
end

#module_nameObject



31
32
33
# File 'lib/sendgrid_toolkit/common.rb', line 31

def module_name
  self.class.to_s.split("::").last.downcase
end

#retrieve(options = {}) ⇒ Object



5
6
7
8
# File 'lib/sendgrid_toolkit/common.rb', line 5

def retrieve(options = {})
  response = api_post(module_name, 'get', options)
  response
end

#retrieve_with_timestamps(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sendgrid_toolkit/common.rb', line 10

def retrieve_with_timestamps(options = {})
  options.merge! :date => 1
  response = retrieve options
  if response.is_a? Array
    response.each do |message|
      parse_message_time message
    end
  else
    parse_message_time response
  end
  response
end