module MailCatcher::API::Client
Constants
- MESSAGE_ENDPOINT
- MESSAGE_INDEX_ENDPOINT
Public Class Methods
delete_all()
click to toggle source
# File lib/mailcatcher/api/client.rb, line 19 def self.delete_all request(:delete, MESSAGE_INDEX_ENDPOINT) end
delete_message(id)
click to toggle source
# File lib/mailcatcher/api/client.rb, line 23 def self.delete_message(id) request(:delete, format(MESSAGE_ENDPOINT, message_id: id)) end
fetch_message(id)
click to toggle source
# File lib/mailcatcher/api/client.rb, line 15 def self.fetch_message(id) request(:get, format(MESSAGE_ENDPOINT, message_id: id)) end
fetch_message_index()
click to toggle source
# File lib/mailcatcher/api/client.rb, line 11 def self.fetch_message_index request(:get, MESSAGE_INDEX_ENDPOINT) end
http()
click to toggle source
# File lib/mailcatcher/api/client.rb, line 37 def self.http uri = URI(MailCatcher::API.config.server) Net::HTTP.new(uri.host, uri.port) end
request(method, path)
click to toggle source
# File lib/mailcatcher/api/client.rb, line 27 def self.request(method, path) request = case method when :get; Net::HTTP::Get.new(path) when :delete; Net::HTTP::Delete.new(path) else raise NotImplementedError, "Don't know how to request #{method} method" end response = http.request(request) JSON.load(response.body) end