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

- old
+ new

@@ -1,14 +1,14 @@ =begin #Dkron REST API #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: 0.11.2 +OpenAPI spec version: 1 Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 2.3.1 +Swagger Codegen version: 2.4.2 =end require 'date' require 'json' @@ -31,11 +31,11 @@ # @option config [Configuration] Configuration for initializing the object, default to Configuration.default def initialize(config = Configuration.default) @config = config @user_agent = "Swagger-Codegen/#{VERSION}/ruby" @default_headers = { - 'Content-Type' => "application/json", + 'Content-Type' => 'application/json', 'User-Agent' => @user_agent } end def self.default @@ -134,11 +134,11 @@ # APPLICATION/JSON # */* # @param [String] mime MIME # @return [Boolean] True if the MIME is application/json def json_mime?(mime) - (mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil? + (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil? end # Deserialize the response to the given return type. # # @param [Response] response HTTP response @@ -198,16 +198,16 @@ # generic object (usually a Hash), return directly data when /\AArray<(.+)>\z/ # e.g. Array<Pet> sub_type = $1 - data.map {|item| convert_to_type(item, sub_type) } + data.map { |item| convert_to_type(item, sub_type) } when /\AHash\<String, (.+)\>\z/ # e.g. Hash<String, Integer> sub_type = $1 {}.tap do |hash| - data.each {|k, v| hash[k] = convert_to_type(v, sub_type) } + data.each { |k, v| hash[k] = convert_to_type(v, sub_type) } end else # models, e.g. Pet Dkron.const_get(return_type).new.tap do |model| model.build_from_hash data @@ -225,11 +225,11 @@ def download_file(request) tempfile = nil encoding = nil request.on_headers do |response| content_disposition = response.headers['Content-Disposition'] - if content_disposition and content_disposition =~ /filename=/i + if content_disposition && content_disposition =~ /filename=/i filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] prefix = sanitize_filename(filename) else prefix = 'download-' end @@ -324,31 +324,31 @@ # @return [String] the Accept header (e.g. application/json) def select_header_accept(accepts) return nil if accepts.nil? || accepts.empty? # use JSON when present, otherwise use all of the provided json_accept = accepts.find { |s| json_mime?(s) } - return json_accept || accepts.join(',') + json_accept || accepts.join(',') end # Return Content-Type header based on an array of content types provided. # @param [Array] content_types array for Content-Type # @return [String] the Content-Type header (e.g. application/json) def select_header_content_type(content_types) # use application/json by default return 'application/json' if content_types.nil? || content_types.empty? # use JSON when present, otherwise use the first one json_content_type = content_types.find { |s| json_mime?(s) } - return json_content_type || content_types.first + json_content_type || content_types.first end # Convert object (array, hash, object, etc) to JSON string. # @param [Object] model object to be converted into JSON string # @return [String] JSON string representation of the object def object_to_http_body(model) return model if model.nil? || model.is_a?(String) local_body = nil if model.is_a?(Array) - local_body = model.map{|m| object_to_hash(m) } + local_body = model.map { |m| object_to_hash(m) } else local_body = object_to_hash(model) end local_body.to_json end