lib/dato/api_client.rb in dato-0.6.9 vs lib/dato/api_client.rb in dato-0.6.10

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'faraday' require 'faraday_middleware' require 'json' require 'json_schema' require 'active_support/core_ext/hash/indifferent_access' @@ -38,11 +40,11 @@ schema = JsonSchema.parse!(JSON.parse(response.body)) schema.expand_references! schema.definitions.each do |type, schema| - is_collection = schema.links.select{|x| x.rel === "instances"}.any? + is_collection = schema.links.select { |x| x.rel === 'instances' }.any? namespace = is_collection ? type.pluralize : type define_method(namespace) do instance_variable_set( "@#{namespace}", @@ -53,11 +55,12 @@ end end end def request(*args) - connection.send(*args).body.with_indifferent_access + response = connection.send(*args) + response.body.with_indifferent_access rescue Faraday::SSLError => e raise e if ENV['SSL_CERT_FILE'] == Cacert.pem Cacert.set_in_env request(*args) @@ -78,10 +81,10 @@ default_headers = { 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{@token}", 'User-Agent' => "ruby-client v#{Dato::VERSION}", - 'X-Api-Version' => "2" + 'X-Api-Version' => '2' } options = { url: base_url, headers: default_headers.merge(extra_headers)