Skip to content

Commit

Permalink
Added documentation and a Stylish material design theme project.
Browse files Browse the repository at this point in the history
  • Loading branch information
camalot committed Feb 28, 2015
1 parent bc0090b commit a51aa41
Show file tree
Hide file tree
Showing 23 changed files with 16,075 additions and 3 deletions.
6 changes: 6 additions & 0 deletions AmazonEcho.sln
Expand Up @@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".git", ".git", "{5AB9697C-5
.gitignore = .gitignore
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StylishMaterialTheme", "StylishMaterialTheme\StylishMaterialTheme.csproj", "{AD36BC90-13CD-4705-91D9-B8DB9C6A1461}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,6 +29,10 @@ Global
{CB1C06D3-FB86-43BA-A723-B4D1523536B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB1C06D3-FB86-43BA-A723-B4D1523536B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB1C06D3-FB86-43BA-A723-B4D1523536B6}.Release|Any CPU.Build.0 = Release|Any CPU
{AD36BC90-13CD-4705-91D9-B8DB9C6A1461}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD36BC90-13CD-4705-91D9-B8DB9C6A1461}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD36BC90-13CD-4705-91D9-B8DB9C6A1461}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD36BC90-13CD-4705-91D9-B8DB9C6A1461}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
83 changes: 80 additions & 3 deletions AmazonEchoApi/AlexaRequest.cs
Expand Up @@ -57,9 +57,14 @@ private sealed class Features {
private const string FEATURE_PHOENIX = "PHOENIX_FEATURE";
}

