Class: SendgridToolkit::Unsubscribes
Instance Method Summary
collapse
#initialize
Instance Method Details
#add(options = {}) ⇒ Object
3
4
5
6
7
|
# File 'lib/sendgrid_toolkit/unsubscribes.rb', line 3
def add(options = {})
response = api_post('unsubscribes', 'add', options)
raise UnsubscribeEmailAlreadyExists if response['message'].include?('already exists')
response
end
|
#delete(options = {}) ⇒ Object
9
10
11
12
13
|
# File 'lib/sendgrid_toolkit/unsubscribes.rb', line 9
def delete(options = {})
response = api_post('unsubscribes', 'delete', options)
raise UnsubscribeEmailDoesNotExist if response['message'].include?('does not exist')
response
end
|
#retrieve(options = {}) ⇒ Object
15
16
17
18
|
# File 'lib/sendgrid_toolkit/unsubscribes.rb', line 15
def retrieve(options = {})
response = api_post('unsubscribes', 'get', options)
response
end
|
#retrieve_with_timestamps(options = {}) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/sendgrid_toolkit/unsubscribes.rb', line 20
def retrieve_with_timestamps(options = {})
options.merge! :date => 1
response = retrieve options
response.each do |unsubscribe|
unsubscribe['created'] = Time.parse(unsubscribe['created']) if unsubscribe.has_key?('created')
end
response
end
|