alma_api

This is a ruby wrapper for the Alma REST api. It aims to make working with this api as pleasant as possible. Options and parameters are the same as for the original api. It also sanitizes some api quirks such as unnecessary case sensitive option values.

Installation

Add this line to your application's Gemfile:

gem "alma_api"

And then execute:

$ bundle

Or install it yourself as:

$ gem install alma_api

Usage

In order to use the api client you have to provide an apikey and the host you want to connect to. Both can be provided as paramters or as environment variables named ALMA_APIKEY or ALMA_HOST.

require "alma_api"

client = AlmaApi::Client.new(apikey: "your_api_key", host: "https://alma_host")

# calling semantic resembles the api as close as possible
client.users.get # => [...] users collection
client.users("user_id").get # => user object
client.users("user_id").get(view: :brief) # => user object (brief view)
client.users("user_id").fees.get # => fees of a user
client.users("user_id").fees("fee_id").get # => fees of a user

This gem uses mighty_struct for its results. This means you can navigate results with object notation like with OpenStruct. If you want to get the underlaying hash/array just call to_a or to_h.

require "alma_api"

client = AlmaApi::Client.new(apikey: "your_api_key", host: "https://alma_host")
some_user = client.users(client.users.get.first.primary_id).get

# now you can investigate the user with method notation
some_user.contact_info.email.first.email_address # => "some@email_adress.org"

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release to create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

  1. Fork it ( https://github.com/ubpb/alma_api/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request