Skip to content

Commit

Permalink
Merge pull request #149 from ahmetertem/master
Browse files Browse the repository at this point in the history
few improvement
  • Loading branch information
colinhall17 authored Sep 6, 2023
2 parents d579e6b + c3e1efd commit cda36ec
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'account_id' => env('ZOOM_ACCOUNT_ID'),
'client_id' => env('ZOOM_CLIENT_ID'),
'client_secret' => env('ZOOM_CLIENT_SECRET'),
'cache_token' => env('ZOOM_CACHE_TOKEN', true),
'base_url' => 'https://api.zoom.us/v2/',
'authentication_method' => 'Oauth', // Only Oauth compatible at present
'max_api_calls_per_request' => '5' // how many times can we hit the api to return results for an all() request
Expand Down
9 changes: 9 additions & 0 deletions src/QuestionAnswer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace MacsiDigital\Zoom;

use MacsiDigital\API\Support\Resource;

class QuestionAnswer extends Resource
{
}
13 changes: 13 additions & 0 deletions src/Requests/StoreEmailNotification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace MacsiDigital\Zoom\Requests;

use MacsiDigital\API\Support\PersistResource;

class StoreEmailNotification extends PersistResource
{
protected $persistAttributes = [
"enable" => "nullable|boolean",
"type" => "nullable|integer|in:0,1,2,3,4,5,6,7"
];
}
19 changes: 19 additions & 0 deletions src/Requests/StoreQuestionAnswer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace MacsiDigital\Zoom\Requests;

use MacsiDigital\API\Support\PersistResource;

class StoreQuestionAnswer extends PersistResource
{
protected $persistAttributes = [
"enable" => "nullable|boolean",
"allow_submit_questions" => "nullable|boolean",
"allow_anonymous_questions" => "nullable|boolean",
"answer_questions" => "nullable|string|in:only,all",
"attendees_can_comment" => "nullable|boolean",
"attendees_can_upvote" => "nullable|boolean",
"allow_auto_reply" => "nullable|string",
"auto_reply_text" => "nullable|boolean",
];
}
5 changes: 5 additions & 0 deletions src/Requests/StoreWebinarSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ class StoreWebinarSetting extends PersistResource
"authentication_option" => "nullable|string",
"authentication_domains" => "nullable|string",
"authentication_name" => "nullable|string",
"email_language" => "nullable|string",
];

protected $relatedResource = [
"global_dial_in_countries" => StoreGlobalDialInCountry::class,
"attendees_and_panelists_reminder_email_notification" => StoreEmailNotification::class,
"follow_up_absentees_email_notification" => StoreEmailNotification::class,
"follow_up_attendees_email_notification" => StoreEmailNotification::class,
"question_and_answer" => StoreQuestionAnswer::class,
];
}
5 changes: 5 additions & 0 deletions src/Requests/UpdateWebinarSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ class UpdateWebinarSetting extends PersistResource
"meeting_authentication" => "nullable|boolean",
"authentication_option" => "nullable|string",
"authentication_domains" => "nullable|string",
"email_language" => "nullable|string",
];

protected $relatedResource = [
"global_dial_in_countries" => StoreGlobalDialInCountry::class,
"attendees_and_panelists_reminder_email_notification" => StoreEmailNotification::class,
"follow_up_absentees_email_notification" => StoreEmailNotification::class,
"follow_up_attendees_email_notification" => StoreEmailNotification::class,
"question_and_answer" => StoreQuestionAnswer::class,
];
}
10 changes: 8 additions & 2 deletions src/Support/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct($accountId = null, $clientId = null, $clientSecret =

public function newRequest()
{
if (config('zoom.authentication_method') == 'Oauth') {
if (strtolower(config('zoom.authentication_method')) == 'oauth') {
return $this->oauthRequest();
}

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

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

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

if(config('zoom.cache_token', true)) {
// -10 seconds TTL just-in-case...
cache(['zoom_oauth_token' => $response['access_token']], now()->addSeconds($response['expires_in'] - 10));
}

return $response['access_token'];
}
}
2 changes: 1 addition & 1 deletion src/WebinarRegistrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class WebinarRegistrant extends Model

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

protected $allowedMethods = ['find', 'get', 'post', 'put'];
protected $allowedMethods = ['find', 'get', 'post', 'put', 'delete'];

protected $apiMultipleDataField = 'registrants';

Expand Down
20 changes: 20 additions & 0 deletions src/WebinarSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,24 @@ public function globalDialInCountries()
{
return $this->hasMany(GlobalDialInCountry::class);
}

public function attendeesAndPanelistsReminderEmailNotification()
{
return $this->hasOne(EmailNotification::class);
}

public function followUpAbsenteesEmailNotification()
{
return $this->hasOne(EmailNotification::class);
}

public function followUpAttendeesEmailNotification()
{
return $this->hasOne(EmailNotification::class);
}

public function questionAndAnswer()
{
return $this->hasOne(QuestionAnswer::class);
}
}

0 comments on commit cda36ec

Please sign in to comment.