forked from timheuer/alexa-skills-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
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 timheuer#1 from tobiasviehweger/master
Support for AudioPlayerPlay Response
- Loading branch information
Showing
19 changed files
with
259 additions
and
94 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Alexa.NET.Request.Type | ||
{ | ||
public class AudioPlayerRequest: Request | ||
{ | ||
[JsonProperty("token")] | ||
public string Token { get; set; } | ||
|
||
[JsonProperty("locale")] | ||
public string Locale { get; set; } | ||
|
||
[JsonProperty("offsetInMilliseconds")] | ||
public string OffsetInMilliseconds { get; set; } | ||
|
||
[JsonProperty("error")] | ||
public Error Error { get; set; } | ||
|
||
[JsonProperty("currentPlaybackState")] | ||
public PlaybackState CurrentPlaybackState { get; set; } | ||
} | ||
} |
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,17 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Alexa.NET.Request.Type | ||
{ | ||
public class Error | ||
{ | ||
[JsonProperty("type")] | ||
public string Type { get; set; } | ||
|
||
[JsonProperty("message")] | ||
public string Message { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
namespace Alexa.NET.Request.Type | ||
{ | ||
public class IntentRequest : Request | ||
{ | ||
public Intent Intent { get; set; } | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Alexa.NET/Request/Type/ILaunchRequest.cs → Alexa.NET/Request/Type/LaunchRequest.cs
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace Alexa.NET.Request.Type | ||
{ | ||
public interface ILaunchRequest : IRequest | ||
public class LaunchRequest : 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,20 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Alexa.NET.Request.Type | ||
{ | ||
public class PlaybackState | ||
{ | ||
[JsonProperty("token")] | ||
public string Token { get; set; } | ||
|
||
[JsonProperty("offsetInMilliseconds")] | ||
public string OffsetInMilliseconds { get; set; } | ||
|
||
[JsonProperty("playerActivity")] | ||
public string PlayerActivity { get; set; } | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,56 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
|
||
namespace Alexa.NET.Request.Type | ||
{ | ||
public class RequestConverter : JsonConverter | ||
{ | ||
public override bool CanWrite => false; | ||
|
||
public override bool CanConvert(System.Type objectType) | ||
{ | ||
return objectType == typeof(Request); | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override object ReadJson(JsonReader reader, System.Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
// Load JObject from stream | ||
var jObject = JObject.Load(reader); | ||
|
||
// Create target request object based on "type" property | ||
var target = Create(jObject["type"].Value<string>()); | ||
|
||
// Populate the object properties | ||
serializer.Populate(jObject.CreateReader(), target); | ||
|
||
return target; | ||
} | ||
|
||
public Request Create(string requestType) | ||
{ | ||
//AudioPlayer requests are very similar, map to single type | ||
if (requestType.StartsWith("AudioPlayer")) | ||
requestType = "AudioPlayer"; | ||
|
||
switch (requestType) | ||
{ | ||
case "IntentRequest": | ||
return new IntentRequest(); | ||
case "LaunchRequest": | ||
return new LaunchRequest(); | ||
case "SessionEndedRequest": | ||
return new SessionEndedRequest(); | ||
case "AudioPlayer": | ||
return new AudioPlayerRequest(); | ||
default: | ||
throw new ArgumentOutOfRangeException(nameof(Type), $"Unknown request type: {requestType}."); | ||
} | ||
} | ||
} | ||
} |
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,11 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Alexa.NET.Response.Directive | ||
{ | ||
public class AudioItem | ||
{ | ||
[JsonRequired] | ||
[JsonProperty("stream")] | ||
public AudioItemStream Stream { get; set; } | ||
} | ||
} |
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,22 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Alexa.NET.Response.Directive | ||
{ | ||
public class AudioItemStream | ||
{ | ||
[JsonRequired] | ||
[JsonProperty("url")] | ||
public string Url { get; set; } | ||
|
||
[JsonRequired] | ||
[JsonProperty("token")] | ||
public string Token { get; set; } | ||
|
||
[JsonProperty("expectedPreviousToken")] | ||
public string ExpectedPreviousToken { get; set; } | ||
|
||
[JsonRequired] | ||
[JsonProperty("offsetInMilliseconds")] | ||
public int OffsetInMilliseconds { get; set; } | ||
} | ||
} |
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,20 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
namespace Alexa.NET.Response.Directive | ||
{ | ||
public class AudioPlayerPlayDirective : IDirective | ||
{ | ||
[JsonProperty("playBehavior")] | ||
[JsonRequired] | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public PlayBehavior PlayBehavior { get; set; } | ||
|
||
[JsonProperty("audioItem")] | ||
[JsonRequired] | ||
public AudioItem AudioItem { get; set; } | ||
|
||
[JsonProperty("type")] | ||
public string Type => "AudioPlayer.Play"; | ||
} | ||
} |
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,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
using System.Threading.Tasks; | ||
|
||
namespace Alexa.NET.Response.Directive | ||
{ | ||
public enum PlayBehavior | ||
{ | ||
[EnumMember(Value = "REPLACE_ALL")] | ||
ReplaceAll, | ||
[EnumMember(Value = "ENQUEUE")] | ||
Enqueue, | ||
[EnumMember(Value = "REPLACE_ENQUEUED")] | ||
ReplaceEnqueued | ||
} | ||
} |
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,14 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Alexa.NET.Response | ||
{ | ||
public interface IDirective | ||
{ | ||
[JsonRequired] | ||
string Type { get; } | ||
} | ||
} |
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
Oops, something went wrong.