Class: Mailgun::Base
Instance Method Summary collapse
- #addresses(domain = Mailgun.domain) ⇒ Object
-
#base_url ⇒ Object
Returns the base url used in all Mailgun API calls.
- #bounces(domain = Mailgun.domain) ⇒ Object
- #complaints(domain = Mailgun.domain) ⇒ Object
- #domains ⇒ Object
-
#initialize(options) ⇒ Base
constructor
Options taken from documentation.mailgun.net/quickstart.html#authentication * Mailgun host - location of mailgun api servers * Procotol - http or https [default to https] * API key and version * Test mode - if enabled, doesn’t actually send emails (see documentation.mailgun.net/user_manual.html#sending-in-test-mode) * Domain - domain to use * Webhook URL - default url to use if one is not specified in each request * Public API Key - used for address endpoint.
- #list_members(address) ⇒ Object
- #lists ⇒ Object
- #log(domain = Mailgun.domain) ⇒ Object
-
#mailboxes(domain = Mailgun.domain) ⇒ Object
Returns an instance of Mailgun::Mailbox configured for the current API user.
- #messages(domain = Mailgun.domain) ⇒ Object
- #public_base_url ⇒ Object
- #routes ⇒ Object
- #secure ⇒ Object
- #unsubscribes(domain = Mailgun.domain) ⇒ Object
- #webhooks(domain = Mailgun.domain, webhook_url = Mailgun.webhook_url) ⇒ Object
Constructor Details
#initialize(options) ⇒ Base
Options taken from documentation.mailgun.net/quickstart.html#authentication
-
Mailgun host - location of mailgun api servers
-
Procotol - http or https [default to https]
-
API key and version
-
Test mode - if enabled, doesn’t actually send emails (see documentation.mailgun.net/user_manual.html#sending-in-test-mode)
-
Domain - domain to use
-
Webhook URL - default url to use if one is not specified in each request
-
Public API Key - used for address endpoint
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mailgun/base.rb', line 12 def initialize() Mailgun.mailgun_host = .fetch(:mailgun_host) { "api.mailgun.net" } Mailgun.protocol = .fetch(:protocol) { "https" } Mailgun.api_version = .fetch(:api_version) { "v3" } Mailgun.test_mode = .fetch(:test_mode) { false } Mailgun.api_key = .fetch(:api_key) { raise ArgumentError.new(":api_key is a required argument to initialize Mailgun") if Mailgun.api_key.nil? } Mailgun.domain = .fetch(:domain) { nil } Mailgun.webhook_url = .fetch(:webhook_url) { nil } Mailgun.public_api_key = .fetch(:public_api_key) { nil } end |
Instance Method Details
#addresses(domain = Mailgun.domain) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/mailgun/base.rb', line 61 def addresses(domain = Mailgun.domain) if Mailgun.public_api_key.nil? raise ArgumentError.new(":public_api_key is a required argument to validate addresses") end Mailgun::Address.new(self) end |
#base_url ⇒ Object
Returns the base url used in all Mailgun API calls
24 25 26 |
# File 'lib/mailgun/base.rb', line 24 def base_url "#{Mailgun.protocol}://api:#{Mailgun.api_key}@#{Mailgun.mailgun_host}/#{Mailgun.api_version}" end |
#bounces(domain = Mailgun.domain) ⇒ Object
45 46 47 |
# File 'lib/mailgun/base.rb', line 45 def bounces(domain = Mailgun.domain) Mailgun::Bounce.new(self, domain) end |
#complaints(domain = Mailgun.domain) ⇒ Object
68 69 70 |
# File 'lib/mailgun/base.rb', line 68 def complaints(domain = Mailgun.domain) Mailgun::Complaint.new(self, domain) end |
#domains ⇒ Object
49 50 51 |
# File 'lib/mailgun/base.rb', line 49 def domains Mailgun::Domain.new(self) end |
#list_members(address) ⇒ Object
80 81 82 |
# File 'lib/mailgun/base.rb', line 80 def list_members(address) Mailgun::MailingList::Member.new(self, address) end |
#lists ⇒ Object
76 77 78 |
# File 'lib/mailgun/base.rb', line 76 def lists @lists ||= Mailgun::MailingList.new(self) end |
#log(domain = Mailgun.domain) ⇒ Object
72 73 74 |
# File 'lib/mailgun/base.rb', line 72 def log(domain=Mailgun.domain) Mailgun::Log.new(self, domain) end |
#mailboxes(domain = Mailgun.domain) ⇒ Object
Returns an instance of Mailgun::Mailbox configured for the current API user
33 34 35 |
# File 'lib/mailgun/base.rb', line 33 def mailboxes(domain = Mailgun.domain) Mailgun::Mailbox.new(self, domain) end |
#messages(domain = Mailgun.domain) ⇒ Object
37 38 39 |
# File 'lib/mailgun/base.rb', line 37 def (domain = Mailgun.domain) @messages ||= Mailgun::Message.new(self, domain) end |
#public_base_url ⇒ Object
28 29 30 |
# File 'lib/mailgun/base.rb', line 28 def public_base_url "#{Mailgun.protocol}://api:#{Mailgun.public_api_key}@#{Mailgun.mailgun_host}/#{Mailgun.api_version}" end |
#routes ⇒ Object
41 42 43 |
# File 'lib/mailgun/base.rb', line 41 def routes @routes ||= Mailgun::Route.new(self) end |
#secure ⇒ Object
84 85 86 |
# File 'lib/mailgun/base.rb', line 84 def secure Mailgun::Secure.new(self) end |