Class: AlmaApi::Client
- Inherits:
-
Object
- Object
- AlmaApi::Client
- Defined in:
- lib/alma_api/client.rb
Defined Under Namespace
Classes: Users
Constant Summary collapse
- API_ROOT_PATH =
"/almaws"
Instance Attribute Summary collapse
-
#apikey ⇒ Object
(also: #api_key)
Returns the value of attribute apikey.
-
#host ⇒ Object
Returns the value of attribute host.
Instance Method Summary collapse
-
#http(method, path, options = {}) ⇒ Object
inter-client api.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #users(user_id = nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 |
# File 'lib/alma_api/client.rb', line 15 def initialize( = {}) .symbolize_keys.try do || @apikey = [:apikey] || [:api_key] || ENV["ALMA_APIKEY"] || ENV["ALMA_API_KEY"] @host = ([:host] || ENV["ALMA_HOST"]).try(:strip) end end |
Instance Attribute Details
#apikey ⇒ Object Also known as: api_key
Returns the value of attribute apikey.
9 10 11 |
# File 'lib/alma_api/client.rb', line 9 def apikey @apikey end |
#host ⇒ Object
Returns the value of attribute host.
10 11 12 |
# File 'lib/alma_api/client.rb', line 10 def host @host end |
Instance Method Details
#http(method, path, options = {}) ⇒ Object
inter-client api
27 28 29 30 31 32 33 34 |
# File 'lib/alma_api/client.rb', line 27 def http(method, path, = {}) connection = Faraday.new.tap do |_connection| _connection.headers["Accept"] = "application/json" _connection.params["apikey"] = apikey end connection.send(method, "#{host}#{API_ROOT_PATH}#{path}", ) end |