Skip to content

Commit b43aa53

Browse files
committed
Fix Laravel SP, rename baseUrl to entrypoint
1 parent 9421780 commit b43aa53

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ $alma = new AlmaClient('MY_SECRET_API_KEY', 'eu');
7777
```
7878

7979
where `'eu'` is the region code for Europe (use `'na'` for North America or `'ap'` for Asia Pacific).
80-
By default, the API base URL is generated from the region code,
81-
but if you're connecting to the API through a proxy, you can set the base URL directly:
80+
By default, the API entry point URL is generated from the region code,
81+
but if you're connecting to the API through a proxy, you can configure a different URL:
8282

8383
```
8484
$alma = new AlmaClient('MY_SECRET_API_KEY')
85-
->setBaseUrl('https://gw-uio.intark.uh-it.no/alma/v1');
85+
->setEntryPoint('https://gw-uio.intark.uh-it.no/alma/v1');
8686
```
8787

8888
If your Alma instance is connected to a network zone and you want to work

config/alma.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
// SRU URL for institution zone
2222
'sru' => env('ALMA_IZ_SRU_URL'),
2323

24-
// Base URL for institution zone. This only needs to be specified if you
25-
// use a proxy or other non-standard URL.
26-
'baseUrl' => null,
24+
// Entry point URL. This only needs to be specified if you use a proxy
25+
// or other non-standard entry point.
26+
'entrypoint' => null,
2727

2828
// Optional list of extra headers to send with each request.
29-
'extraHeaders' => [
29+
'headers' => [
3030
// 'x-proxy-auth' => 'custom proxy auth'
3131
],
3232
],
@@ -43,12 +43,12 @@
4343
// SRU URL for institution zone
4444
'sru' => env('ALMA_NZ_SRU_URL'),
4545

46-
// Base URL for institution zone. This only needs to be specified if you
47-
// use a proxy or other non-standard URL.
48-
'baseUrl' => null,
46+
// Entry point URL. This only needs to be specified if you use a proxy
47+
// or other non-standard entry point.
48+
'entrypoint' => null,
4949

5050
// Optional list of extra headers to send with each request.
51-
'extraHeaders' => [
51+
'headers' => [
5252
// 'x-proxy-auth' => 'custom proxy auth'
5353
],
5454
],

spec/ClientSpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public function let()
3131
public function it_can_be_configured_with_custom_base_url()
3232
{
3333
$this->beConstructedWith('DummyKey');
34-
$this->setBaseUrl('http://proxy.foxy');
35-
$this->baseUrl->shouldBe('http://proxy.foxy');
34+
$this->setEntryPoint('http://proxy.foxy');
35+
$this->entrypoint->shouldBe('http://proxy.foxy');
3636
}
3737

3838

src/Client.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*/
4242
class Client
4343
{
44-
public $baseUrl;
44+
public $entrypoint;
4545

4646
/** @var string Alma zone (institution or network) */
4747
public $zone;
@@ -89,7 +89,7 @@ class Client
8989
public $sleepTimeOnServerError = 10;
9090

9191
/** @var array Extra request headers */
92-
public $extraHeaders = [];
92+
public $headers = [];
9393

9494
/**
9595
* @var Conf
@@ -115,7 +115,7 @@ class Client
115115
* Create a new client to connect to a given Alma instance.
116116
*
117117
* @param ?string $key API key
118-
* @param string $region Hosted region code, used to build base URL
118+
* @param string $region Hosted region code, used to build the entrypoint URL
119119
* @param string $zone Alma zone (Either Zones::INSTITUTION or Zones::NETWORK)
120120
* @param ?HttpClientInterface $http
121121
* @param ?RequestFactoryInterface $requestFactory
@@ -228,33 +228,33 @@ public function setRegion($regionCode)
228228
if (!in_array($regionCode, ['na', 'eu', 'ap'])) {
229229
throw new AlmaClientException('Invalid region code');
230230
}
231-
$this->setBaseUrl('https://api-' . $regionCode . '.hosted.exlibrisgroup.com/almaws/v1');
231+
$this->setEntryPoint('https://api-' . $regionCode . '.hosted.exlibrisgroup.com/almaws/v1');
232232

233233
return $this;
234234
}
235235

236236
/**
237237
* Set the Alma API base url.
238238
*
239-
* @param string $baseUrl
239+
* @param string $url
240240
* @return $this
241241
*/
242-
public function setBaseUrl(string $baseUrl)
242+
public function setEntryPoint(string $url)
243243
{
244-
$this->baseUrl = $baseUrl;
244+
$this->entrypoint = $url;
245245

246246
return $this;
247247
}
248248

249249
/**
250250
* Set extra request headers.
251251
*
252-
* @param array $extraHeaders
252+
* @param array $headers
253253
* @return $this
254254
*/
255-
public function setExtraHeaders(array $extraHeaders)
255+
public function setExtraHeaders(array $headers)
256256
{
257-
$this->extraHeaders = $extraHeaders;
257+
$this->headers = $headers;
258258

259259
return $this;
260260
}
@@ -277,8 +277,8 @@ public function buildUrl($url, $query = [])
277277

278278
$url = $url[0];
279279

280-
if (strpos($url, $this->baseUrl) === false) {
281-
$url = $this->baseUrl . $url;
280+
if (strpos($url, $this->entrypoint) === false) {
281+
$url = $this->entrypoint . $url;
282282
}
283283

284284
return $this->uriFactory->createUri($url)
@@ -301,7 +301,7 @@ public function request(RequestInterface $request, $attempt = 1)
301301
if (isset($this->key)) {
302302
$request = $request->withHeader('Authorization', 'apikey ' . $this->key);
303303
}
304-
foreach ($this->extraHeaders as $key => $val) {
304+
foreach ($this->headers as $key => $val) {
305305
$request = $request->withHeader($key, $val);
306306
}
307307

src/Laravel/ServiceProvider.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@ public function register()
5454
isset($app[UriFactoryInterface::class]) ? $app[UriFactoryInterface::class] : null
5555
);
5656

57-
if ($app['config']->get('alma.iz.baseUrl')) {
58-
$alma->setBaseUrl($app['config']->get('alma.iz.baseUrl'));
57+
if ($app['config']->get('alma.iz.entrypoint')) {
58+
$alma->setEntryPoint($app['config']->get('alma.iz.entrypoint'));
5959
}
60-
$alma->setExtraHeaders($app['config']->get('alma.extraHeaders', []));
60+
$alma->setExtraHeaders($app['config']->get('alma.iz.headers', []));
6161

6262
// Set network zone key, if any
6363
$alma->nz->setKey($app['config']->get('alma.nz.key'));
6464

65-
if ($app['config']->get('alma.nz.baseUrl')) {
66-
$alma->nz->setBaseUrl($app['config']->get('alma.nz.baseUrl'));
65+
if ($app['config']->get('alma.nz.entrypoint')) {
66+
$alma->nz->setEntryPoint($app['config']->get('alma.nz.entrypoint'));
6767
}
68-
$alma->nz->setExtraHeaders($app['config']->get('alma.nz.extraHeaders', []));
68+
$alma->nz->setExtraHeaders($app['config']->get('alma.nz.headers', []));
6969

7070
// Optionally, attach SRU client for institution zone
7171
if ($app['config']->get('alma.iz.sru')) {

0 commit comments

Comments
 (0)