Skip to content

Commit 36a3484

Browse files
committed
allow additional config to be passed through to client
1 parent 0e71c68 commit 36a3484

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

src/Client.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(array $config, $userEmail = '')
2626
$this->config = $config;
2727

2828
// create an instance of the google client for OAuth2
29-
$this->client = new Google_Client();
29+
$this->client = new Google_Client(array_get($config, 'config', []));
3030

3131
// set application name
3232
$this->client->setApplicationName(array_get($config, 'application_name', ''));
@@ -62,7 +62,7 @@ public function getClient()
6262
* Setter for the google client.
6363
*
6464
* @param string $client
65-
*
65+
*
6666
* @return self
6767
*/
6868
public function setClient(Google_Client $client)
@@ -126,7 +126,7 @@ protected function useAssertCredentials($userEmail = '')
126126

127127
$this->client->setAuthConfig($serviceJsonUrl);
128128

129-
if ($userEmail) {
129+
if (! empty($userEmail)) {
130130
$this->client->setSubject($userEmail);
131131
}
132132

src/config/config.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,18 @@
5555
*/
5656
'file' => env('GOOGLE_SERVICE_ACCOUNT_JSON_LOCATION', '')
5757
],
58+
59+
/*
60+
|----------------------------------------------------------------------------
61+
| Additional config for the Google Client
62+
|----------------------------------------------------------------------------
63+
|
64+
| Set any additional config variables supported by the Google Client
65+
| Details can be found here:
66+
| https://github.com/google/google-api-php-client/blob/master/src/Google/Client.php
67+
|
68+
| NOTE: If client id is specified here, it will get over written by the one above.
69+
|
70+
*/
71+
'config' => [],
5872
];

tests/ClientTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ public function testClientGetter()
1919
$this->assertInstanceOf('Google_Client', $client->getClient());
2020
}
2121

22+
public function testClientGetterWithAdditionalConfig()
23+
{
24+
$client = Mockery::mock('PulkitJalan\Google\Client', [[
25+
'config' => [
26+
'subject' => 'test',
27+
],
28+
]])->makePartial();
29+
30+
$this->assertEquals($client->getClient()->getConfig('subject'), 'test');
31+
}
32+
2233
public function testServiceMake()
2334
{
2435
$client = Mockery::mock('PulkitJalan\Google\Client', [[]])->makePartial();

0 commit comments

Comments
 (0)