|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace lordelph\SIP2\Response; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class HoldResponse provides the response from a HoldRequest |
|
7
|
|
|
* |
|
8
|
|
|
* @method getOk() |
|
9
|
|
|
* @method getAvailable() |
|
10
|
|
|
* @method getTransactionDate() |
|
11
|
|
|
* @method getExpirationDate() |
|
12
|
|
|
* @method getQueuePosition() |
|
13
|
|
|
* @method getPickupLocation() |
|
14
|
|
|
* @method getInstitutionId() |
|
15
|
|
|
* @method getPatronIdentifier() |
|
16
|
|
|
* @method getItemIdentifier() |
|
17
|
|
|
* @method getTitleIdentifier() |
|
18
|
|
|
* @method getScreenMessage() |
|
19
|
|
|
* @method getPrintLine() |
|
20
|
|
|
* @method getSequenceNumber() |
|
21
|
|
|
* |
|
22
|
|
|
* @licence https://opensource.org/licenses/MIT |
|
23
|
|
|
* @copyright John Wohlers <[email protected]> |
|
24
|
|
|
* @copyright Paul Dixon <[email protected]> |
|
25
|
|
|
*/ |
|
26
|
|
|
class HoldResponse extends SIP2Response |
|
27
|
|
|
{ |
|
28
|
|
|
//fixed part of response contains these |
|
29
|
|
|
protected $var = [ |
|
30
|
|
|
'Ok' => [], |
|
31
|
|
|
'Available' => [], |
|
32
|
|
|
'TransactionDate' => [] |
|
33
|
|
|
]; |
|
34
|
|
|
|
|
35
|
|
|
//variable part of the response allowed to contain these... |
|
36
|
|
|
protected $allowedVariables=[ |
|
37
|
|
|
self::BW_EXPIRATION_DATE, |
|
38
|
|
|
self::BR_QUEUE_POSITION, |
|
39
|
|
|
self::BS_PICKUP_LOCATION, |
|
40
|
|
|
self::AO_INSTITUTION_ID, |
|
41
|
|
|
self::AA_PATRON_IDENTIFIER, |
|
42
|
|
|
self::AB_ITEM_IDENTIFIER, |
|
43
|
|
|
self::AJ_TITLE_IDENTIFIER, |
|
44
|
|
|
self::AF_SCREEN_MESSAGE, |
|
45
|
|
|
self::AG_PRINT_LINE, |
|
46
|
|
|
self::AY_SEQUENCE_NUMBER |
|
47
|
|
|
]; |
|
48
|
|
|
|
|
49
|
1 |
|
public function __construct($raw) |
|
50
|
|
|
{ |
|
51
|
|
|
/* |
|
52
|
|
|
* $result = []; |
|
53
|
|
|
$result['fixed'] = |
|
54
|
|
|
[ |
|
55
|
|
|
'Ok' => substr($response, 2, 1), |
|
56
|
|
|
'available' => substr($response, 3, 1), |
|
57
|
|
|
'TransactionDate' => substr($response, 4, 18) |
|
58
|
|
|
]; |
|
59
|
|
|
|
|
60
|
|
|
//expiration date is optional an indicated by BW |
|
61
|
|
|
$variableOffset = 22; |
|
62
|
|
|
if (substr($response, 22, 2) === 'BW') { |
|
63
|
|
|
$result['fixed']['ExpirationDate'] = substr($response, 24, 18); |
|
64
|
|
|
$variableOffset = 42; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$result['variable'] = $this->parseVariableData($response, $variableOffset); |
|
68
|
|
|
*/ |
|
69
|
1 |
|
$this->setVariable('Ok', substr($raw, 2, 1)); |
|
70
|
1 |
|
$this->setVariable('Available', substr($raw, 3, 1)); |
|
71
|
1 |
|
$this->setVariable('TransactionDate', substr($raw, 4, 18)); |
|
72
|
1 |
|
$this->parseVariableData($raw, 22); |
|
73
|
1 |
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|