Skip to content

Commit

Permalink
Added a bit of configuration documentation and removed the Alexa faca…
Browse files Browse the repository at this point in the history
…de from the overwritten Application
  • Loading branch information
develpr committed May 28, 2015
1 parent e5ee55f commit 86edc32
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 38 deletions.
52 changes: 38 additions & 14 deletions config/alexa.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,55 @@

return [

/*
|--------------------------------------------------------------------------
| Alexa Auth Model
|--------------------------------------------------------------------------
|
| Which model should be used to store Alexa information
|
*/

'device' => [

'enable' => env("ALEXA_ENABLE_DEVICE", true),
'device' => [

/*
|--------------------------------------------------------------------------
| provider
|--------------------------------------------------------------------------
|
| `database` and `eloquent` providers are supported
|
*/
'provider' => env('ALEXA_DEVICE_PROVIDER', 'eloquent'),

/*
|--------------------------------------------------------------------------
| model
|--------------------------------------------------------------------------
|
| For *eloquent* provider, which model should be used for a Device. A Device
| model is provided out of the box, but any other eloquent model can be used
| as long as it implements the AmazonEchoDevice contract.
|
*/
'model' => env('ALEXA_ELOQUENT_DEVICE_MODEL', 'Develpr\AlexaApp\Device\Device'),

/*
|--------------------------------------------------------------------------
| table
|--------------------------------------------------------------------------
|
| For *database* provider, which table will store your alexa device
| data?
|
*/
'table' => env('ALEXA_DATABASE_DEVICE_TABLE', 'alexa_devices'),

/*
|--------------------------------------------------------------------------
| device_identifier
|--------------------------------------------------------------------------
|
| What is the attribute or table column name for the unique echo device
| id? This is the attribute used to look up a specific device via either
| eloquent or database providers.
|
*/
'device_identifier' => env('ALEXA_DEVICE_ID_ATTRIBUTE', 'device_user_id'),

'auto_create_device' => env('ALEXA_AUTO_CREATE_DEVICE', false),

],

'facadeAlias' => env('ALEXA_FACADE_ALIAS', 'Alexa')

];
25 changes: 23 additions & 2 deletions src/Alexa.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

use Develpr\AlexaApp\Device\DeviceProvider;
use Develpr\AlexaApp\Request\AlexaRequest;
use Develpr\AlexaApp\Response\AlexaResponse;
use Develpr\AlexaApp\Response\Speech;

class Alexa {

Expand Down Expand Up @@ -54,10 +56,29 @@ public function request()
return $this->alexaRequest;
}

public function response()
{
return new AlexaResponse;
}

public function say($statementWords)
{
$response = new AlexaResponse(new Speech($statementWords));

return $response;
}

public function ask($question)
{
$response = new AlexaResponse(new Speech($question));

$response->setIsPrompt(true);

return $response;
}

public function device($attributes = [])
{
if( ! $this->alexaConfig['device']['enable'])
throw new \Exception("Alexa device functionality is disabled. Please see documentation.");

if( ! $this->isAlexaRequest() )
return null;
Expand Down
20 changes: 0 additions & 20 deletions src/AlexaApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ class AlexaApplication extends Application
{
private $intentRoutes = [];

/**
* Indicates if the class aliases have been registered.
*
* @var bool
*/
protected static $alexaAliasesRegistered = false;

public function intent($uri, $intent, $action)
{
$this->intentRoutes[] = $uri;
Expand Down Expand Up @@ -90,18 +83,5 @@ private function getIntentFromRequest()

}

//If the parent class
public function withFacades()
{
parent::withFacades();

if (! static::$alexaAliasesRegistered){

static::$alexaAliasesRegistered = true;
class_alias('Develpr\AlexaApp\Facades\Alexa', env('ALEXA_FACADE', "Alexa"));

}
}


}
1 change: 0 additions & 1 deletion src/Request/BaseAlexaRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
abstract class BaseAlexaRequest implements AlexaRequest
{
private $data = [];
private $session = [];

function __construct(Request $request)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Response/AlexaResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ class AlexaResponse implements Jsonable
*/
private $alexa;

function __construct()
function __construct(Speech $speech = null, Card $card = null)
{
$this->speech = $speech;
$this->card = $card;
$this->alexa = app()->make('alexa');

return $this;
Expand Down

0 comments on commit 86edc32

Please sign in to comment.