Class: MailinatorClient::Client
- Inherits:
-
Object
- Object
- MailinatorClient::Client
- Defined in:
- lib/mailinator_client/client.rb
Overview
Mailinator API
User API for accessing Mailinator data
Instance Method Summary collapse
- #domains ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
attr_reader :auth_token, :url.
- #messages ⇒ Object
- #request(options = {}) ⇒ Object
- #rules ⇒ Object
- #stats ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
attr_reader :auth_token, :url
32 33 34 35 |
# File 'lib/mailinator_client/client.rb', line 32 def initialize( = {}) @auth_token = .fetch(:auth_token, nil) @url = "https://mailinator.com/api/v2" end |
Instance Method Details
#domains ⇒ Object
37 38 39 |
# File 'lib/mailinator_client/client.rb', line 37 def domains @domains ||= Domains.new(self) end |
#messages ⇒ Object
45 46 47 |
# File 'lib/mailinator_client/client.rb', line 45 def ||= Messages.new(self) end |
#request(options = {}) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/mailinator_client/client.rb', line 53 def request( = {}) headers = .fetch(:headers, {}) method = .fetch(:method, :get) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" headers["Authorization"] = @auth_token if @auth_token path = @url + .fetch(:path, "") response = HTTParty.send(method, path, query: Utils.fix_query_arrays([:query]), body: [:body] && [:body].to_json(), headers: headers) result = response.parsed_response if response.code >= 400 raise ResponseError.new(response.code, result) end result end |
#rules ⇒ Object
49 50 51 |
# File 'lib/mailinator_client/client.rb', line 49 def rules @rules ||= Rules.new(self) end |
#stats ⇒ Object
41 42 43 |
# File 'lib/mailinator_client/client.rb', line 41 def stats @stats ||= Stats.new(self) end |