-
Notifications
You must be signed in to change notification settings - Fork 29
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 #10 from fabeat/master
Display.ElementSelected Request & Hint Directive
- Loading branch information
Showing
6 changed files
with
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\AmazonAlexa\Request\Request\Display; | ||
|
||
use MaxBeckers\AmazonAlexa\Request\Request\AbstractRequest; | ||
use MaxBeckers\AmazonAlexa\Request\Request\Standard\StandardRequest; | ||
|
||
/** | ||
* @author Fabian Graßl <fabian.grassl@db-n.com> | ||
*/ | ||
class ElementSelectedRequest extends StandardRequest | ||
{ | ||
const TYPE = 'Display.ElementSelected'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function fromAmazonRequest(array $amazonRequest): AbstractRequest | ||
{ | ||
$request = new self(); | ||
|
||
$request->type = self::TYPE; | ||
$request->token = $amazonRequest['token']; | ||
$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,28 @@ | ||
<?php | ||
|
||
namespace MaxBeckers\AmazonAlexa\Response\Directives\Display; | ||
|
||
use MaxBeckers\AmazonAlexa\Response\Directives\Directive; | ||
|
||
/** | ||
* @author Maximilian Beckers <beckers.maximilian@gmail.com> | ||
*/ | ||
class HintDirective extends Directive | ||
{ | ||
const TYPE = 'Hint'; | ||
|
||
/** | ||
* @var Text|null | ||
*/ | ||
public $hint; | ||
|
||
public static function create(Text $text): self | ||
{ | ||
$hint = new self(); | ||
|
||
$hint->type = self::TYPE; | ||
$hint->hint = $text; | ||
|
||
return $hint; | ||
} | ||
} |
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\AmazonAlexa\Request\Request\Display\ElementSelectedRequest; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @author Fabian Graßl <fabian.grassl@db-n.com> | ||
*/ | ||
class ElementSelectedRequestTest extends TestCase | ||
{ | ||
public function testFromAmazonRequest() | ||
{ | ||
$req = ElementSelectedRequest::fromAmazonRequest(json_decode(file_get_contents(__DIR__.'/RequestData/displayElementSelected.json'), true)); | ||
$this->assertInstanceOf(ElementSelectedRequest::class, $req); | ||
$this->assertSame($req->type, 'Display.ElementSelected'); | ||
$this->assertSame($req->requestId, 'amzn1.echo-api.request.7zzzzzzzzz'); | ||
$this->assertSame($req->locale, 'en-US'); | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"type": "Display.ElementSelected", | ||
"requestId": "amzn1.echo-api.request.7zzzzzzzzz", | ||
"timestamp": "2017-06-06T20:05:04Z", | ||
"locale": "en-US", | ||
"token": "getTopicName-Cookie-Contest" | ||
} |
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