Class: Dato::Account::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/dato/account/client.rb

Constant Summary collapse

REPOS =
{
  account: Repo::Account,
  sites: Repo::Site
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, base_url: 'https://account-api.datocms.com', extra_headers: {}) ⇒ Client

Returns a new instance of Client.



21
22
23
24
25
26
27
28
29
# File 'lib/dato/account/client.rb', line 21

def initialize(
  token,
  base_url: 'https://account-api.datocms.com',
  extra_headers: {}
)
  @base_url = base_url
  @token = token
  @extra_headers = extra_headers
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



19
20
21
# File 'lib/dato/account/client.rb', line 19

def base_url
  @base_url
end

#extra_headersObject (readonly)

Returns the value of attribute extra_headers.



19
20
21
# File 'lib/dato/account/client.rb', line 19

def extra_headers
  @extra_headers
end

#schemaObject (readonly)

Returns the value of attribute schema.



19
20
21
# File 'lib/dato/account/client.rb', line 19

def schema
  @schema
end

#tokenObject (readonly)

Returns the value of attribute token.



19
20
21
# File 'lib/dato/account/client.rb', line 19

def token
  @token
end

Instance Method Details

#request(*args) ⇒ Object



41
42
43
44
45
# File 'lib/dato/account/client.rb', line 41

def request(*args)
  connection.send(*args).body.with_indifferent_access
rescue Faraday::ClientError => e
  raise ApiError, e
end