| @@ 12-61 (lines=50) @@ | ||
| 9 | /** |
|
| 10 | * A single Fee resource. |
|
| 11 | */ |
|
| 12 | class Fee extends LazyResource |
|
| 13 | { |
|
| 14 | /* @var User */ |
|
| 15 | protected $user; |
|
| 16 | ||
| 17 | /* @var string */ |
|
| 18 | protected $id; |
|
| 19 | ||
| 20 | public function __construct(Client $client, User $user, $id) |
|
| 21 | { |
|
| 22 | parent::__construct($client); |
|
| 23 | $this->user = $user; |
|
| 24 | $this->id = $id; |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * Generate the base URL for this resource. |
|
| 29 | * |
|
| 30 | * @return string |
|
| 31 | */ |
|
| 32 | protected function urlBase() |
|
| 33 | { |
|
| 34 | return "/users/{$this->user->id}/fees/{$this->id}"; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Check if we have the full representation of our data object. |
|
| 39 | * |
|
| 40 | * @param \stdClass $data |
|
| 41 | * @return boolean |
|
| 42 | */ |
|
| 43 | protected function isInitialized($data) |
|
| 44 | { |
|
| 45 | return isset($data->link); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Get the related Item, if any. |
|
| 50 | * |
|
| 51 | * @return Item|null |
|
| 52 | */ |
|
| 53 | public function getItem() |
|
| 54 | { |
|
| 55 | if (isset($this->barcode)) { |
|
| 56 | return $this->client->items->fromBarcode($this->barcode); |
|
| 57 | } |
|
| 58 | ||
| 59 | return null; |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||
| @@ 12-61 (lines=50) @@ | ||
| 9 | /** |
|
| 10 | * A single Loan resource. |
|
| 11 | */ |
|
| 12 | class Loan extends LazyResource |
|
| 13 | { |
|
| 14 | /* @var User */ |
|
| 15 | protected $user; |
|
| 16 | ||
| 17 | /* @var string */ |
|
| 18 | protected $loan_id; |
|
| 19 | ||
| 20 | public function __construct(Client $client, User $user, $loan_id) |
|
| 21 | { |
|
| 22 | parent::__construct($client); |
|
| 23 | $this->user = $user; |
|
| 24 | $this->loan_id = $loan_id; |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * Generate the base URL for this resource. |
|
| 29 | * |
|
| 30 | * @return string |
|
| 31 | */ |
|
| 32 | protected function urlBase() |
|
| 33 | { |
|
| 34 | return "/users/{$this->user->id}/loans/{$this->loan_id}"; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Check if we have the full representation of our data object. |
|
| 39 | * |
|
| 40 | * @param \stdClass $data |
|
| 41 | * @return boolean |
|
| 42 | */ |
|
| 43 | protected function isInitialized($data) |
|
| 44 | { |
|
| 45 | return isset($data->loan_id); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Get the Item on loan. Since the response from the loan(s) API does not |
|
| 50 | * include the `holding_id` and `item_pid`, we cannot initiate an Item object |
|
| 51 | * directly, so we have to lookup the barcode instead. |
|
| 52 | * |
|
| 53 | * @see https://developers.exlibrisgroup.com/discussions#!/forum/posts/list/1397.page |
|
| 54 | * |
|
| 55 | * @return Item |
|
| 56 | */ |
|
| 57 | public function getItem() |
|
| 58 | { |
|
| 59 | return $this->client->items->fromBarcode($this->item_barcode); |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||