Class: Ponga::Mailer

Inherits:
Object
  • Object
show all
Defined in:
lib/ponga/mailer.rb

Constant Summary collapse

API_ENDPOINT =
"https://www.getponga.com/messages".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Mailer

Returns a new instance of Mailer.



6
7
8
# File 'lib/ponga/mailer.rb', line 6

def initialize(api_key)
  @api_key = api_key
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



3
4
5
# File 'lib/ponga/mailer.rb', line 3

def api_key
  @api_key
end

Instance Method Details

#send(subject:, body:, to:) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/ponga/mailer.rb', line 10

def send(subject:, body:, to:)
  HTTParty.post(API_ENDPOINT, body: {
    message: {
      subject: subject,
      recipient: to,
      body: body
    },
    key: api_key
  })
end