forked from odensecentralbibliotek/sms_service
-
Notifications
You must be signed in to change notification settings - Fork 1
/
alma_reminder_service.inc
54 lines (49 loc) · 1.4 KB
/
alma_reminder_service.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @file
*/
/**
* Missing define in ALMA client.
*/
define('ALMA_SERVICE_METHOD_EMAIL', 'email');
/**
* SMS Service wrapper.
*
* A small wrapper fro missing ALMA functionality.
*/
class Smsservice extends AlmaClient {
/**
* Implements to check messages service in patron (not implemented in original alma module only implemented add and remove messages).
*
* @param string $borr_card
* User CPR.
* @param string $pin_code
* User password.
* @param bool $extended
* Whether to fetch extended user data.
*
* @return array
* An array with enabled reminder options.
*/
function GetPatronInfo($borr_card, $pin_code, $extended = FALSE) {
$path = ($extended) ? 'patron/informationExtended' : 'patron/information';
$info_node = ($extended) ? 'patronInformationExtended' : 'patronInformation';
$doc = $this->request($path, array(
'borrCard' => $borr_card,
'pinCode' => $pin_code
));
$info = $doc->getElementsByTagName($info_node)->item(0);
$message_services = $info->getElementsByTagName('messageServices');
$data = array(
'messageServices' => !empty($message_services),
'sendMethods' => array(),
);
// The missing part.
foreach ($info->getElementsByTagName('sendMethod') as $type) {
$data['sendMethods'][] = array(
'value' => $type->getAttribute('value'),
);
}
return $data;
}
}