Class: Dato::Account::Client
- Inherits:
-
Object
- Object
- Dato::Account::Client
- Defined in:
- lib/dato/account/client.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#extra_headers ⇒ Object
readonly
Returns the value of attribute extra_headers.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(token, options = {}) ⇒ Client
constructor
A new instance of Client.
- #request(*args) ⇒ Object
Constructor Details
#initialize(token, options = {}) ⇒ Client
Returns a new instance of Client.
27 28 29 30 31 |
# File 'lib/dato/account/client.rb', line 27 def initialize(token, = {}) @token = token @base_url = [:base_url] || 'https://account-api.datocms.com' @extra_headers = [:extra_headers] || {} end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
25 26 27 |
# File 'lib/dato/account/client.rb', line 25 def base_url @base_url end |
#extra_headers ⇒ Object (readonly)
Returns the value of attribute extra_headers.
25 26 27 |
# File 'lib/dato/account/client.rb', line 25 def extra_headers @extra_headers end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
25 26 27 |
# File 'lib/dato/account/client.rb', line 25 def schema @schema end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
25 26 27 |
# File 'lib/dato/account/client.rb', line 25 def token @token end |
Instance Method Details
#request(*args) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dato/account/client.rb', line 43 def request(*args) connection.send(*args).body.with_indifferent_access rescue Faraday::SSLError => e raise e if ENV['SSL_CERT_FILE'] == Cacert.pem Cacert.set_in_env request(*args) rescue Faraday::ConnectionFailed, Faraday::TimeoutError => e raise e rescue Faraday::ClientError => e raise ApiError, e end |