GithubHelp home page GithubHelp logo

php-alma-client's People

Contributors

ctgraham avatar danmichaelo avatar pbek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-alma-client's Issues

UTF-16 and UTF-8 encoding error in XmlImporter

XmlImporter will trigger an error while reading xml depending on the version of Alma.
Alma might return an XML document in the wrong encoding, encoding in XML file is said to be UTF-16 but actually it is UTF-8.
A solution is to catch this error, then change the encoding in the XML using a preg_replace from UTF-16 to UTF-8 and then parse the XML file.

See attached XMLImporter file
XmlImporter.php.zip

The Alma Users API can return a lower number of results than reported

curl -X GET --header 'Accept: application/json; charset=utf-8' --header 'Authorization: apikey {key}' 'https://api-eu.hosted.exlibrisgroup.com/almaws/v1/users?limit=5&[email protected]' | jq '.'

gives "total_record_count": 5, but only 3 records are returned. Anonymized response:

{
  "user": [
    {
      "primary_id": "li",
      "first_name": "Li",
      "last_name": "Aker",
      "gender": {
        "value": "FEMALE",
        "desc": "Female"
      },
      "password": "",
      "status": {
        "value": "ACTIVE",
        "desc": "Active"
      },
      "requests": null,
      "loans": null,
      "fees": null,
      "link": "https://api-eu.hosted.exlibrisgroup.com/almaws/v1/users/li"
    },
    {
      "primary_id": "n003548402",
      "first_name": "Stein",
      "last_name": "Gal",
      "gender": {
        "value": "",
        "desc": ""
      },
      "password": "",
      "status": {
        "value": "ACTIVE",
        "desc": "Active"
      },
      "requests": null,
      "loans": null,
      "fees": null,
      "link": "https://api-eu.hosted.exlibrisgroup.com/almaws/v1/users/n003548402"
    },
    {
      "primary_id": "N003548424",
      "first_name": "Sol",
      "last_name": "Storm",
      "gender": {
        "value": "",
        "desc": ""
      },
      "password": "",
      "status": {
        "value": "ACTIVE",
        "desc": "Active"
      },
      "requests": null,
      "loans": null,
      "fees": null,
      "link": "https://api-eu.hosted.exlibrisgroup.com/almaws/v1/users/N003548424"
    }
  ],
  "total_record_count": 5
}

Ignore users without primary id

Today's surprise: The Alma users API can return users without any identifiers! 😲 Within the normal Alma GUI these are shown as "contacts".

Another weird thing is that the primary_id field is not something like null, but a not very machine-friendly string: "no primary id (123456789023)". Here's a full (anonymized) response example:

    {
      "primary_id": "no primary id (123456789023)",
      "first_name": "Hans",
      "last_name": "Jonas",
      "gender": {
        "value": "",
        "desc": ""
      },
      "status": {
        "value": "ACTIVE",
        "desc": "Active"
      },
      "requests": null,
      "loans": null,
      "fees": null,
      "link": "https://api-eu.hosted.exlibrisgroup.com/almaws/v1/users/-"
    }

Also notice that the link field is also not null, but an invalid URL that can not be dereferenced.

Language support

Following documentation of Alma API at
https://developers.exlibrisgroup.com/alma/apis/#lang

Language Support
By default all APIs return error messages and textual information in English. To run an API with another language include the ‘lang’ parameter with a 2 letter code of the language. E.g. for French: ...&lang=fr. Note that only languages which are enabled in Alma can be used (according to ‘Institution Languages’ mapping-table).

Adding this "extra parameter" to AlmaClient can make easier to handle multiple language instances.

I solved the issue for the moment extending AlmaClient:

class LocalizedAlmaClient extends  AlmaClient {
  
    public $lang;

    public function __construct(
        $key = null,
        $region = 'eu',
        $lang = 'en',
        $zone = Zones::INSTITUTION,
        HttpClientInterface $http = null,
        RequestFactoryInterface $requestFactory = null,
        UriFactoryInterface $uriFactory = null
    ) {
        $this->lang = $lang;
        parent::__construct($key,$region,$zone,$http,$requestFactory,$uriFactory);
    }

    public function buildUrl($url, $query = [])
    {
        $url = explode('?', $url, 2);
        if (count($url) == 2) {
            parse_str($url[1], $query0);
            $query = array_merge($query0, $query);
        }
        $query['apikey'] = $this->key;
        $query['lang'] = $this->lang;

        $url = $url[0];

        if (strpos($url, $this->baseUrl) === false) {
            $url = $this->baseUrl . $url;
        }

        return $this->uriFactory->createUri($url)
            ->withQuery(http_build_query($query));
    }
}

Implementing updates to Alma Users

Love this client SDK so far, but I need to be able to perform an update to the User. I've forked the client and plan to add this feature locally and then via pull request.

Do y'all have any preferences/requirements as to how this is implemented?

I'm up for adding dedicated helper methods ala $bib->record->appendField(), or just adding support via the Users class to update( $identifier, $json ) or update( $identifier, $User) or store( $User ).

In particular, we will immediately be targeting updating Addresses and Fines/Fees.

@danmichaelo ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.