Method: Phaxio::Client.request
- Defined in:
- lib/phaxio/client.rb
.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 |