This file contains hidden or 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
| object Utils { | |
| fun getLanguage(locale: String) = locale.substringBefore('-') | |
| fun getRegion(locale: String) = locale.substringAfter('-') | |
| } |
This file contains hidden or 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
| override fun handle(input: HandlerInput): Optional<Response> { | |
| val request = input.requestEnvelope.request | |
| val intentRequest = request as IntentRequest | |
| val intent = intentRequest.intent | |
| val slots = intent.slots | |
| val releasesDate = slots["releasesDate"]!! | |
| val dateValue = releasesDate.value | |
| DirectiveServiceHandler(input).onRequestingUpcomings(input.getLanguage()) | |
| val movies = moviesGetter.getUpcomings(intentRequest.locale, dateValue) |
This file contains hidden or 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
| object Translations { | |
| enum class TranslationKey { | |
| WELCOME, HELP, THANKS, UPCOMINGS_NOT_FOUND, ASKING_FOR_NOW_PLAYING, UPCOMINGS_RESPONSE, | |
| ERROR_ASKING_NOW_PLAYING, NOW_PLAYING_RESPONSE, REQUESTING_UPCOMINGS, REQUESTING_NOW_PLAYING_MOVIES, AND | |
| } | |
| fun getMessage(language: String, messageKey: TranslationKey) = | |
| messages.getValue(language)[messageKey] | |
| ?: throw InternalServerErrorException("There is not messages for $language - $messageKey") |
This file contains hidden or 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
| class NewReleasesIntentHandler(private val moviesGetter: MoviesGetter) : RequestHandler { | |
| override fun canHandle(input: HandlerInput): Boolean { | |
| return input.matches(Predicates.intentName("NewReleasesIntent")) | |
| } | |
| override fun handle(input: HandlerInput): Optional<Response> { | |
| ... | |
| // Get slots values and so on | |
| ... |
This file contains hidden or 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
| ... | |
| import com.amazon.ask.model.services.directive.Header | |
| import com.amazon.ask.model.services.directive.SendDirectiveRequest | |
| import com.amazon.ask.model.services.directive.SpeakDirective | |
| ... | |
| class DirectiveServiceHandler( | |
| private val input: HandlerInput | |
| ) { |
This file contains hidden or 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
| module.exports = { | |
| talks: [ | |
| {"time": "09:00", "title":"Keynote", "topics":[]}, | |
| {"time": "10:15", "title":"Cultura de empresa y tecnología", "topics":["BUSINESS"]}, | |
| {"time": "11:15", "title":"Caja negra, caja blanca y el futuro inmediato de la Inteligencia Artificial", "topics":["DEV"]}, | |
| {"time": "12:15", "title":"Bioimpresión CCMI", "topics":["MAKERS"]}, | |
| {"time": "13:15", "title":"Gestión de la Innovación", "topics":["BUSINESS"]}, | |
| {"time": "15:30", "title":"Gestión de servicios con equipos distribuidos", "topics":["DEV"]}, | |
| {"time": "16:30", "title":"Programando diseños 3D", "topics":["MAKERS"]}, | |
| {"time": "17:45", "title":"Keynote de cierre", "topics":[]} |
This file contains hidden or 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
| private fun getRandomOkSpeech(): String { | |
| val randomOkSpeechcon = listOf("okey", "okey dokey", "okey makey")[Random.nextInt(2)] | |
| return "<say-as interpret-as=\"interjection\">$randomOkSpeechcon</say-as>" | |
| } |
This file contains hidden or 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
| private fun Movie.getTitle() = | |
| when { | |
| originalTitle == title && originalLanguage != "es" -> { | |
| val lang = ssmlLangByMovieOriginalLanguage[originalLanguage] | |
| when { | |
| lang != null && lang.isNotBlank() -> "<lang xml:lang=$lang>${originalTitle.sanitaze()}</lang>" | |
| else -> { | |
| println("Unhandled original language $originalLanguage") | |
| title.sanitaze() | |
| } |
This file contains hidden or 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
| override fun handle(input: HandlerInput): Optional<Response> { | |
| val request = input.requestEnvelope.request | |
| val intentRequest = request as IntentRequest | |
| ... | |
| val movies = moviesGetter.getUpcomings(intentRequest.locale, dateValue) | |
| ... | |
| } |
This file contains hidden or 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
| class MoviesGetter(gson: Gson) { | |
| private val theMovieDBService = TheMovieDBService(gson) | |
| fun getUpcomings(locale: String, releaseDate: String) = theMovieDBService.getUpcomings(locale) | |
| .filter { it.isReleasedOnDate(releaseDate) } | |
| .map { it.getTitle() } | |
| .getResponse() | |
| fun getNowPlayingMovies(locale: String) = theMovieDBService.getNowPlayingMovies(locale) |