lib/dato/account/client.rb in dato-0.1.5 vs lib/dato/account/client.rb in dato-0.1.6
- old
+ new
@@ -1,5 +1,6 @@
+# frozen_string_literal: true
require 'faraday'
require 'faraday_middleware'
require 'json'
require 'active_support/core_ext/hash/indifferent_access'
@@ -10,12 +11,12 @@
module Dato
module Account
class Client
REPOS = {
account: Repo::Account,
- sites: Repo::Site,
- }
+ sites: Repo::Site
+ }.freeze
attr_reader :token, :base_url, :schema
def initialize(token, base_url: 'https://account-api.datocms.com')
@base_url = base_url
@@ -33,20 +34,20 @@
end
def request(*args)
connection.send(*args).body.with_indifferent_access
rescue Faraday::ClientError => e
- raise ApiError.new(e)
+ raise ApiError, e
end
private
def connection
options = {
url: base_url,
headers: {
- 'Accept' => "application/json",
- 'Content-Type' => "application/json",
+ 'Accept' => 'application/json',
+ 'Content-Type' => 'application/json',
'Authorization' => "Bearer #{@token}"
}
}
@connection ||= Faraday.new(options) do |c|