Skip to content

Commit 0955e18

Browse files
authored
Merge pull request #76 from Jamie4224/master
Configurable Entry parameters
2 parents 9b7ca29 + ff19978 commit 0955e18

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ There are 2 main ways to work with models, to call them directly from the access
114114
$user = new \MacsiDigital\Zoom\User($zoom);
115115
```
116116

117+
### Custom settings
118+
If you would like to use different configuration values than those in your zoom.php config file, you can feed those as parameters to \MacsiDigital\Zoom\Support\Entry as shown below.
119+
``` php
120+
$zoom = new \MacsiDigital\Zoom\Support\Entry($apiKey, $apiSecret, $tokenLife, $maxQueries, $baseUrl);
121+
```
122+
117123
### Working with models
118124

119125
As noted we are aiming for functionality similar to Laravel, so most things that you can do in Laravel you can do here, with exception to any database specific functionality, as we are not using databases.

src/Support/Entry.php

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ class Entry extends ApiEntry
1414

1515
protected $maxQueries = '5';
1616

17+
protected $apiKey = null;
18+
19+
protected $apiSecret = null;
20+
21+
protected $tokenLife = null;
22+
23+
protected $baseUrl = null;
24+
1725
// Amount of pagination results per page by default, leave blank if should not paginate
1826
// Without pagination rate limits could be hit
1927
protected $defaultPaginationRecords = '30';
@@ -28,11 +36,21 @@ class Entry extends ApiEntry
2836

2937
protected $allowedOperands = ['='];
3038

31-
public function __construct()
39+
/**
40+
* Entry constructor.
41+
* @param $apiKey
42+
* @param $apiSecret
43+
* @param $tokenLife
44+
* @param $maxQueries
45+
* @param $baseUrl
46+
*/
47+
public function __construct($apiKey = null, $apiSecret = null, $tokenLife = null, $maxQueries = null, $baseUrl = null)
3248
{
33-
if (config('zoom.max_api_calls_per_request') != null) {
34-
$this->maxQueries = config('zoom.max_api_calls_per_request');
35-
}
49+
$this->apiKey = $apiKey ? $apiKey : config('zoom.api_key');
50+
$this->apiSecret = $apiSecret ? $apiSecret : config('zoom.api_secret');
51+
$this->tokenLife = $tokenLife ? $tokenLife : config('zoom.token_life');
52+
$this->maxQueries = $maxQueries ? $maxQueries : (config('zoom.max_api_calls_per_request') ? config('zoom.max_api_calls_per_request') : $this->maxQueries);
53+
$this->baseUrl = $baseUrl ? $baseUrl : config('zoom.base_url');
3654
}
3755

3856
public function newRequest()
@@ -45,9 +63,9 @@ public function newRequest()
4563

4664
public function jwtRequest()
4765
{
48-
$jwtToken = JWT::generateToken(['iss' => config('zoom.api_key'), 'exp' => time() + config('zoom.token_life')], config('zoom.api_secret'));
49-
50-
return Client::baseUrl(config('zoom.base_url'))->withToken($jwtToken);
66+
$jwtToken = JWT::generateToken(['iss' => $this->apiKey, 'exp' => time() + $this->tokenLife], $this->apiSecret);
67+
68+
return Client::baseUrl($this->baseUrl)->withToken($jwtToken);
5169
}
5270

5371
public function oauth2Request()

0 commit comments

Comments
 (0)