Sha256: 2845e832b46e10ddde55be7d90907ff9b4e7eef407b109b392ec095558214589
Contents?: true
Size: 912 Bytes
Versions: 1
Compression:
Stored size: 912 Bytes
Contents
require "faraday" require_relative "../alma_api" class AlmaApi::Client require_relative "./client/users" API_ROOT_PATH="/almaws" attr_accessor :apikey attr_accessor :host alias_method :api_key, :apikey alias_method :api_key=, :apikey= def initialize(options = {}) options.symbolize_keys.try do |_sanitized_options| @apikey = _sanitized_options[:apikey] || _sanitized_options[:api_key] || ENV["ALMA_APIKEY"] || ENV["ALMA_API_KEY"] @host = (_sanitized_options[:host] || ENV["ALMA_HOST"]).try(:strip) end end def users(user_id = nil) Users.new(self, user_id) end # inter-client api def http(method, path, options = {}) connection = Faraday.new.tap do |_connection| _connection.headers["Accept"] = "application/json" _connection.params["apikey"] = apikey end connection.send(method, "#{host}#{API_ROOT_PATH}#{path}", options) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alma_api-0.1.0 | lib/alma_api/client.rb |