Class: Howitzer::MailgunApi::Connector

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/howitzer/mailgun_api/connector.rb

Overview

This class represent connector to Mailgun service

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConnector

Assigns default value for a domain


16
17
18
# File 'lib/howitzer/mailgun_api/connector.rb', line 16

def initialize
  self.domain = Howitzer.mailgun_domain
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key


11
12
13
# File 'lib/howitzer/mailgun_api/connector.rb', line 11

def api_key
  @api_key
end

#domainObject

Returns the value of attribute domain


12
13
14
# File 'lib/howitzer/mailgun_api/connector.rb', line 12

def domain
  @domain
end

Instance Method Details

#client(api_key = Howitzer.mailgun_key) ⇒ Client

Returns a mailgun client

Raises:


23
24
25
26
27
28
# File 'lib/howitzer/mailgun_api/connector.rb', line 23

def client(api_key = Howitzer.mailgun_key)
  check_api_key(api_key)
  return @client if @api_key == api_key && @api_key
  @api_key = api_key
  @client = Client.new(api_key: @api_key)
end