Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes typhoeus for HTTParty #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion khipu-api-client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.description = %q{This gem maps to a swagger API}
s.license = "Apache-2.0"

s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
s.add_runtime_dependency 'httparty', '0.20.0'
s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'

s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
Expand Down
9 changes: 3 additions & 6 deletions lib/khipu-api-client/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
require 'json'
require 'logger'
require 'tempfile'
require 'typhoeus'
require 'uri'
require 'net/http'
require 'openssl'
require 'base64'
require 'httparty'

module Khipu
class ApiClient
Expand All @@ -32,8 +32,7 @@ def initialize(host = nil)
end

def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
response = build_request(http_method, path, opts)

# record as last response
@last_response = response
Expand Down Expand Up @@ -64,9 +63,7 @@ def build_request(http_method, path, opts = {})
query_params = opts[:query_params] || {}
form_params = opts[:form_params] || {}


update_params_for_auth! @host, path, http_method, header_params, query_params, form_params, opts[:auth_names], opts[:body]


req_opts = {
:method => http_method,
Expand All @@ -87,7 +84,7 @@ def build_request(http_method, path, opts = {})
end
end

Typhoeus::Request.new(url, req_opts)
HTTParty.send(req_opts[:method], url, { headers: req_opts[:headers], body: req_opts[:body] })
end

# Deserialize the response to the given return type.
Expand Down
2 changes: 0 additions & 2 deletions lib/khipu-api-client/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ class Configuration
#
# @return [String] the path to the certificate file
#
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
attr_accessor :ssl_ca_cert

# Client certificate file (for client certificate)
Expand Down