-
Notifications
You must be signed in to change notification settings - Fork 30
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 #83 from maxbeckers/develop
Merge 1.8.0
- Loading branch information
Showing
18 changed files
with
550 additions
and
0 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
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
50 changes: 50 additions & 0 deletions
50
src/Request/Request/AlexaSkillEvent/AlexaSkillEventRequest.php
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,50 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\AmazonAlexa\Request\Request\AlexaSkillEvent; | ||
|
||
use MaxBeckers\AmazonAlexa\Request\Request\AbstractRequest; | ||
|
||
/** | ||
* @author Maximilian Beckers <[email protected]> | ||
*/ | ||
abstract class AlexaSkillEventRequest extends AbstractRequest | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $eventCreationTime; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $eventPublishingTime; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $requestId; | ||
|
||
/** | ||
* @param array $amazonRequest | ||
*/ | ||
protected function setRequestData(array $amazonRequest) | ||
{ | ||
$this->requestId = $amazonRequest['requestId']; | ||
|
||
$this->setTime('timestamp', $amazonRequest['timeStamp']); | ||
$this->setTime('eventCreationTime', $amazonRequest['eventCreationTime']); | ||
$this->setTime('eventPublishingTime', $amazonRequest['eventPublishingTime']); | ||
|
||
$this->locale = $amazonRequest['locale']; | ||
} | ||
|
||
private function setTime($attribute, $value) | ||
{ | ||
//Workaround for amazon developer console sending unix timestamp | ||
try { | ||
$this->{$attribute} = new \DateTime($value); | ||
} catch (\Exception $e) { | ||
$this->{$attribute} = (new \DateTime())->setTimestamp(intval($value / 1000)); | ||
} | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\AmazonAlexa\Request\Request\AlexaSkillEvent; | ||
|
||
/** | ||
* @author Maximilian Beckers <[email protected]> | ||
*/ | ||
class Permission | ||
{ | ||
/** | ||
* @var string|null | ||
*/ | ||
public $scope; | ||
|
||
/** | ||
* @param array $amazonRequest | ||
* | ||
* @return Permission | ||
*/ | ||
public static function fromAmazonRequest(array $amazonRequest): self | ||
{ | ||
$permission = new self(); | ||
|
||
$permission->scope = isset($amazonRequest['scope']) ? $amazonRequest['scope'] : null; | ||
|
||
return $permission; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Request/Request/AlexaSkillEvent/SkillAccountLinkedBody.php
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,28 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\AmazonAlexa\Request\Request\AlexaSkillEvent; | ||
|
||
/** | ||
* @author Maximilian Beckers <[email protected]> | ||
*/ | ||
class SkillAccountLinkedBody | ||
{ | ||
/** | ||
* @var string|null | ||
*/ | ||
public $accessToken; | ||
|
||
/** | ||
* @param array $amazonRequest | ||
* | ||
* @return SkillAccountLinkedBody | ||
*/ | ||
public static function fromAmazonRequest(array $amazonRequest): self | ||
{ | ||
$body = new self(); | ||
|
||
$body->accessToken = isset($amazonRequest['accessToken']) ? $amazonRequest['accessToken'] : null; | ||
|
||
return $body; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Request/Request/AlexaSkillEvent/SkillAccountLinkedRequest.php
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,32 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\AmazonAlexa\Request\Request\AlexaSkillEvent; | ||
|
||
use MaxBeckers\AmazonAlexa\Request\Request\AbstractRequest; | ||
|
||
/** | ||
* @author Maximilian Beckers <[email protected]> | ||
*/ | ||
class SkillAccountLinkedRequest extends AlexaSkillEventRequest | ||
{ | ||
const TYPE = 'AlexaSkillEvent.SkillAccountLinked'; | ||
|
||
/** | ||
* @var SkillAccountLinkedBody|null | ||
*/ | ||
public $body; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function fromAmazonRequest(array $amazonRequest): AbstractRequest | ||
{ | ||
$request = new self(); | ||
|
||
$request->type = self::TYPE; | ||
$request->body = isset($amazonRequest['body']) ? SkillAccountLinkedBody::fromAmazonRequest($amazonRequest['body']) : null; | ||
$request->setRequestData($amazonRequest); | ||
|
||
return $request; | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\AmazonAlexa\Request\Request\AlexaSkillEvent; | ||
|
||
/** | ||
* @author Maximilian Beckers <[email protected]> | ||
*/ | ||
class SkillDisabledBody | ||
{ | ||
const PERSISTED = 'PERSISTED'; | ||
const NOT_PERSISTED = 'NOT_PERSISTED'; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
public $userInformationPersistenceStatus; | ||
|
||
/** | ||
* @param array $amazonRequest | ||
* | ||
* @return SkillDisabledBody | ||
*/ | ||
public static function fromAmazonRequest(array $amazonRequest): self | ||
{ | ||
$body = new self(); | ||
|
||
$body->userInformationPersistenceStatus = isset($amazonRequest['userInformationPersistenceStatus']) ? $amazonRequest['userInformationPersistenceStatus'] : null; | ||
|
||
return $body; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Request/Request/AlexaSkillEvent/SkillDisabledRequest.php
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,32 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\AmazonAlexa\Request\Request\AlexaSkillEvent; | ||
|
||
use MaxBeckers\AmazonAlexa\Request\Request\AbstractRequest; | ||
|
||
/** | ||
* @author Maximilian Beckers <[email protected]> | ||
*/ | ||
class SkillDisabledRequest extends AlexaSkillEventRequest | ||
{ | ||
const TYPE = 'AlexaSkillEvent.SkillDisabled'; | ||
|
||
/** | ||
* @var SkillDisabledBody|null | ||
*/ | ||
public $body; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function fromAmazonRequest(array $amazonRequest): AbstractRequest | ||
{ | ||
$request = new self(); | ||
|
||
$request->type = self::TYPE; | ||
$request->body = isset($amazonRequest['body']) ? SkillDisabledBody::fromAmazonRequest($amazonRequest['body']) : null; | ||
$request->setRequestData($amazonRequest); | ||
|
||
return $request; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Request/Request/AlexaSkillEvent/SkillEnabledRequest.php
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,26 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\AmazonAlexa\Request\Request\AlexaSkillEvent; | ||
|
||
use MaxBeckers\AmazonAlexa\Request\Request\AbstractRequest; | ||
|
||
/** | ||
* @author Maximilian Beckers <[email protected]> | ||
*/ | ||
class SkillEnabledRequest extends AlexaSkillEventRequest | ||
{ | ||
const TYPE = 'AlexaSkillEvent.SkillEnabled'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function fromAmazonRequest(array $amazonRequest): AbstractRequest | ||
{ | ||
$request = new self(); | ||
|
||
$request->type = self::TYPE; | ||
$request->setRequestData($amazonRequest); | ||
|
||
return $request; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Request/Request/AlexaSkillEvent/SkillPermissionAcceptedRequest.php
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,32 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\AmazonAlexa\Request\Request\AlexaSkillEvent; | ||
|
||
use MaxBeckers\AmazonAlexa\Request\Request\AbstractRequest; | ||
|
||
/** | ||
* @author Maximilian Beckers <[email protected]> | ||
*/ | ||
class SkillPermissionAcceptedRequest extends AlexaSkillEventRequest | ||
{ | ||
const TYPE = 'AlexaSkillEvent.SkillPermissionAccepted'; | ||
|
||
/** | ||
* @var SkillPermissionBody|null | ||
*/ | ||
public $body; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function fromAmazonRequest(array $amazonRequest): AbstractRequest | ||
{ | ||
$request = new self(); | ||
|
||
$request->type = self::TYPE; | ||
$request->body = isset($amazonRequest['body']) ? SkillPermissionBody::fromAmazonRequest($amazonRequest['body']) : null; | ||
$request->setRequestData($amazonRequest); | ||
|
||
return $request; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/Request/Request/AlexaSkillEvent/SkillPermissionBody.php
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,34 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\AmazonAlexa\Request\Request\AlexaSkillEvent; | ||
|
||
/** | ||
* @author Maximilian Beckers <[email protected]> | ||
*/ | ||
class SkillPermissionBody | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
public $acceptedPermissions; | ||
|
||
/** | ||
* @param array $amazonRequest | ||
* | ||
* @return SkillPermissionBody | ||
*/ | ||
public static function fromAmazonRequest(array $amazonRequest): self | ||
{ | ||
$body = new self(); | ||
|
||
$body->acceptedPermissions = []; | ||
|
||
if ($amazonRequest['acceptedPermissions']) { | ||
foreach ($amazonRequest['acceptedPermissions'] as $permission) { | ||
$body->acceptedPermissions[] = Permission::fromAmazonRequest($permission); | ||
} | ||
} | ||
|
||
return $body; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Request/Request/AlexaSkillEvent/SkillPermissionChangedRequest.php
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,32 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\AmazonAlexa\Request\Request\AlexaSkillEvent; | ||
|
||
use MaxBeckers\AmazonAlexa\Request\Request\AbstractRequest; | ||
|
||
/** | ||
* @author Maximilian Beckers <[email protected]> | ||
*/ | ||
class SkillPermissionChangedRequest extends AlexaSkillEventRequest | ||
{ | ||
const TYPE = 'AlexaSkillEvent.SkillPermissionChanged'; | ||
|
||
/** | ||
* @var SkillPermissionBody|null | ||
*/ | ||
public $body; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function fromAmazonRequest(array $amazonRequest): AbstractRequest | ||
{ | ||
$request = new self(); | ||
|
||
$request->type = self::TYPE; | ||
$request->body = isset($amazonRequest['body']) ? SkillPermissionBody::fromAmazonRequest($amazonRequest['body']) : null; | ||
$request->setRequestData($amazonRequest); | ||
|
||
return $request; | ||
} | ||
} |
Oops, something went wrong.