Skip to content

Commit cda36ec

Browse files
authored
Merge pull request #149 from ahmetertem/master
few improvement
2 parents d579e6b + c3e1efd commit cda36ec

9 files changed

+81
-3
lines changed

config/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
'account_id' => env('ZOOM_ACCOUNT_ID'),
55
'client_id' => env('ZOOM_CLIENT_ID'),
66
'client_secret' => env('ZOOM_CLIENT_SECRET'),
7+
'cache_token' => env('ZOOM_CACHE_TOKEN', true),
78
'base_url' => 'https://api.zoom.us/v2/',
89
'authentication_method' => 'Oauth', // Only Oauth compatible at present
910
'max_api_calls_per_request' => '5' // how many times can we hit the api to return results for an all() request

src/QuestionAnswer.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace MacsiDigital\Zoom;
4+
5+
use MacsiDigital\API\Support\Resource;
6+
7+
class QuestionAnswer extends Resource
8+
{
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace MacsiDigital\Zoom\Requests;
4+
5+
use MacsiDigital\API\Support\PersistResource;
6+
7+
class StoreEmailNotification extends PersistResource
8+
{
9+
protected $persistAttributes = [
10+
"enable" => "nullable|boolean",
11+
"type" => "nullable|integer|in:0,1,2,3,4,5,6,7"
12+
];
13+
}

src/Requests/StoreQuestionAnswer.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace MacsiDigital\Zoom\Requests;
4+
5+
use MacsiDigital\API\Support\PersistResource;
6+
7+
class StoreQuestionAnswer extends PersistResource
8+
{
9+
protected $persistAttributes = [
10+
"enable" => "nullable|boolean",
11+
"allow_submit_questions" => "nullable|boolean",
12+
"allow_anonymous_questions" => "nullable|boolean",
13+
"answer_questions" => "nullable|string|in:only,all",
14+
"attendees_can_comment" => "nullable|boolean",
15+
"attendees_can_upvote" => "nullable|boolean",
16+
"allow_auto_reply" => "nullable|string",
17+
"auto_reply_text" => "nullable|boolean",
18+
];
19+
}

src/Requests/StoreWebinarSetting.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ class StoreWebinarSetting extends PersistResource
3232
"authentication_option" => "nullable|string",
3333
"authentication_domains" => "nullable|string",
3434
"authentication_name" => "nullable|string",
35+
"email_language" => "nullable|string",
3536
];
3637

3738
protected $relatedResource = [
3839
"global_dial_in_countries" => StoreGlobalDialInCountry::class,
40+
"attendees_and_panelists_reminder_email_notification" => StoreEmailNotification::class,
41+
"follow_up_absentees_email_notification" => StoreEmailNotification::class,
42+
"follow_up_attendees_email_notification" => StoreEmailNotification::class,
43+
"question_and_answer" => StoreQuestionAnswer::class,
3944
];
4045
}

src/Requests/UpdateWebinarSetting.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ class UpdateWebinarSetting extends PersistResource
3131
"meeting_authentication" => "nullable|boolean",
3232
"authentication_option" => "nullable|string",
3333
"authentication_domains" => "nullable|string",
34+
"email_language" => "nullable|string",
3435
];
3536

3637
protected $relatedResource = [
3738
"global_dial_in_countries" => StoreGlobalDialInCountry::class,
39+
"attendees_and_panelists_reminder_email_notification" => StoreEmailNotification::class,
40+
"follow_up_absentees_email_notification" => StoreEmailNotification::class,
41+
"follow_up_attendees_email_notification" => StoreEmailNotification::class,
42+
"question_and_answer" => StoreQuestionAnswer::class,
3843
];
3944
}

src/Support/Entry.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct($accountId = null, $clientId = null, $clientSecret =
5656

5757
public function newRequest()
5858
{
59-
if (config('zoom.authentication_method') == 'Oauth') {
59+
if (strtolower(config('zoom.authentication_method')) == 'oauth') {
6060
return $this->oauthRequest();
6161
}
6262

@@ -66,7 +66,8 @@ public function newRequest()
6666

6767
public function oauthRequest()
6868
{
69-
$oauthToken = $this->OAuthGenerateToken();
69+
$cached = config('zoom.cache_token', true) ? \Cache::get('zoom_oauth_token') : null;
70+
$oauthToken = !is_null($cached) ? $cached : $this->OAuthGenerateToken();
7071

7172
return Client::baseUrl($this->baseUrl)->withToken($oauthToken);
7273
}
@@ -85,6 +86,11 @@ private function OAuthGenerateToken(){
8586
throw new \ErrorException( $response['error']);
8687
}
8788

89+
if(config('zoom.cache_token', true)) {
90+
// -10 seconds TTL just-in-case...
91+
cache(['zoom_oauth_token' => $response['access_token']], now()->addSeconds($response['expires_in'] - 10));
92+
}
93+
8894
return $response['access_token'];
8995
}
9096
}

src/WebinarRegistrant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class WebinarRegistrant extends Model
1010

1111
protected $endPoint = 'webinars/{webinar:id}/registrants';
1212

13-
protected $allowedMethods = ['find', 'get', 'post', 'put'];
13+
protected $allowedMethods = ['find', 'get', 'post', 'put', 'delete'];
1414

1515
protected $apiMultipleDataField = 'registrants';
1616

src/WebinarSetting.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,24 @@ public function globalDialInCountries()
1010
{
1111
return $this->hasMany(GlobalDialInCountry::class);
1212
}
13+
14+
public function attendeesAndPanelistsReminderEmailNotification()
15+
{
16+
return $this->hasOne(EmailNotification::class);
17+
}
18+
19+
public function followUpAbsenteesEmailNotification()
20+
{
21+
return $this->hasOne(EmailNotification::class);
22+
}
23+
24+
public function followUpAttendeesEmailNotification()
25+
{
26+
return $this->hasOne(EmailNotification::class);
27+
}
28+
29+
public function questionAndAnswer()
30+
{
31+
return $this->hasOne(QuestionAnswer::class);
32+
}
1333
}

0 commit comments

Comments
 (0)