Ruby client to process the DPN REST api
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/dpn
spec
.gitignore
.rspec
.travis.yml
Gemfile
Gemfile.lock
LICENSE.md
README.md
Rakefile
dpn-client.gemspec
dpn_client_128.png
dpn_client_500.jpg
logo_license.txt

README.md

DPN::Client

dpn_client

Build Status Code Climate Test Coverage

Installation

Add this line to your application's Gemfile:

gem 'dpn-client'

And then execute:

$ bundle install

Usage

See the yard documentation for more info, but the basics are thus:

client = DPN::Client.client.configure do |c|
  c.api_root = "https://hathitrust.org/api_root"
  c.auth_token = "auth_token_for_hathi"
end

client.bags(page_size: 25, admin_node: "hathi") do |bag|
  bag.inspect # this block is optional
end

resp = client.create_bag(some_bag_hash)
if resp.success?
  some_bag_hash[:status] = resp[:status]
end

Essentially, single-endpoint operations always return a Response object, but you can treat this object as just a hash, if you want. Index operations return an array of hashes.

You can pass a block to any operation. For single-endpoints, the response will be passed to the block. For indexes, each individual result will be passed successively to the block. Using blocks is recommended.

License

Copyright (c) 2015 The Regents of the University of Michigan. All Rights Reserved. Licensed according to the terms of the Revised BSD License. See LICENSE.md for details.