/// <summary>
/// Initializes a new instance of the <see cref="AlexaRequest"/> class.
/// </summary>
/// <param name="username">The username.</param>
/// <param name="password">The password.</param>
public AlexaRequest(string username, string password) {
Username = username;
Password = password;
Username = username.Require();
Password = password.Require();
Cookies = new CookieContainer();

ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
Expand All @@ -71,22 +76,34 @@ private sealed class Features {

private string Username { get; set; }
private string Password { get; set; }

private CookieContainer Cookies { get; set; }

/// <summary>
/// Gets the tasks.
/// </summary>
/// <returns></returns>
public IEnumerable<TaskItem> GetTasks() {
if(Login()) {
return DeserializeStream<TaskItemCollection>(Urls.TASKS).Values;
}
return null;
}
/// <summary>
/// Gets the shopping items.
/// </summary>
/// <returns></returns>
public IEnumerable<TaskItem> GetShoppingItems() {
if(Login()) {
return DeserializeStream<TaskItemCollection>(Urls.SHOPPING).Values;
}
return null;
}

/// <summary>
/// Determines whether the specified feature is supported.
/// </summary>
/// <param name="feature">The feature.</param>
/// <returns></returns>
public bool HasSupport(string feature) {
if(Login()) {
var result = DeserializeStream<FeatureAccessResult>(Urls.FEATURE_ACCESS_FORMAT.With(feature.Require()));
Expand All @@ -95,6 +112,11 @@ private sealed class Features {
return false;
}

/// <summary>
/// Updates the task item.
/// </summary>
/// <param name="task">The task.</param>
/// <returns></returns>
public TaskItem UpdateTaskItem(TaskItem task) {
if(Login()) {
var result = Put<TaskItem>(task, Urls.TASK_PUT_FORMAT.With(task.Id));
Expand All @@ -104,6 +126,11 @@ private sealed class Features {
}


/// <summary>
/// Plays the specified device.
/// </summary>
/// <param name="device">The device.</param>
/// <returns></returns>
public bool Play(EchoDevice device) {
if(Login()) {
var result = Post<MediaStatePayload>(new MediaStatePayload {
Expand All @@ -116,13 +143,24 @@ private sealed class Features {
return false;
}

/// <summary>
/// Plays the specified device.
/// </summary>
/// <param name="deviceSerialNumber">The device serial number.</param>
/// <param name="deviceType">Type of the device.</param>
/// <returns></returns>
public bool Play(string deviceSerialNumber, string deviceType) {
return Play(new EchoDevice {
Type = deviceType.Require(),
SerialNumber = deviceSerialNumber.Require()
});
}

/// <summary>
/// Stops the specified device.
/// </summary>
/// <param name="device">The device.</param>
/// <returns></returns>
public bool Stop(EchoDevice device) {
if(Login()) {
var result = Post<MediaStatePayload>(new MediaStatePayload {
Expand All @@ -135,13 +173,25 @@ private sealed class Features {
return false;
}

/// <summary>
/// Stops the specified device.
/// </summary>
/// <param name="deviceSerialNumber">The device serial number.</param>
/// <param name="deviceType">Type of the device.</param>
/// <returns></returns>
public bool Stop(string deviceSerialNumber, string deviceType) {
return Stop(new EchoDevice {
Type = deviceType.Require(),
SerialNumber = deviceSerialNumber.Require()
});
}

/// <summary>
/// Sets the volume on the specified device.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="volume">The volume.</param>
/// <returns></returns>
public bool Volume(EchoDevice device, int volume) {
if(Login()) {
var result = Post<MediaStatePayload>(new MediaStatePayload {
Expand All @@ -154,13 +204,25 @@ private sealed class Features {
return false;
}

/// <summary>
/// Sets the volume on the specified device.
/// </summary>
/// <param name="deviceSerialNumber">The device serial number.</param>
/// <param name="deviceType">Type of the device.</param>
/// <param name="volume">The volume.</param>
/// <returns></returns>
public bool Volume(string deviceSerialNumber, string deviceType, int volume) {
return Volume(new EchoDevice {
Type = deviceType.Require(),
SerialNumber = deviceSerialNumber.Require()
}, volume);
}

/// <summary>
/// Mutes the specified device.
/// </summary>
/// <param name="device">The device.</param>
/// <returns></returns>
public bool Mute(EchoDevice device) {
if(Login()) {
var result = Post<MediaStatePayload>(new MediaStatePayload {
Expand All @@ -173,17 +235,32 @@ private sealed class Features {
return false;
}

/// <summary>
/// Mutes the specified device serial number.
/// </summary>
/// <param name="deviceSerialNumber">The device serial number.</param>
/// <param name="deviceType">Type of the device.</param>
/// <returns></returns>
public bool Mute(string deviceSerialNumber, string deviceType) {
return Mute(new EchoDevice {
Type = deviceType.Require(),
SerialNumber = deviceSerialNumber.Require()
});
}

/// <summary>
/// Logout of Echo service.
/// </summary>
/// <returns></returns>
public bool Logout() {
return GetDataStream(Urls.LOGOUT) != null;
}

/// <summary>
/// Login to the Echo service.
/// </summary>
/// <returns></returns>
/// <exception cref="System.Net.WebException"></exception>
public bool Login() {

// this needs to check if we need to log in, or if we are already logged in.
Expand Down
144 changes: 144 additions & 0 deletions StylishMaterialTheme/StylishMaterialTheme.csproj
@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AD36BC90-13CD-4705-91D9-B8DB9C6A1461}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StylishMaterialTheme</RootNamespace>
<AssemblyName>StylishMaterialTheme</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<Content Include="demo\css\682ad-app.min.css" />
<Content Include="demo\css\bootstrap.min.css" />
<Content Include="demo\html\index.html" />
<Content Include="demo\html\cards.html" />
<Content Include="demo\img\sprites\55977-spinner-grey-opt.svg" />
<Content Include="demo\img\sprites\eeb15-logo-sprite.svg" />
<Content Include="stylish.css">
<DependentUpon>stylish.less</DependentUpon>
</Content>
<Content Include="stylish.less" />
<Content Include="stylish.min.css">
<DependentUpon>stylish.css</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Content Include="stylish.css.map">
<DependentUpon>stylish.css</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="includes\_colors.less" />
</ItemGroup>
<ItemGroup>
<Content Include="includes\_cards.less" />
</ItemGroup>
<ItemGroup>
<Content Include="includes\_fonts.less" />
</ItemGroup>
<ItemGroup>
<Content Include="includes\_root.less" />
</ItemGroup>
<ItemGroup>
<Content Include="includes\_navigation.less" />
</ItemGroup>
<ItemGroup>
<Content Include="includes\_shadows.less" />
</ItemGroup>
<ItemGroup>
<Content Include="includes\_delete.less" />
</ItemGroup>
<ItemGroup>
<Content Include="includes\_mixins.less" />
</ItemGroup>
<ItemGroup>
<Content Include="includes\_todo.less" />
</ItemGroup>
<ItemGroup>
<Content Include="includes\_media-controls.less" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>8501</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:8501/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

0 comments on commit a51aa41

Please sign in to comment.