@@ 11-69 (lines=59) @@ | ||
8 | use Scriptotek\Alma\Model\LazyResourceList; |
|
9 | use Scriptotek\Alma\Model\ReadOnlyArrayAccess; |
|
10 | ||
11 | class ElectronicCollections extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess |
|
12 | { |
|
13 | use ReadOnlyArrayAccess; |
|
14 | use IterableCollection; |
|
15 | ||
16 | /** |
|
17 | * The Bib this ElectronicCollections list belongs to. |
|
18 | * |
|
19 | * @var Bib |
|
20 | */ |
|
21 | public $bib; |
|
22 | ||
23 | /** |
|
24 | * ElectronicCollections constructor. |
|
25 | * |
|
26 | * @param Client $client |
|
27 | * @param Bib $bib |
|
28 | */ |
|
29 | public function __construct(Client $client, Bib $bib) |
|
30 | { |
|
31 | parent::__construct($client, 'electronic_collection'); |
|
32 | $this->bib = $bib; |
|
33 | } |
|
34 | ||
35 | /** |
|
36 | * Get a single electronic collection record by id. |
|
37 | * |
|
38 | * @param string $id |
|
39 | * |
|
40 | * @return Representation |
|
41 | */ |
|
42 | public function get($id) |
|
43 | { |
|
44 | return Collection::make($this->client, $id); |
|
45 | } |
|
46 | ||
47 | /** |
|
48 | * Convert a data element to a resource object. |
|
49 | * |
|
50 | * @param $data |
|
51 | * |
|
52 | * @return Representation |
|
53 | */ |
|
54 | protected function convertToResource($data) |
|
55 | { |
|
56 | return Collection::make($this->client, $data->id) |
|
57 | ->init($data); |
|
58 | } |
|
59 | ||
60 | /** |
|
61 | * Generate the base URL for this resource. |
|
62 | * |
|
63 | * @return string |
|
64 | */ |
|
65 | protected function urlBase() |
|
66 | { |
|
67 | return "/bibs/{$this->bib->mms_id}/e-collections"; |
|
68 | } |
|
69 | } |
|
70 |
@@ 13-71 (lines=59) @@ | ||
10 | /** |
|
11 | * Iterable collection of Holding resources belonging to some Bib resource. |
|
12 | */ |
|
13 | class Holdings extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess |
|
14 | { |
|
15 | use ReadOnlyArrayAccess; |
|
16 | use IterableCollection; |
|
17 | ||
18 | /** |
|
19 | * The Bib this Holdings list belongs to. |
|
20 | * |
|
21 | * @var Bib |
|
22 | */ |
|
23 | public $bib; |
|
24 | ||
25 | /** |
|
26 | * Holdings constructor. |
|
27 | * |
|
28 | * @param Client $client |
|
29 | * @param Bib $bib |
|
30 | */ |
|
31 | public function __construct(Client $client, Bib $bib) |
|
32 | { |
|
33 | parent::__construct($client, 'holding'); |
|
34 | $this->bib = $bib; |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * Get a single holding record by id. |
|
39 | * |
|
40 | * @param string $holding_id |
|
41 | * |
|
42 | * @return Holding |
|
43 | */ |
|
44 | public function get($holding_id) |
|
45 | { |
|
46 | return Holding::make($this->client, $this->bib, $holding_id); |
|
47 | } |
|
48 | ||
49 | /** |
|
50 | * Convert a data element to a resource object. |
|
51 | * |
|
52 | * @param $data |
|
53 | * |
|
54 | * @return Holding |
|
55 | */ |
|
56 | protected function convertToResource($data) |
|
57 | { |
|
58 | return Holding::make($this->client, $this->bib, $data->holding_id) |
|
59 | ->init($data); |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * Generate the base URL for this resource. |
|
64 | * |
|
65 | * @return string |
|
66 | */ |
|
67 | protected function urlBase() |
|
68 | { |
|
69 | return "/bibs/{$this->bib->mms_id}/holdings"; |
|
70 | } |
|
71 | } |
|
72 |
@@ 10-68 (lines=59) @@ | ||
7 | use Scriptotek\Alma\Model\LazyResourceList; |
|
8 | use Scriptotek\Alma\Model\ReadOnlyArrayAccess; |
|
9 | ||
10 | class Portfolios extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess |
|
11 | { |
|
12 | use ReadOnlyArrayAccess; |
|
13 | use IterableCollection; |
|
14 | ||
15 | /** |
|
16 | * The Bib this Portfolios list belongs to. |
|
17 | * |
|
18 | * @var Bib |
|
19 | */ |
|
20 | public $bib; |
|
21 | ||
22 | /** |
|
23 | * Portfolios constructor. |
|
24 | * |
|
25 | * @param Client $client |
|
26 | * @param Bib $bib |
|
27 | */ |
|
28 | public function __construct(Client $client, Bib $bib) |
|
29 | { |
|
30 | parent::__construct($client, 'portfolio'); |
|
31 | $this->bib = $bib; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * Get a single portfolio record by id. |
|
36 | * |
|
37 | * @param string $id |
|
38 | * |
|
39 | * @return Portfolio |
|
40 | */ |
|
41 | public function get($id) |
|
42 | { |
|
43 | return Portfolio::make($this->client, $this->bib, $id); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * Convert a data element to a resource object. |
|
48 | * |
|
49 | * @param $data |
|
50 | * |
|
51 | * @return Portfolio |
|
52 | */ |
|
53 | protected function convertToResource($data) |
|
54 | { |
|
55 | return Portfolio::make($this->client, $this->bib, $data->id) |
|
56 | ->init($data); |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * Generate the base URL for this resource. |
|
61 | * |
|
62 | * @return string |
|
63 | */ |
|
64 | protected function urlBase() |
|
65 | { |
|
66 | return "/bibs/{$this->bib->mms_id}/portfolios"; |
|
67 | } |
|
68 | } |
|
69 |
@@ 10-68 (lines=59) @@ | ||
7 | use Scriptotek\Alma\Model\LazyResourceList; |
|
8 | use Scriptotek\Alma\Model\ReadOnlyArrayAccess; |
|
9 | ||
10 | class Representations extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess |
|
11 | { |
|
12 | use ReadOnlyArrayAccess; |
|
13 | use IterableCollection; |
|
14 | ||
15 | /** |
|
16 | * The Bib this Representations list belongs to. |
|
17 | * |
|
18 | * @var Bib |
|
19 | */ |
|
20 | public $bib; |
|
21 | ||
22 | /** |
|
23 | * Representations constructor. |
|
24 | * |
|
25 | * @param Client $client |
|
26 | * @param Bib $bib |
|
27 | */ |
|
28 | public function __construct(Client $client, Bib $bib) |
|
29 | { |
|
30 | parent::__construct($client, 'representation'); |
|
31 | $this->bib = $bib; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * Get a single representation record by id. |
|
36 | * |
|
37 | * @param string $id |
|
38 | * |
|
39 | * @return Representation |
|
40 | */ |
|
41 | public function get($id) |
|
42 | { |
|
43 | return Representation::make($this->client, $this->bib, $id); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * Convert a data element to a resource object. |
|
48 | * |
|
49 | * @param $data |
|
50 | * |
|
51 | * @return Representation |
|
52 | */ |
|
53 | protected function convertToResource($data) |
|
54 | { |
|
55 | return Representation::make($this->client, $this->bib, $data->id) |
|
56 | ->init($data); |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * Generate the base URL for this resource. |
|
61 | * |
|
62 | * @return string |
|
63 | */ |
|
64 | protected function urlBase() |
|
65 | { |
|
66 | return "/bibs/{$this->bib->mms_id}/representations"; |
|
67 | } |
|
68 | } |
|
69 |
@@ 14-68 (lines=55) @@ | ||
11 | /** |
|
12 | * Iterable collection of Job Instances. |
|
13 | */ |
|
14 | class JobInstances extends SimplePaginatedList implements \ArrayAccess, \Countable, \Iterator |
|
15 | { |
|
16 | use ReadOnlyArrayAccess; |
|
17 | use IterableCollection; |
|
18 | ||
19 | /** @var Job */ |
|
20 | public $job; |
|
21 | ||
22 | /** |
|
23 | * Job Instances constructor. |
|
24 | * |
|
25 | * @param Client $client |
|
26 | * @param Job $job |
|
27 | */ |
|
28 | public function __construct(Client $client, Job $job) |
|
29 | { |
|
30 | parent::__construct($client, 'job_instance'); |
|
31 | $this->job = $job; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * Get a single Job Instance by its instance_id. |
|
36 | * |
|
37 | * @param string $instance_id |
|
38 | * |
|
39 | * @return JobInstance |
|
40 | */ |
|
41 | public function get(string $instance_id) |
|
42 | { |
|
43 | return JobInstance::make($this->client, $this->job, $instance_id); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * Convert a data element to a resource object. |
|
48 | * |
|
49 | * @param $data |
|
50 | * |
|
51 | * @return JobInstance |
|
52 | */ |
|
53 | protected function convertToResource($data) |
|
54 | { |
|
55 | return JobInstance::make($this->client, $this->job, $data->id) |
|
56 | ->init($data); |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * Generate the base URL for this resource. |
|
61 | * |
|
62 | * @return string |
|
63 | */ |
|
64 | protected function urlBase() |
|
65 | { |
|
66 | return "/conf/jobs/{$this->job->job_id}/instances"; |
|
67 | } |
|
68 | } |
|
69 |
@@ 13-71 (lines=59) @@ | ||
10 | /** |
|
11 | * Iterable collection of Location resources. |
|
12 | */ |
|
13 | class Locations extends LazyResourceList implements \ArrayAccess, \Countable, \Iterator |
|
14 | { |
|
15 | use ReadOnlyArrayAccess; |
|
16 | use IterableCollection; |
|
17 | ||
18 | /** |
|
19 | * The Library this Locations list belongs to. |
|
20 | * |
|
21 | * @var Library |
|
22 | */ |
|
23 | protected $library; |
|
24 | ||
25 | /** |
|
26 | * Locations constructor. |
|
27 | * |
|
28 | * @param Client $client |
|
29 | * @param Library $library |
|
30 | */ |
|
31 | public function __construct(Client $client, Library $library) |
|
32 | { |
|
33 | parent::__construct($client, 'location'); |
|
34 | $this->library = $library; |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * Get a single location by its location code. |
|
39 | * |
|
40 | * @param string $code |
|
41 | * |
|
42 | * @return Location |
|
43 | */ |
|
44 | public function get($code) |
|
45 | { |
|
46 | return Location::make($this->client, $this->library, $code); |
|
47 | } |
|
48 | ||
49 | /** |
|
50 | * Convert a data element to a resource object. |
|
51 | * |
|
52 | * @param $data |
|
53 | * |
|
54 | * @return Location |
|
55 | */ |
|
56 | protected function convertToResource($data) |
|
57 | { |
|
58 | return Location::make($this->client, $this->library, $data->code) |
|
59 | ->init($data); |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * Generate the base URL for this resource. |
|
64 | * |
|
65 | * @return string |
|
66 | */ |
|
67 | protected function urlBase() |
|
68 | { |
|
69 | return "/conf/libraries/{$this->library->code}/locations"; |
|
70 | } |
|
71 | } |
|
72 |
@@ 13-70 (lines=58) @@ | ||
10 | /** |
|
11 | * Iterable collection of Fee resources. |
|
12 | */ |
|
13 | class Fees extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess |
|
14 | { |
|
15 | use ReadOnlyArrayAccess; |
|
16 | use IterableCollection; |
|
17 | ||
18 | /** |
|
19 | * The User object this Fees list belongs to. |
|
20 | * |
|
21 | * @var User |
|
22 | */ |
|
23 | public $user; |
|
24 | ||
25 | /** |
|
26 | * Fees constructor. |
|
27 | * |
|
28 | * @param Client $client |
|
29 | * @param User $user |
|
30 | */ |
|
31 | public function __construct(Client $client, User $user) |
|
32 | { |
|
33 | parent::__construct($client, 'fee'); |
|
34 | $this->user = $user; |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * Get a single Fee by id. |
|
39 | * |
|
40 | * @param string $id |
|
41 | * |
|
42 | * @return Fee |
|
43 | */ |
|
44 | public function get($id) |
|
45 | { |
|
46 | return Fee::make($this->client, $this->user, $id); |
|
47 | } |
|
48 | ||
49 | /** |
|
50 | * Convert a retrieved resource object to a model object. |
|
51 | * |
|
52 | * @param $data |
|
53 | * |
|
54 | * @return Fee |
|
55 | */ |
|
56 | public function convertToResource($data) |
|
57 | { |
|
58 | return $this->get($data->id)->init($data); |
|
59 | } |
|
60 | ||
61 | /** |
|
62 | * Generate the base URL for this resource. |
|
63 | * |
|
64 | * @return string |
|
65 | */ |
|
66 | protected function urlBase() |
|
67 | { |
|
68 | return sprintf('/users/%s/fees', rawurlencode($this->user->id)); |
|
69 | } |
|
70 | } |
|
71 |
@@ 13-54 (lines=42) @@ | ||
10 | /** |
|
11 | * Iterable collection of Request resources. |
|
12 | */ |
|
13 | class Requests extends LazyResourceList implements \Countable, \Iterator, \ArrayAccess |
|
14 | { |
|
15 | use ReadOnlyArrayAccess; |
|
16 | use IterableCollection; |
|
17 | ||
18 | protected $_urlBase; |
|
19 | ||
20 | /** |
|
21 | * Requests constructor. |
|
22 | * |
|
23 | * @param Client $client |
|
24 | * @param string $url |
|
25 | */ |
|
26 | public function __construct(Client $client, $url) |
|
27 | { |
|
28 | parent::__construct($client, 'user_request'); |
|
29 | $this->_urlBase = $url; |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * Convert a data element to a resource object. |
|
34 | * |
|
35 | * @param $data |
|
36 | * |
|
37 | * @return Request |
|
38 | */ |
|
39 | protected function convertToResource($data) |
|
40 | { |
|
41 | return Request::make($this->client, User::make($this->client, $data->user_primary_id), $data->request_id) |
|
42 | ->init($data); |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * Generate the base URL for this resource. |
|
47 | * |
|
48 | * @return string |
|
49 | */ |
|
50 | protected function urlBase() |
|
51 | { |
|
52 | return $this->_urlBase; |
|
53 | } |
|
54 | } |
|
55 |