Class: Rubymail::Base

Inherits:
Object show all
Defined in:
lib/rubymail/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Base

Returns a new instance of Base.



4
5
6
7
8
9
10
11
12
13
# File 'lib/rubymail/base.rb', line 4

def initialize(options)
  Rubymail.rubymail_host    = options.fetch(:rubymail_host)    { "api.rubymail.net" }
  Rubymail.protocol        = options.fetch(:protocol)        { "https" }
  Rubymail.api_version     = options.fetch(:api_version)     { "v3" }
  Rubymail.test_mode       = options.fetch(:test_mode)       { false }
  Rubymail.api_key         = options.fetch(:api_key)         { raise ArgumentError.new(":api_key is a required argument to initialize Rubymail") if Rubymail.api_key.nil? }
  Rubymail.domain          = options.fetch(:domain)          { nil }
  Rubymail.webhook_url     = options.fetch(:webhook_url)     { nil }
  Rubymail.public_api_key  = options.fetch(:public_api_key)  { nil }
end

Instance Method Details

#addresses(domain = Rubymail.domain) ⇒ Object



51
52
53
54
55
56
# File 'lib/rubymail/base.rb', line 51

def addresses(domain = Rubymail.domain)
  if Rubymail.public_api_key.nil?
    raise ArgumentError.new(":public_api_key is a required argument to validate addresses")
  end
  Rubymail::Address.new(self)
end

#base_urlObject



15
16
17
# File 'lib/rubymail/base.rb', line 15

def base_url
  "#{Rubymail.protocol}://api:#{Rubymail.api_key}@#{Rubymail.rubymail_host}/#{Rubymail.api_version}"
end

#bounces(domain = Rubymail.domain) ⇒ Object



35
36
37
# File 'lib/rubymail/base.rb', line 35

def bounces(domain = Rubymail.domain)
  Rubymail::Bounce.new(self, domain)
end

#complaints(domain = Rubymail.domain) ⇒ Object



58
59
60
# File 'lib/rubymail/base.rb', line 58

def complaints(domain = Rubymail.domain)
  Rubymail::Complaint.new(self, domain)
end

#domainsObject



39
40
41
# File 'lib/rubymail/base.rb', line 39

def domains
  Rubymail::Domain.new(self)
end

#list_members(address) ⇒ Object



70
71
72
# File 'lib/rubymail/base.rb', line 70

def list_members(address)
  Rubymail::MailingList::Member.new(self, address)
end

#listsObject



66
67
68
# File 'lib/rubymail/base.rb', line 66

def lists
  @lists ||= Rubymail::MailingList.new(self)
end

#log(domain = Rubymail.domain) ⇒ Object



62
63
64
# File 'lib/rubymail/base.rb', line 62

def log(domain=Rubymail.domain)
  Rubymail::Log.new(self, domain)
end

#mailboxes(domain = Rubymail.domain) ⇒ Object



23
24
25
# File 'lib/rubymail/base.rb', line 23

def mailboxes(domain = Rubymail.domain)
  Rubymail::Mailbox.new(self, domain)
end

#messages(domain = Rubymail.domain) ⇒ Object



27
28
29
# File 'lib/rubymail/base.rb', line 27

def messages(domain = Rubymail.domain)
  @messages ||= Rubymail::Message.new(self, domain)
end

#public_base_urlObject



19
20
21
# File 'lib/rubymail/base.rb', line 19

def public_base_url
  "#{Rubymail.protocol}://api:#{Rubymail.public_api_key}@#{Rubymail.rubymail_host}/#{Rubymail.api_version}"
end

#routesObject



31
32
33
# File 'lib/rubymail/base.rb', line 31

def routes
  @routes ||= Rubymail::Route.new(self)
end

#secureObject



74
75
76
# File 'lib/rubymail/base.rb', line 74

def secure
  Rubymail::Secure.new(self)
end

#unsubscribes(domain = Rubymail.domain) ⇒ Object



43
44
45
# File 'lib/rubymail/base.rb', line 43

def unsubscribes(domain = Rubymail.domain)
  Rubymail::Unsubscribe.new(self, domain)
end

#webhooks(domain = Rubymail.domain, webhook_url = Rubymail.webhook_url) ⇒ Object



47
48
49
# File 'lib/rubymail/base.rb', line 47

def webhooks(domain = Rubymail.domain, webhook_url = Rubymail.webhook_url)
  Rubymail::Webhook.new(self, domain, webhook_url)
end