class Maropost::DoNotMailList
Public Class Methods
create(contact)
click to toggle source
# File lib/maropost/do_not_mail_list.rb, line 21 def create(contact) payload = { 'global_unsubscribe': { 'email': contact.email } } service = Service.new( method: :post, path: 'global_unsubscribes.json', payload: payload ) service.execute! rescue RestClient::UnprocessableEntity, RestClient::BadRequest false end
delete(contact)
click to toggle source
# File lib/maropost/do_not_mail_list.rb, line 33 def delete(contact) service = Service.new( method: :delete, path: 'global_unsubscribes/delete.json', query: { 'email': contact.email } ) service.execute! rescue RestClient::UnprocessableEntity, RestClient::BadRequest false end
exists?(contact)
click to toggle source
# File lib/maropost/do_not_mail_list.rb, line 6 def exists?(contact) service = Service.new( method: :get, path: 'global_unsubscribes/email.json', query: { 'contact[email]': contact.email, 'auth_token': Maropost.configuration.auth_token } ) response = JSON.parse(service.execute!.body) response['id'].present? rescue RestClient::ResourceNotFound, RestClient::BadRequest false end