class MailinatorClient::Client
Mailinator API
User API for accessing Mailinator data
Public Class Methods
new(options = {})
click to toggle source
attr_reader :auth_token, :url
# File lib/mailinator_client/client.rb, line 32 def initialize(options = {}) @auth_token = options.fetch(:auth_token, nil) @url = "https://mailinator.com/api/v2" end
Public Instance Methods
domains()
click to toggle source
# File lib/mailinator_client/client.rb, line 37 def domains @domains ||= Domains.new(self) end
messages()
click to toggle source
# File lib/mailinator_client/client.rb, line 45 def messages @messages ||= Messages.new(self) end
request(options = {})
click to toggle source
# File lib/mailinator_client/client.rb, line 53 def request(options = {}) headers = options.fetch(:headers, {}) method = options.fetch(:method, :get) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" headers["Authorization"] = @auth_token if @auth_token path = @url + options.fetch(:path, "") response = HTTParty.send(method, path, query: Utils.fix_query_arrays(options[:query]), body: options[:body] && options[:body].to_json(), headers: headers) result = response.parsed_response if response.code >= 400 raise ResponseError.new(response.code, result) end result end
rules()
click to toggle source
# File lib/mailinator_client/client.rb, line 49 def rules @rules ||= Rules.new(self) end
stats()
click to toggle source
# File lib/mailinator_client/client.rb, line 41 def stats @stats ||= Stats.new(self) end