Class: Mailgun::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mailgun/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, domain) ⇒ Client

Returns a new instance of Client.



8
9
10
11
# File 'lib/mailgun/client.rb', line 8

def initialize(api_key, domain)
  @api_key = api_key
  @domain = domain
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



6
7
8
# File 'lib/mailgun/client.rb', line 6

def api_key
  @api_key
end

#domainObject (readonly)

Returns the value of attribute domain.



6
7
8
# File 'lib/mailgun/client.rb', line 6

def domain
  @domain
end

Instance Method Details

#api_urlObject



21
22
23
# File 'lib/mailgun/client.rb', line 21

def api_url
  "https://api:#{api_key}@api.mailgun.net/v3/#{domain}"
end

#mailgun_urlObject



17
18
19
# File 'lib/mailgun/client.rb', line 17

def mailgun_url
  api_url+"/messages"
end

#send_message(options) ⇒ Object



13
14
15
# File 'lib/mailgun/client.rb', line 13

def send_message(options)
  RestClient.post mailgun_url, options
end