-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit db75590
Showing
23 changed files
with
878 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
composer.phar | ||
/vendor/ | ||
composer.lock |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Maximilian Beckers <beckers.maximilian@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,2 @@ | ||
# Amazon alexa php library | ||
This library is a helper for google actions with 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 @@ | ||
{ | ||
"name": "maxbeckers/google-actions-php", | ||
"type": "library", | ||
"description": "This library is a helper for google actions with php.", | ||
"keywords": [ | ||
"google", | ||
"actions", | ||
"php" | ||
], | ||
"license": "MIT", | ||
"support": { | ||
"issues": "https://github.com/maxbeckers/google-actions-php/issues", | ||
"source": "https://github.com/maxbeckers/google-actions-php" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Maximilian Beckers", | ||
"email": "beckers.maximilian@gmail.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"require": { | ||
"php": ">=7.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^6.2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"MaxBeckers\\GoogleActions\\": "src/" | ||
} | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
use MaxBeckers\GoogleActions\Request\Request; | ||
use MaxBeckers\GoogleActions\Response\Response; | ||
|
||
require '../vendor/autoload.php'; | ||
|
||
$requestBody = file_get_contents('php://input'); | ||
if ($requestBody) { | ||
$alexaRequest = Request::fromGoogleRequest($requestBody); | ||
|
||
// todo generate response | ||
$response = new Response(); | ||
// render response | ||
header('Content-Type: application/json'); | ||
echo json_encode($response); | ||
} | ||
|
||
exit(); |
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
bootstrap="test/bootstrap.php" | ||
checkForUnintentionallyCoveredCode="true" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
verbose="true" | ||
> | ||
<testsuites> | ||
<testsuite name="unit"> | ||
<directory>./test/Tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">./src</directory> | ||
<exclude> | ||
<directory>./test</directory> | ||
<directory>./vendor</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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,61 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\GoogleActions\Request; | ||
|
||
/** | ||
* @author Maximilian Beckers <beckers.maximilian@gmail.com> | ||
*/ | ||
class Argument | ||
{ | ||
/** | ||
* @var string|null | ||
*/ | ||
public $name; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
public $rawText; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
public $boolValue = false; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
public $textValue; | ||
|
||
/** | ||
* @var DateTime|null | ||
*/ | ||
public $datetimeValue; | ||
|
||
/** | ||
* TODO | ||
* | ||
* @var array | ||
*/ | ||
public $extension; | ||
|
||
/** | ||
* @param array $googleRequest | ||
* | ||
* @return Argument | ||
*/ | ||
public static function fromGoogleRequest(array $googleRequest): Argument | ||
{ | ||
$argument = new self(); | ||
|
||
$argument->name = isset($googleRequest['name']) ? $googleRequest['name'] : null; | ||
$argument->rawText = isset($googleRequest['rawText']) ? $googleRequest['rawText'] : null; | ||
$argument->boolValue = isset($googleRequest['boolValue']) ? (bool)$googleRequest['boolValue'] : false; | ||
$argument->textValue = isset($googleRequest['textValue']) ? $googleRequest['textValue'] : null; | ||
$argument->datetimeValue = isset($googleRequest['datetimeValue']) ? DateTime::fromGoogleRequest($googleRequest['datetimeValue']) : null; | ||
// TODO | ||
$argument->extension = isset($googleRequest['extension']) ? (array)$googleRequest['extension'] : []; | ||
|
||
return $argument; | ||
} | ||
} |
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\GoogleActions\Request; | ||
|
||
/** | ||
* @author Maximilian Beckers <beckers.maximilian@gmail.com> | ||
*/ | ||
class Capability | ||
{ | ||
/** | ||
* @var string|null | ||
*/ | ||
public $name; | ||
|
||
/** | ||
* @param array $googleRequest | ||
* | ||
* @return Capability | ||
*/ | ||
public static function fromGoogleRequest(array $googleRequest): Capability | ||
{ | ||
$capability = new self(); | ||
|
||
$capability->name = isset($googleRequest['name']) ? $googleRequest['name'] : null; | ||
|
||
return $capability; | ||
} | ||
} |
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,44 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\GoogleActions\Request; | ||
|
||
/** | ||
* @author Maximilian Beckers <beckers.maximilian@gmail.com> | ||
*/ | ||
class Conversation | ||
{ | ||
const TYPE_UNSPECIFIED = 'TYPE_UNSPECIFIED'; | ||
const TYPE_NEW = 'NEW'; | ||
const TYPE_ACTIVE = 'ACTIVE'; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
public $conversationId; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
public $type; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
public $conversationToken; | ||
|
||
/** | ||
* @param array $googleRequest | ||
* | ||
* @return Conversation | ||
*/ | ||
public static function fromGoogleRequest(array $googleRequest): Conversation | ||
{ | ||
$conversation = new self(); | ||
|
||
$conversation->conversationId = isset($googleRequest['conversationId']) ? $googleRequest['conversationId'] : null; | ||
$conversation->type = isset($googleRequest['type']) ? $googleRequest['type'] : null; | ||
$conversation->conversationToken = isset($googleRequest['conversationToken']) ? $googleRequest['conversationToken'] : null; | ||
|
||
return $conversation; | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\GoogleActions\Request; | ||
|
||
/** | ||
* @author Maximilian Beckers <beckers.maximilian@gmail.com> | ||
*/ | ||
class Date | ||
{ | ||
/** | ||
* @var int|null | ||
*/ | ||
public $year; | ||
|
||
/** | ||
* @var int|null | ||
*/ | ||
public $month; | ||
|
||
/** | ||
* @var int|null | ||
*/ | ||
public $day; | ||
|
||
/** | ||
* @param array $googleRequest | ||
* | ||
* @return Date | ||
*/ | ||
public static function fromGoogleRequest(array $googleRequest): Date | ||
{ | ||
$date = new self(); | ||
|
||
$date->year = isset($googleRequest['year']) ? (int)$googleRequest['year'] : null; | ||
$date->month = isset($googleRequest['month']) ? (int)$googleRequest['month'] : null; | ||
$date->day = isset($googleRequest['day']) ? (int)$googleRequest['day'] : null; | ||
|
||
return $date; | ||
} | ||
} |
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\GoogleActions\Request; | ||
|
||
/** | ||
* @author Maximilian Beckers <beckers.maximilian@gmail.com> | ||
*/ | ||
class DateTime | ||
{ | ||
/** | ||
* @var Date|null | ||
*/ | ||
public $date; | ||
|
||
/** | ||
* @var Time|null | ||
*/ | ||
public $time; | ||
|
||
/** | ||
* @param array $googleRequest | ||
* | ||
* @return DateTime | ||
*/ | ||
public static function fromGoogleRequest(array $googleRequest): DateTime | ||
{ | ||
$dateTime = new self(); | ||
|
||
$dateTime->date = isset($googleRequest['date']) ? Date::fromGoogleRequest($googleRequest['date']) : null; | ||
$dateTime->time = isset($googleRequest['time']) ? Time::fromGoogleRequest($googleRequest['time']) : null; | ||
|
||
return $dateTime; | ||
} | ||
} |
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\GoogleActions\Request; | ||
|
||
/** | ||
* @author Maximilian Beckers <beckers.maximilian@gmail.com> | ||
*/ | ||
class Device | ||
{ | ||
/** | ||
* @var Location|null | ||
*/ | ||
public $location; | ||
|
||
/** | ||
* @param array $googleRequest | ||
* | ||
* @return Device | ||
*/ | ||
public static function fromGoogleRequest(array $googleRequest): Device | ||
{ | ||
$device = new self(); | ||
|
||
$device->location = isset($googleRequest['location']) ? Location::fromGoogleRequest($googleRequest['location']) : null; | ||
|
||
return $device; | ||
} | ||
} |
Oops, something went wrong.