-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from heiglandreas/addSessionizeApi
- Loading branch information
Showing
11 changed files
with
339 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
charset = utf-8 | ||
|
||
[{*.js, *.json}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright Andreas Heigl <andreas@heigl.org> | ||
* | ||
* Licensed under the MIT-license. For details see the included file LICENSE.md | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Callingallpapers\Service; | ||
|
||
use function parse_ini_file; | ||
|
||
class ConfigService | ||
{ | ||
private $configFile = __DIR__ . '/../../config/callingallpapers.ini'; | ||
|
||
public function __construct() {} | ||
|
||
public function getConfiguration(): array | ||
{ | ||
return parse_ini_file($this->configFile)??[]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright Andreas Heigl <andreas@heigl.org> | ||
* | ||
* Licensed under the MIT-license. For details see the included file LICENSE.md | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Callingallpapers\Subcommands\SessionizeApi; | ||
|
||
use Callingallpapers\Command\AbstractParseEvents; | ||
use Callingallpapers\Entity\Cfp; | ||
use Callingallpapers\Parser\ParserInterface; | ||
use Callingallpapers\Service\ConfigService; | ||
use Callingallpapers\Service\ServiceContainer; | ||
use Callingallpapers\Subcommands\SessionizeApi\Parser\EntryParser; | ||
use Callingallpapers\Subcommands\SessionizeApi\Parser\Sessionize; | ||
use function strtolower; | ||
|
||
class Command extends AbstractParseEvents | ||
{ | ||
const NAME = 'SessionizeAPI'; | ||
|
||
protected function getParser(ServiceContainer $serviceContainer) : ParserInterface | ||
{ | ||
$parser = new EntryParser(new Cfp(), $serviceContainer); | ||
|
||
return new Sessionize($parser, $serviceContainer->getClient(), new ConfigService()); | ||
} | ||
|
||
protected function getParserName() : string | ||
{ | ||
return self::NAME; | ||
} | ||
|
||
protected function getParserId() : string | ||
{ | ||
return strtolower($this->getParserName()); | ||
} | ||
|
||
protected function getServiceUrl() : string | ||
{ | ||
return 'https://sessionize.com'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* Copyright Andrea Heigl <andreas@heigl.org> | ||
* | ||
* Licenses under the MIT-license. For details see the included file LICENSE.md | ||
*/ | ||
namespace Callingallpapers\Subcommands\SessionizeApi\Parser; | ||
|
||
use Callingallpapers\Entity\Cfp; | ||
use Callingallpapers\Service\ServiceContainer; | ||
use Callingallpapers\Service\TimezoneService; | ||
use DateTimeImmutable; | ||
use DateTimeZone; | ||
use DOMDocument; | ||
use DOMXPath; | ||
use Exception; | ||
use GuzzleHttp\Client; | ||
use InvalidArgumentException; | ||
use Throwable; | ||
|
||
class EntryParser | ||
{ | ||
private $cfp; | ||
|
||
private $timezoneService; | ||
|
||
private $geolocationService; | ||
|
||
public function __construct(Cfp $cfp, ServiceContainer $container) | ||
{ | ||
$this->cfp = $cfp; | ||
$this->timezoneService = $container->getTimezoneService(); | ||
$this->geolocationService = $container->getGeolocationService(); | ||
} | ||
|
||
/** | ||
* @param array{ | ||
* eventId: int, | ||
* name: string, | ||
* organizer: string, | ||
* website: string, | ||
* cfpLink: string, | ||
* isTest: boolean, | ||
* isOnline: boolean, | ||
* isUserGroup: boolean, | ||
* expensesCovered: array{ | ||
* conferenceFee: boolean, | ||
* accommodation: boolean, | ||
* travel: boolean | ||
* }, | ||
* eventDates: array{ | ||
* start: datestring, | ||
* end: datestring | ||
* }, | ||
* cfpDates: array{ | ||
* startUtc: datetimestringZ, | ||
* endUtc: datetimestringZ, | ||
* start: datetimestring, | ||
* end: datetimestring | ||
* }, | ||
* timezone: array{ | ||
* iana: string, | ||
* windows: string | ||
* }, | ||
* location: array{ | ||
* full: string, | ||
* city: string, | ||
* state: string, | ||
* country: string, | ||
* coordinates: latlonstring | ||
* }, | ||
* links: array{ | ||
* twitter: string, | ||
* linkedIn: null, | ||
* facebook: string, | ||
* instagram: string, | ||
* } | ||
* } $event | ||
* @return Cfp | ||
* @throws Exception | ||
*/ | ||
public function parse(array $event): Cfp | ||
{ | ||
$cfp = new Cfp(); | ||
|
||
try { | ||
$cfp->location = $event['location']['full']??''; | ||
if ($event['location']['coordinates']??null !== null) { | ||
$location = explode(',', $event['location']['coordinates']); | ||
$cfp->latitude = $location[0]; | ||
$cfp->longitude = $location[1]; | ||
} | ||
$cfp->timezone = $event['timezone']['iana']; | ||
|
||
$timezone = new DateTimeZone($cfp->timezone); | ||
|
||
$cfp->dateEnd = new DateTimeImmutable($event['cfpDates']['end'], $timezone); | ||
$cfp->dateStart = new DateTimeImmutable($event['cfpDates']['start'], $timezone); | ||
|
||
$cfp->uri = $event['cfpLink']; | ||
$cfp->conferenceName = $event['name']; | ||
|
||
$cfp->conferenceUri = $event['website']; | ||
|
||
$cfp->eventEndDate = new DateTimeImmutable($event['eventDates']['end'], $timezone); | ||
$cfp->eventStartDate = new DateTimeImmutable($event['eventDates']['start'], $timezone); | ||
|
||
return $cfp; | ||
} catch (Exception $e) { | ||
throw $e; | ||
} | ||
} | ||
} |
Oops, something went wrong.