Method: AmznSpApi::SalesApiModel::ApiClient#call_api
- Defined in:
- lib/sales_api_model/api_client.rb
#call_api(http_method, path, opts = {}) ⇒ Array<(Object, Integer, Hash)>
Call an API with given options.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/sales_api_model/api_client.rb', line 46 def call_api(http_method, path, opts = {}) request = build_request(http_method, path, opts) response = request.run @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" if @config.debugging unless response.success? if response.timed_out? raise ApiError, 'Connection timed out' elsif response.code == 0 # Errors from libcurl will be made visible here raise ApiError.new(code: 0, message: response.) else raise ApiError.new(code: response.code, response_headers: response.headers, response_body: response.body), response. end end data = if opts[:return_type] deserialize(response, opts[:return_type]) else nil end [data, response.code, response.headers] end |