-
-
Notifications
You must be signed in to change notification settings - Fork 309
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 #1579 from jovotech/v4/dev
🔖 Prepare latest release
- Loading branch information
Showing
5 changed files
with
107 additions
and
1 deletion.
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
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,41 @@ | ||
import { Alexa } from './Alexa'; | ||
import { Request } from './interfaces'; | ||
|
||
export class AlexaTask { | ||
constructor(private alexa: Alexa) {} | ||
|
||
getTask(): Request['task'] { | ||
return this.alexa.$request.request?.task; | ||
} | ||
|
||
get version(): string | undefined { | ||
return this.getTask()?.version; | ||
} | ||
|
||
get name(): string | undefined { | ||
return this.getTask()?.name; | ||
} | ||
|
||
get input(): Record<string, unknown> | undefined { | ||
return this.getTask()?.input; | ||
} | ||
|
||
/** | ||
* Looks at the task name and checks if it ends with the provided taskName. Ignores skillId prefix | ||
* @param taskName Task name without skill id | ||
* @returns true, if task name comes after the skill id | ||
*/ | ||
hasTaskName(taskName: string): boolean { | ||
if (!this.name) return false; | ||
return this.name.endsWith(`.${taskName}`); | ||
} | ||
|
||
isVersion(version: number | string): boolean { | ||
if (!this.version) return false; | ||
return this.version === `${version}`; | ||
} | ||
|
||
toJSON(): AlexaTask { | ||
return { ...this, alexa: undefined }; | ||
} | ||
} |
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