Class: Phaxio::Client Private
- Inherits:
-
Object
- Object
- Phaxio::Client
- Defined in:
- lib/phaxio/client.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
-
.conn ⇒ Faraday::Connection
private
A new Faraday connection to ‘Phaxio::Config.api_endpoint`.
-
.request(method, endpoint, params = {}) ⇒ Object
private
Makes a request to the Phaxio API.
Class Method Details
.conn ⇒ Faraday::Connection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns A new Faraday connection to ‘Phaxio::Config.api_endpoint`.
42 43 44 45 46 47 48 |
# File 'lib/phaxio/client.rb', line 42 def conn Faraday.new(Phaxio.api_endpoint) do |conn| conn.request :multipart conn.request :url_encoded conn.adapter :net_http end end |
.request(method, endpoint, params = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Makes a request to the Phaxio API.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/phaxio/client.rb', line 25 def request method, endpoint, params = {} params = api_params params begin response = case method.to_s when 'post' then post(endpoint, params) when 'patch' then patch(endpoint, params) when 'get' then get(endpoint, params) when 'delete' then delete(endpoint, params) else raise ArgumentError, "HTTP method `#{method}` is not supported." end handle_response response rescue Faraday::ConnectionFailed, Faraday::TimeoutError, Faraday::SSLError => error raise Error::ApiConnectionError, "Error communicating with Phaxio: #{error}" end end |