-
Notifications
You must be signed in to change notification settings - Fork 1
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
Ralf Eggert
committed
Oct 26, 2018
1 parent
9166bdb
commit 43b22ea
Showing
2 changed files
with
123 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,64 @@ | ||
<?php | ||
/** | ||
* Build voice applications for Amazon Alexa with phlexa and PHP | ||
* | ||
* @author Ralf Eggert <ralf@travello.audio> | ||
* @license http://opensource.org/licenses/MIT The MIT License (MIT) | ||
* @link https://github.com/phoice/phlexa | ||
* @link https://www.phoice.tech/ | ||
* @link https://www.travello.audio/ | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phlexa\Response\Card; | ||
|
||
/** | ||
* Class AskForPermissionsConsent | ||
* | ||
* @package Phlexa\Response\Card | ||
*/ | ||
class AskForPermissionsConsent implements CardInterface | ||
{ | ||
public const ALEXA_ALERTS_REMINDERS_SKILL_READWRITE = 'alexa::alerts:reminders:skill:readwrite'; | ||
public const WRITE_ALEXA_HOUSEHOLD_LIST = 'write::alexa:household:list'; | ||
public const READ_ALEXA_HOUSEHOLD_LIST = 'read::alexa:household:list'; | ||
public const READ_ALEXA_DEVICE_ALL_ADDRESS = 'read::alexa:device:all:address'; | ||
public const READ_ALEXA_DEVICE_ALL_ADDRESS_COUNTRY = 'read::alexa:device:all:address:country_and_postal_code'; | ||
|
||
/** @var array */ | ||
private $permissions = []; | ||
|
||
/** | ||
* AskForPermissionsConsent constructor. | ||
* | ||
* @param array $permissions | ||
*/ | ||
|
||
public function __construct(array $permissions) | ||
{ | ||
$this->setPermissions($permissions); | ||
} | ||
|
||
|
||
/** | ||
* Render the card object to an array | ||
* | ||
* @return array | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'type' => 'AskForPermissionsConsent', | ||
'permissions' => $this->permissions, | ||
]; | ||
} | ||
|
||
/** | ||
* @param array $permissions | ||
*/ | ||
private function setPermissions(array $permissions): void | ||
{ | ||
$this->permissions = $permissions; | ||
} | ||
} |
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,59 @@ | ||
<?php | ||
/** | ||
* Build voice applications for Amazon Alexa with phlexa and PHP | ||
* | ||
* @author Ralf Eggert <ralf@travello.audio> | ||
* @license http://opensource.org/licenses/MIT The MIT License (MIT) | ||
* @link https://github.com/phoice/phlexa | ||
* @link https://www.phoice.tech/ | ||
* @link https://www.travello.audio/ | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhlexaTest\Response\Card; | ||
|
||
use Phlexa\Response\Card\AskForPermissionsConsent; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class AskForPermissionsConsentTest | ||
* | ||
* @package PhlexaTest\Response\Card | ||
*/ | ||
class AskForPermissionsConsentTest extends TestCase | ||
{ | ||
/** | ||
* | ||
*/ | ||
public function testInstantiationRemindersSkillReadWrite(): void | ||
{ | ||
$card = new AskForPermissionsConsent( | ||
[AskForPermissionsConsent::ALEXA_ALERTS_REMINDERS_SKILL_READWRITE] | ||
); | ||
|
||
$expected = [ | ||
'type' => 'AskForPermissionsConsent', | ||
'permissions' => [AskForPermissionsConsent::ALEXA_ALERTS_REMINDERS_SKILL_READWRITE], | ||
]; | ||
|
||
$this->assertEquals($expected, $card->toArray()); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testInstantiationDeviceAllAddress(): void | ||
{ | ||
$card = new AskForPermissionsConsent( | ||
[AskForPermissionsConsent::READ_ALEXA_DEVICE_ALL_ADDRESS] | ||
); | ||
|
||
$expected = [ | ||
'type' => 'AskForPermissionsConsent', | ||
'permissions' => [AskForPermissionsConsent::READ_ALEXA_DEVICE_ALL_ADDRESS], | ||
]; | ||
|
||
$this->assertEquals($expected, $card->toArray()); | ||
} | ||
} |