Class: Howitzer::TestmailApi::Client

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

Overview

A Testmail::Client object is used to communicate with the testmail.app API.

Constant Summary collapse

BASE_URL =
"https://api.testmail.app/api/json?apikey=#{Howitzer.testmail_api_key}" \
"&namespace=#{Howitzer.testmail_namespace}".freeze

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



11
12
13
# File 'lib/howitzer/testmail_api/client.rb', line 11

def initialize
  @api_token = Howitzer.testmail_api_key
end

Instance Method Details

#find_message(recipient, subject) ⇒ Hash

Finds message according to given parameters

Parameters:

  • recipient (String)

    this is recipient mail address for message filtering

  • subject (String)

    this is subject of the message to filter particular message

Returns:

  • (Hash)

    json message parsed to ruby hash



21
22
23
24
25
# File 'lib/howitzer/testmail_api/client.rb', line 21

def find_message(recipient, subject)
  recipient = recipient.gsub(/.*\.([^@]+)@.*/, '\1')
  messages = filter_by_subject(messages(recipient), subject)
  latest_message(messages)
end