Project

dpn-client

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A client to process the DPN api.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 2.8.0
 Project Readme

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.