Test Failed
Push — master ( 99cade...32f37c )
by Dan Michael O.
10:15
created

LendingRequests::urlBase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Scriptotek\Alma\TaskLists;
4
5
use Scriptotek\Alma\Client;
6
use Scriptotek\Alma\Conf\Library;
7
use Scriptotek\Alma\Model\IterableCollection;
8
use Scriptotek\Alma\Model\LazyResourceList;
9
10
/**
11
 * Note to future self:
12
 * The lending requests API returns maximum 100 requests and does not suport pagination.
13
 * The response does include a "total_record_count" field just like the APIs that *do* support
14
 * pagination though, so it almost seems like they just forgot to finalize the pagination support.
15
 * If pagination arrives in the future, we should extend SimplePaginatedList rather than LazyResourceList.
16
 */
17
class LendingRequests extends LazyResourceList implements \Countable, \Iterator
18
{
19
    use IterableCollection;
20
21
    protected $client;
22
    protected $library;
23
24
    /**
25
     * LendingRequests constructor.
26
     *
27
     * @param Client $client
28
     * @param Library $library
29
     * @param array $params
30
     */
31
    public function __construct(Client $client, Library $library, $params = [])
32
    {
33
        parent::__construct($client, 'user_resource_sharing_request');
34
        $this->library = $library;
35
        $params['library'] = $library->code;
36
        $this->params = $params;
37
    }
38
39
    /**
40
     * Generate the base URL for this resource.
41
     *
42
     * @return string
43
     */
44
    protected function urlBase()
45
    {
46
        return '/task-lists/rs/lending-requests';
47
    }
48
49
    /**
50
     * Convert a data element to a resource object.
51
     *
52
     * @param $data
53
     * @return mixed
54
     */
55
    protected function convertToResource($data)
56
    {
57
        return ResourceSharingRequest::make($this->client, $data->request_id)
58
            ->init($data);
59
    }
60
}
61