Class: SendGridWebApi::Modules::Unsubscribe

Inherits:
Client
  • Object
show all
Defined in:
lib/web_api/unsubscribes.rb

Instance Attribute Summary

Attributes inherited from Base

#api_key

Instance Method Summary collapse

Methods included from SendGridWebApi::Modules

#apikey, #blocks, #bounces, #event_notification, #invalid_emails, #mail, #parse_email, #profile, #spam, #stats, #sub_user, #unsubscribes

Methods inherited from Base

#builder_options, #initialize, #make_request_url, #query_api, #query_delete_api, #query_patch_api, #query_post_api, #query_post_json_api, #session, #to_query

Constructor Details

This class inherits a constructor from SendGridWebApi::Base

Instance Method Details

#add(options = {}) ⇒ Object

Add one or more email addresses to the global suppressions group. Expects options => recipient_emails: [“[email protected]”]



17
18
19
20
# File 'lib/web_api/unsubscribes.rb', line 17

def add options = {}
unsubscribe_url = "asm/suppressions/global"
  query_post_json_api(unsubscribe_url, process_header_options(options))
end

#base_urlObject



3
4
5
# File 'lib/web_api/unsubscribes.rb', line 3

def base_url
  "https://api.sendgrid.com/v3/"
end

#delete(options = {}) ⇒ Object

This method will delete all unsubscribes from the given email



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

def delete options = {}
  unsubscribe_url = "asm/suppressions/global"
  delete_url = unsubscribe_url + "/#{options[:email]}"
  options.delete(:email)

  query_delete_api(delete_url, process_header_options(options))
end

#get(options = {}) ⇒ Object

Retrieve a list of all email address that are globally suppressed. You can use the offset and limit parameters to retrieve a custom number of results. You can use the start_time and end_time parameters to filter by time frames.



10
11
12
13
# File 'lib/web_api/unsubscribes.rb', line 10

def get options = {}
  unsubscribe_url = "suppression/unsubscribes"
  query_api(unsubscribe_url, process_header_options(options))
end