lib/dkron-rb/api_client.rb in dkron-rb-1.0.0 vs lib/dkron-rb/api_client.rb in dkron-rb-1.1.0

- old
+ new

@@ -4,20 +4,20 @@ #You can communicate with Dkron using a RESTful JSON API over HTTP. Dkron nodes usually listen on port `8080` for API requests. All examples in this section assume that you've found a running leader at `localhost:8080`. Dkron implements a RESTful JSON API over HTTP to communicate with software clients. Dkron listens in port `8080` by default. All examples in this section assume that you're using the default port. Default API responses are unformatted JSON add the `pretty=true` param to format the response. OpenAPI spec version: 1 Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 2.4.2 +Swagger Codegen version: 2.4.18 =end require 'date' require 'json' require 'logger' require 'tempfile' require 'typhoeus' -require 'uri' +require 'addressable/uri' module Dkron class ApiClient # The Configuration object holding settings to be used in the API client. attr_accessor :config @@ -61,11 +61,11 @@ # Errors from libcurl will be made visible here fail ApiError.new(:code => 0, :message => response.return_message) else fail ApiError.new(:code => response.code, - :response_headers => response.headers, + :response_headers => response.headers.to_h, :response_body => response.body), response.status_message end end @@ -109,10 +109,12 @@ :sslcert => @config.cert_file, :sslkey => @config.key_file, :verbose => @config.debugging } + req_opts.merge!(multipart: true) if header_params['Content-Type'].start_with? "multipart/" + # set custom cert, if provided req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert if [:post, :patch, :put, :delete].include?(http_method) req_body = build_request_body(header_params, form_params, opts[:body]) @@ -261,10 +263,10 @@ end def build_request_url(path) # Add leading and trailing slashes to path path = "/#{path}".gsub(/\/+/, '/') - URI.encode(@config.base_url + path) + Addressable::URI.encode(@config.base_url + path) end # Builds the HTTP request body # # @param [Hash] header_params Header parameters