Class: Mailgun::Base
- Inherits:
-
Object
- Object
- Mailgun::Base
- Defined in:
- lib/mailgun/base.rb
Instance Method Summary collapse
-
#base_url ⇒ Object
Returns the base url used in all Mailgun API calls.
- #bounces ⇒ Object
- #complaints ⇒ 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).
- #list_members ⇒ Object
- #lists ⇒ Object
- #log ⇒ Object
-
#mailboxes ⇒ Object
Returns an instance of Mailgun::Mailbox configured for the current API user.
- #routes ⇒ Object
- #unsubscribes ⇒ 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)
9 10 11 12 13 14 15 |
# File 'lib/mailgun/base.rb', line 9 def initialize() Mailgun.mailgun_host = .fetch(:mailgun_host) {"api.mailgun.net"} Mailgun.protocol = .fetch(:protocol) { "https" } Mailgun.api_version = .fetch(:api_version) { "v2" } 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?} end |
Instance Method Details
#base_url ⇒ Object
Returns the base url used in all Mailgun API calls
18 19 20 |
# File 'lib/mailgun/base.rb', line 18 def base_url "#{Mailgun.protocol}://api:#{Mailgun.api_key}@#{Mailgun.mailgun_host}/#{Mailgun.api_version}" end |
#bounces ⇒ Object
31 32 33 |
# File 'lib/mailgun/base.rb', line 31 def bounces @bounces ||= Mailgun::Bounce.new(self) end |
#complaints ⇒ Object
39 40 41 |
# File 'lib/mailgun/base.rb', line 39 def complaints @complaints ||= Mailgun::Complaint.new(self) end |
#list_members ⇒ Object
51 52 53 |
# File 'lib/mailgun/base.rb', line 51 def list_members @list_members ||= Mailgun::List::Member.new(self) end |
#lists ⇒ Object
47 48 49 |
# File 'lib/mailgun/base.rb', line 47 def lists @lists ||= Mailgun::List.new(self) end |
#log ⇒ Object
43 44 45 |
# File 'lib/mailgun/base.rb', line 43 def log @log ||= Mailgun::Log.new(self) end |
#mailboxes ⇒ Object
Returns an instance of Mailgun::Mailbox configured for the current API user
23 24 25 |
# File 'lib/mailgun/base.rb', line 23 def mailboxes @mailboxes ||= Mailgun::Mailbox.new(self) end |
#routes ⇒ Object
27 28 29 |
# File 'lib/mailgun/base.rb', line 27 def routes @routes ||= Mailgun::Route.new(self) end |
#unsubscribes ⇒ Object
35 36 37 |
# File 'lib/mailgun/base.rb', line 35 def unsubscribes @unsubscribes ||= Mailgun::Unsubscribe.new(self) end |