Skip to content

Commit

Permalink
Merge branch 'release-3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dalpras-vimar committed Dec 9, 2020
2 parents f89ef60 + 735a82f commit f3b6d06
Show file tree
Hide file tree
Showing 13 changed files with 357 additions and 81 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
LogMeIn GoToWebinar Provider for OAuth 2.0 Client
=================================================

v3.0
----
_Released: 2020-12-09_

Potential break change: DateUtcHelper is static

- \Resources\Webinar.php
- reorganization of getWebinars:
- added getWebinarsByAccount,
- added getWebinarsByOrganizer
- getAudioInformation,
- getInSessionWebinars
- \Resources\CoOrganizer.php
- deprecated resendInvitation
- added resendCoorganizerInvitation
- \Resources\Registrant.php
- added getRegistrationFields
- added $resendConfirmation in createRegistrant
- \ResultSet\ResultSetInterface.php
- implements JsonSerializable
- new \Resources\Webhook.php
- \Helper\DateUtcHelper.php
- is now static
- \Resources now return SimpleResult or PageResult as return type

v2.0
----
_Released: 2020-12-02_
Expand Down
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,17 @@ Interaction with the GoToWebinar API is very easy.

$resWebinar = new \DalPraS\OAuth2\Client\Resources\Webinar($provider, $accessToken);
try {
$data = $resWebinar->getWebinars(new \DateTime('-1 year'), new \DateTime('+1 year'), 0, 10);
$data = $resWebinar->getWebinarsByOrganizer(new \DateTime('-1 year'), new \DateTime('+1 year'), 0, 10);

// or @deprecated, use getWebinars
// $data = $resWebinar->getPast(new \DateTime('-1 year'));
// or
$data = $resWebinar->getWebinarsByAccount(new \DateTime('-1 year'), new \DateTime('+1 year'), 0, 10);

// or @deprecated, use getWebinars
// $data = $resWebinar->getWebinar('webinarKey');
// or
$data = $resWebinar->getWebinar('webinarKey');

// or
$data = $resWebinar->deleteWebinar('webinarKey');

// or
$data = $resWebinar->getUpcoming();

// or
// helper for changing timezone to utc
$dateUtcHelper = new \DalPraS\OAuth2\Client\Helper\DateUtcHelper();
Expand Down
25 changes: 8 additions & 17 deletions src/Helper/DateUtcHelper.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
<?php
namespace DalPraS\OAuth2\Client\Helper;

class DateUtcHelper {

/**
* @var \DateTimeZone
*/
private $utcTimeZone;

/**
* @param \DateTime $dateTime
*/
public function __construct() {
$this->utcTimeZone = new \DateTimeZone('UTC');
}

class DateUtcHelper
{
/**
* Convert DateTime in UTC timezone string format Y-m-d\TH:i:s\Z
*
* @param \DateTime $dateTime Local datetime
* @return string
*/
public function date2utc(\DateTime $dateTime) : string {
return $dateTime->setTimezone($this->utcTimeZone)->format('Y-m-d\TH:i:s\Z');
public static function date2utc(\DateTime $dateTime) : string {
return $dateTime->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d\TH:i:s\Z');
}

/**
* Convert string UTC datetime in current datetime
*
* @param string $utcTime String representing the time
* @return \DateTime
*/
public function utc2date(string $utcTime) : \DateTime {
public static function utc2date(string $utcTime) : \DateTime {
return (new \DateTime())->createFromFormat('Y-m-d\TH:i:s\Z', $utcTime);
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/Resources/Attendee.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace DalPraS\OAuth2\Client\Resources;

use DalPraS\OAuth2\Client\ResultSet\SimpleResultSet;
use DalPraS\OAuth2\Client\ResultSet\ResultSetInterface;

class Attendee extends AuthenticatedResourceAbstract
{
Expand All @@ -17,7 +16,7 @@ class Attendee extends AuthenticatedResourceAbstract
*
* @link https://developer.goto.com/GoToWebinarV2/#operation/getAttendees
*/
public function getSessionAttendees(string $webinarKey, string $sessionKey): ResultSetInterface
public function getSessionAttendees(string $webinarKey, string $sessionKey): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/sessions/{sessionKey}/attendees', [
'webinarKey' => $webinarKey,
Expand All @@ -38,7 +37,7 @@ public function getSessionAttendees(string $webinarKey, string $sessionKey): Res
*
* @link https://developer.goto.com/GoToWebinarV2/#operation/getAttendee
*/
public function getAttendee(string $webinarKey, string $sessionKey, string $registrantKey): ResultSetInterface
public function getAttendee(string $webinarKey, string $sessionKey, string $registrantKey): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/sessions/{sessionKey}/attendees/{registrantKey}', [
'webinarKey' => $webinarKey,
Expand All @@ -60,7 +59,7 @@ public function getAttendee(string $webinarKey, string $sessionKey, string $regi
*
* @link https://developer.goto.com/GoToWebinarV2/#operation/getAttendeePollAnswers
*/
public function getAttendeePollAnswers(string $webinarKey, string $sessionKey, string $registrantKey): ResultSetInterface
public function getAttendeePollAnswers(string $webinarKey, string $sessionKey, string $registrantKey): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/sessions/{sessionKey}/attendees/{registrantKey}/polls', [
'webinarKey' => $webinarKey,
Expand All @@ -82,7 +81,7 @@ public function getAttendeePollAnswers(string $webinarKey, string $sessionKey, s
*
* @link https://developer.goto.com/GoToWebinarV2/#operation/getAttendeeQuestions
*/
public function getAttendeeQuestions(string $webinarKey, string $sessionKey, string $registrantKey): ResultSetInterface
public function getAttendeeQuestions(string $webinarKey, string $sessionKey, string $registrantKey): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/sessions/{sessionKey}/attendees/{registrantKey}/questions', [
'webinarKey' => $webinarKey,
Expand All @@ -104,7 +103,7 @@ public function getAttendeeQuestions(string $webinarKey, string $sessionKey, str
*
* @link https://developer.goto.com/GoToWebinarV2/#operation/getAttendeeSurveyAnswers
*/
public function getAttendeeSurveyAnswers(string $webinarKey, string $sessionKey, string $registrantKey): ResultSetInterface
public function getAttendeeSurveyAnswers(string $webinarKey, string $sessionKey, string $registrantKey): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/sessions/{sessionKey}/attendees/{registrantKey}/surveys', [
'webinarKey' => $webinarKey,
Expand Down
1 change: 0 additions & 1 deletion src/Resources/AuthenticatedResourceAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use DalPraS\OAuth2\Client\Provider\GotoWebinar;
use League\OAuth2\Client\Token\AccessToken;
use DalPraS\OAuth2\Client\ResultSet\ResultSetInterface;
use DalPraS\OAuth2\Client\Decorators\AccessTokenDecorator;

abstract class AuthenticatedResourceAbstract {
Expand Down
35 changes: 28 additions & 7 deletions src/Resources/CoOrganizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace DalPraS\OAuth2\Client\Resources;

use DalPraS\OAuth2\Client\ResultSet\SimpleResultSet;
use DalPraS\OAuth2\Client\ResultSet\ResultSetInterface;

class CoOrganizer extends AuthenticatedResourceAbstract
{
Expand All @@ -16,7 +15,7 @@ class CoOrganizer extends AuthenticatedResourceAbstract
*
* @link https://developer.goto.com/GoToWebinarV2/#operation/getCoorganizers
*/
public function getCoOrganizers(string $webinarKey): ResultSetInterface
public function getCoOrganizers(string $webinarKey): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/coorganizers', [
'webinarKey' => $webinarKey,
Expand All @@ -35,7 +34,7 @@ public function getCoOrganizers(string $webinarKey): ResultSetInterface
*
* @link https://developer.goto.com/GoToWebinarV2/#operation/createCoorganizers
*/
public function createCoOrganizers(string $webinarKey, array $body): ResultSetInterface
public function createCoOrganizers(string $webinarKey, array $body): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/coorganizers', [
'webinarKey' => $webinarKey
Expand All @@ -57,7 +56,7 @@ public function createCoOrganizers(string $webinarKey, array $body): ResultSetIn
*
* @link https://developer.goto.com/GoToWebinarV2/#operation/deleteCoorganizer
*/
public function deleteCoOrganizer(string $webinarKey, string $coOrganizerKey, bool $external = false): ResultSetInterface
public function deleteCoOrganizer(string $webinarKey, string $coOrganizerKey, bool $external = false): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/coorganizers/{coorganizerKey}', [
'webinarKey' => $webinarKey,
Expand All @@ -71,17 +70,39 @@ public function deleteCoOrganizer(string $webinarKey, string $coOrganizerKey, bo
}

/**
* Resend invitation
* Resends an invitation email to the specified co-organizer. For external co-organizers
* (individuals who do not have a shared GoToWebinar account), set the URL parameter 'external' = true.
*
* https://api.getgo.com/G2W/rest/v2/organizers/{organizerKey}/webinars/{webinarKey}/coorganizers/{coorganizerKey}/resendInvitation
*
* @deprecated use resendCoOrganizerInvitation
*
* @param string $webinarKey
* @param string $coOrganizerKey
* @param bool $external
* @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException
*
* @link https://developer.goto.com/GoToWebinarV2/#operation/resendCoorganizerInvitation
*/
public function resendInvitation(string $webinarKey, string $coOrganizerKey, bool $external = false): SimpleResultSet
{
return $this->resendCoOrganizerInvitation($webinarKey, $coOrganizerKey, $external);
}

/**
* Resends an invitation email to the specified co-organizer. For external co-organizers
* (individuals who do not have a shared GoToWebinar account), set the URL parameter 'external' = true.
*
* https://api.getgo.com/G2W/rest/v2/organizers/{organizerKey}/webinars/{webinarKey}/coorganizers/{coorganizerKey}/resendInvitation
*
* @param string $webinarKey
* @param string $coOrganizerKey
* @param bool $external
* @return array|null
* @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException
*
* @link https://developer.goto.com/GoToWebinarV2/#operation/resendCoorganizerInvitation
*/
public function resendInvitation(string $webinarKey, string $coOrganizerKey, bool $external = false): ResultSetInterface
public function resendCoOrganizerInvitation(string $webinarKey, string $coOrganizerKey, bool $external = false): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/coorganizers/{coorganizerKey}/resendInvitation', [
'webinarKey' => $webinarKey,
Expand Down
37 changes: 28 additions & 9 deletions src/Resources/Registrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace DalPraS\OAuth2\Client\Resources;

use DalPraS\OAuth2\Client\ResultSet\SimpleResultSet;
use DalPraS\OAuth2\Client\ResultSet\ResultSetInterface;

class Registrant extends \DalPraS\OAuth2\Client\Resources\AuthenticatedResourceAbstract
{
Expand All @@ -15,7 +14,7 @@ class Registrant extends \DalPraS\OAuth2\Client\Resources\AuthenticatedResourceA
*
* @param string $webinarKey
*/
public function getRegistrants(string $webinarKey): ResultSetInterface
public function getRegistrants(string $webinarKey): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/registrants', [
'webinarKey' => $webinarKey,
Expand All @@ -33,7 +32,7 @@ public function getRegistrants(string $webinarKey): ResultSetInterface
* @param string $webinarKey
* @param string $registrantKey
*/
public function getRegistrant(string $webinarKey, string $registrantKey): ResultSetInterface
public function getRegistrant(string $webinarKey, string $registrantKey): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/registrants/{registrantKey}', [
'webinarKey' => $webinarKey,
Expand All @@ -52,7 +51,7 @@ public function getRegistrant(string $webinarKey, string $registrantKey): Result
* @param string $email
* @return array|NULL
*/
public function getRegistrantByEmail(string $webinarKey, string $email): ResultSetInterface
public function getRegistrantByEmail(string $webinarKey, string $email): SimpleResultSet
{
$registrants = $this->getRegistrants($webinarKey);
foreach ($registrants as $registrant) {
Expand All @@ -64,19 +63,25 @@ public function getRegistrantByEmail(string $webinarKey, string $email): ResultS
}

/**
* Subscribe a registrant for a webinar.
* Register an attendee for a scheduled webinar. Requires the organizer and a scheduled webinar.
* Please note that you must provide all required fields including custom fields defined during the webinar creation.
* Use the API call 'Get registration fields' to get a list of all fields, if they are required, and their possible values.
*
* https://api.getgo.com/G2W/rest/v2/organizers/{organizerKey}/webinars/{webinarKey}/registrants
*
* @link https://developer.goto.com/GoToWebinarV2#operation/createRegistrant
*
* @param string $webinarKey
* @param array $body
* @return array
* @param array $body
* @param bool $resendConfirmation
* Indicates whether the confirmation email should be resent when a registrant is re-registered
*/
public function createRegistrant(string $webinarKey, array $body): ResultSetInterface
public function createRegistrant(string $webinarKey, array $body, bool $resendConfirmation = false): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/registrants', [
'webinarKey' => $webinarKey,
], [
'resendConfirmation' => $resendConfirmation ? 'true' : 'false'
]);
$request = $this->provider->getAuthenticatedRequest('POST', $url, $this->accessToken, [
'headers' => [
Expand All @@ -87,6 +92,20 @@ public function createRegistrant(string $webinarKey, array $body): ResultSetInte
return new SimpleResultSet($this->provider->getParsedResponse($request));
}

/**
* Retrieve required, optional registration, and custom questions for a specified webinar.
*
* https://api.getgo.com/G2W/rest/v2/organizers/{organizerKey}/webinars/{webinarKey}/registrants/fields
*
* @link https://developer.goto.com/GoToWebinarV2#operation/getRegistrationFields
*/
public function getRegistrationFields(): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/registrants/fields');
$request = $this->provider->getAuthenticatedRequest('GET', $url, $this->accessToken);
return new SimpleResultSet($this->provider->getParsedResponse($request));
}

/**
* Unsubscribe a registrant from a webinar.
* https://api.getgo.com/G2W/rest/v2/organizers/{organizerKey}/webinars/{webinarKey}/registrants/{registrantKey}
Expand All @@ -97,7 +116,7 @@ public function createRegistrant(string $webinarKey, array $body): ResultSetInte
* @param string $registrantKey
* @return array
*/
public function deleteRegistrant(string $webinarKey, string $registrantKey): ResultSetInterface
public function deleteRegistrant(string $webinarKey, string $registrantKey): SimpleResultSet
{
$url = $this->getRequestUrl('/organizers/{organizerKey}/webinars/{webinarKey}/registrants/{registrantKey}', [
'webinarKey' => $webinarKey,
Expand Down
Loading

0 comments on commit f3b6d06

Please sign in to comment.