Skip to content

UNC-Libraries/laravel-sierra-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Sierra API

A laravel package for querying the Sierra API.

Installation

  1. Add the following to the "repositories" section of your composer.json file
"repositories":[
        {
            "type":"vcs",
            "url":"https://github.com/UNC-Libraries/laravel-sierra-api.git"
        }
    ],
  1. Add the following to your "require" section of your composer.json file
    "cappdev/laravel-sierra-api": "dev-main",
  1. Run composer update to install the package
  2. Run the following to instantiate the package
php artisan vendor:publish --provider="UncLibrary\SierraApi\SierraApiProvider"
  1. Set up your .env file with the following vars:
SIERRA_API_KEY=
SIERRA_API_SECRET=
SIERRA_API_HOST=

Note: If your Library's Sierra API is configured with a different path than iii/sierra-api you can override that default with a SIERRA_API_PATH var in the .env file.

  1. Add the package as a provider in config/app.php
/*
 * Package Service Providers...
 */
UncLibrary\SierraApi\SierraApiProvider::class,
  1. Add it as a facade
'aliases' => [
    'Sierra' => UncLibrary\SierraApi\SierraApiFacade::class,
]

Usage

In a controller, be sure to include the facade at the top of the file:

use Sierra;

Or in a view:

{!! Sierra::get() !!}

Methods

It's best if you read the Sierra API documentation. This wrapper will automatically create the API connection using OAuth2. You have 2 methods to get data from Sierra.

::get($resource, $params = array())

$resource must be an available restful resource:

  • acquisitions
  • agencies
  • authorities
  • bibs
  • branches
  • info
  • items
  • orders
  • patrons
  • users

$params is an array of parameters to pass to the api.

Example: All patrons created on March 10, 2016

$patrons = Sierra::get('patrons',
    [
        'creadedDate' => ['2016-03-10T00:00:00Z','2016-03-10T23:59:59Z']
    ]
)

Example: All items of a group of bib record ids, limit return fields to status, location, and call number

$patrons = Sierra::get('items',
    [
        'bibIds' => "12345678,23456789,34567890,45678901",
        'fields' => "status,location,callNumber"
    ]
)

::query($resource, $query = array(), $offset = 0, $limit = 20)

$resource must be an available restful resource that allows a query method

  • authorities
  • bibs
  • items
  • orders
  • patrons

$query is an array of query parameters

$offset where to begin the return

$limit How many matches to return

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages