multnomah-county-it / libilsws
PHP 包,用于支持 SirsiDynix Symphony Web 服务 API (ILSWS) 的使用
v1.2.7
2024-09-26 15:17 UTC
Requires
- php: >=5.6.0
- curl/curl: >=2.3
- phpmailer/phpmailer: ^6.9
- symfony/yaml: ~4||~5.4||~6
- twig/twig: ^3.0
Requires (Dev)
- symfony/var-dumper: ^6.0
This package is auto-updated.
Last update: 2024-09-26 15:19:05 UTC
README
PHP 包,用于支持 SirsiDynix Symphony Web 服务 API (ILSWS) 的读者功能
John Houser john.houser@multco.us
设计目标
- 验证所有公共函数的输入
- 生成干净、清晰的错误消息
- 尽可能防止或替换 SirsiDynix 错误消息(有时可能难以理解)
- 提供创建、修改、搜索和验证读者的简单、高级函数
- 为所有函数提供代码示例
- 支持无需代码更改即可轻松重新配置,以反映 Symphony 配置的更改
- 支持无需代码更改即可注册或更新任何有效的 Symphony 读者字段
- 允许其他库轻松适应
公共函数
低级
这些函数可以与任何有效的 ILSWS 访问点一起使用。它们在发生错误时会抛出异常。
- connect ()
- send_get($url, $token, $params)
- send_query($url, $token, $query_json, $query_type)
便利函数
这些函数对应于 ILSWS 访问点,但它们验证所有输入,并在遇到不适当的输入时抛出异常。
- authenticate_patron($token, $patron_id, $password)
- change_barcode($token, $patron_key, $patron_id, $options)
选项数组可能包括:role, client_id - change_item_library($token, $item_key, $library)
- change_patron_password($token, $json, $options)
选项数组可能包括:role, client_id - delete_patron($token, $patron_key)
- describe_bib($token)
- describe_item($token)
- describe_patron($token)
- get_expiration($days)
- get_policy($token, $policy_key)
- search_patron($token, $index, $search, $params)
- search_patron_alt_id($token, $alt_id, $count)
- search_patron_id($token, $patron_id, $count)
- transit_item($token, $item_key, $new_library, $working_library)
- untransit_item($token, $item_id)
- update_patron_activity($token, $patron_id)
高级
这些函数通过执行多个查询或组合、操作或评估 Symphony 系统中的数据来提供 ILSWS 不直接支持的功能。
- authenticate_patron_id($token, $patron_id, $password)
- check_duplicate($token, $index1, $search1, $index2, $search2)
- email_template($patron, $to, $from, $subject, $template)
- get_bib($token, $bib_key, $field_list)
- get_bib_circ_info($token, $bib_key)
- get_bib_marc($token, $bib_key)
- get_call_number($token, $call_key, $field_list)
- get_catalog_indexes($token)
- get_hold($token, $hold_key)
- get_item($token, $item_key, $field_list)
- get_item_circ_info($token, $item_key)
- get_library_paging_list($token, $library_key)
- get_patron_attributes($token, $patron_key)
- get_patron_checkouts($token, $patron_key, $include_fields)
- get_patron_indexes($token)
- prepare_search($terms)
- register_patron($patron, $token, $addr_num, $options)
选项数组可能包括:role, client_id, template, subject - reset_patron_password($token, $patron_id, $url, $email)
可选:email - search_authenticate($token, $index, $search, $password)
- search_bib($token, $index, $value, $params)
Params 数组可能包括:q, ct, rw, j, includeFields - update_patron($patron, $token, $patron_key, $addr_num)
- update_patron_activeid($token, $patron_key, $patron_id, $option)
选项可能为:a, i, d - update_phone_list($phone_list, $token, $patron_key, $options)
选项数组可能包括:role, client_id
日期和电话号码格式
为了方便开发者,代码库接受以下格式的日期,无论何时日期作为参数接受:YYYYMMDD,YYYY-MM-DD,YYYY/MM/DD,MM-DD-YYYY或MM/DD/YYYY。
电话号码的验证规则目前设置为期望一个没有标点的数字字符串。但是,很容易修改任何公共函数顶部的验证规则,以接受电话号码中的标点。
示例
初始化并连接到ILSWS
require_once 'vendor/autoload.php';
// Initialize and load configuration from YAML configuration file
$ilsws = new Libilsws\Libilsws('./libilsws.yaml');
// Connect to ILSWS with configuration loaded from YAML file
$token = $ilsws->connect();
搜索读者
/**
* Valid incoming params are:
* ct = number of results to return,
* rw = row to start on (so you can page through results),
* j = boolean AND or OR to use with multiple search terms, and
* includeFields = fields to return in result.
*/
$index = 'EMAIL';
$search = 'john.houser@multco.us';
// Prepare search parameters, including fields to return
$options = [
'rw' => 1,
'ct' => 10,
'j' => 'AND',
'includeFields' => 'key,barcode']
];
// Run search
$response = $ilsws->search_patron($token, $index, $search, $options);
获取读者属性
$response = $ilsws->get_patron_attributes($token, $patron_key);
注册新读者
/**
* The order of the fields doesn't matter. Not all of these are actually required.
* See the YAML configuration file to determine which fields are required. If an
* email template name is included in the options array, an email will be sent to the
* patron. Actual template files must include a language extension (for example .en for
* English. The system will look for template that matches the patrons language
* preference. If one is found, it will use that, otherwise it will attempt to
* find and use an English template.
*/
$patron = [
'birthDate' => '1962-03-07',
'city_state' => 'Portland, OR',
'county' => '0_MULT',
'email' => 'johnchouser@gmail.com',
'firstName' => 'Bogus',
'friends_notices' => 'YES',
'home_library' => 'CEN',
'language' => 'ENGLISH',
'lastName' => 'Bogart',
'library_news' => 'YES',
'middleName' => 'T',
'notice_type' => 'PHONE',
'patron_id' => '21168045918653',
'postal_code' => '97209',
'street' => '925 NW Hoyt St Apt 406',
'telephone' => '215-534-6821',
'sms_phone' => [
'number' => '215-534-6821',
'countryCode' => 'US',
'bills' => true,
'general' => true,
'holds' => true,
'manual' => true,
'overdues' => true,
],
];
$addr_num = 1;
$options = [];
$options['role'] = 'STAFF';
$options['client_id'] = 'StaffClient';
$options['template'] = 'template.html.twig';
$options['subject'] = 'Welcome to the library!';
$response = $ilsws->register_patron($patron, $token, $addr_num, $options);
更新读者记录
// Define patron array
$patron = [
'firstName' => 'John',
'middleName' => 'Rad',
'lastName' => 'Houser',
'birthDate' => '1972-03-10',
'home_library' => 'CEN',
'county' => '0_MULT',
'notice_type' => 'PHONE',
'library_news' => 'YES',
'friends_notices' => 'YES',
'online_update' => 'YES',
'street' => '925 NW Hoyt St Apt 606',
'city_state' => 'Portland, OR',
'patron_id' => '21168045918653',
'postal_code' => '97208',
'email' => 'john.houser@multco.us',
'telephone' => '215-544-6941',
'sms_phone' => [
'number' => '215-544-6941',
'countryCode => 'US',
'bills' => true,
'general' => true,
'holds' => true,
'manual' => true,
'overdues' => true,
],
];
$addr_num = 1;
$patron_key = '782339';
// Update the patron record
$response = $ilsws->update_patron($patron, $token, $patron_key, $addr_num);
搜索书目记录
/**
* Convert UTF-8 characters with accents to ASCII and strip unwanted characters and
* boolean operators from search terms
*/
$search = $ilsws->prepare_search($search);
// Prepare search parameters and choose fields to return
$params = [
'ct' => '50',
'rw' => '1',
'j' => 'AND',
'includeFields' => 'author,title,bib{650_a,856_u},callList{callNumber,itemList{barcode,currentLocation}}'
];
// Run search
$response = $ilsws->search_bib($token, $index, $search, $params);
关于includeFields参数的说明
- 要按标签包含MARC数据,请添加一个书目项。例如,要获取650标签,子字段a,添加:
bib{650_a}
- 要获取索书号或任何项目记录中的项目,您必须包含一个callList项。例如,添加:
callList{callNumber}
- 要获取项目记录中的任何字段,您必须在callList项中包含一个itemList条目。例如,要获取条形码,添加:
callList{itemList{barcode}}
更多信息
有关字段定义和YAML配置选项的文档,请参阅libilsws.yaml.sample文件。
有关完整的代码示例,请参阅test
目录中的示例脚本。
警告:测试脚本可能会对配置的Symphony系统进行实际更改。请在生产系统上使用之前仔细审查它们所做的一切!