Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added desktop version of the library. Also added notification classes…

…/method
  • Loading branch information...
commit fa0082c4281d72172c715602301a2de5a541a98c 1 parent 3e1a8c9
@joelmartinez authored
View
BIN  DarkSky.Mono.suo
Binary file not shown
View
BIN  DarkSky.WindowsPhone/DarkSky.WindowsPhone.suo
Binary file not shown
View
133 DarkSky/Api.cs
@@ -1,60 +1,73 @@
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Collections.Generic;
-
-namespace DarkSky
-{
- public class Api
- {
- string apikey;
-
- public Api(string key)
- {
- this.apikey = key;
- }
-
- public Task<FullForecast> GetForecastAsync(Position position)
- {
- //https://api.darkskyapp.com/v1/forecast/APIKEY/LAT,LON
- string url = "https://api.darkskyapp.com/v1/forecast/{0}/{1},{2}";
- url = string.Format(url, apikey, position.Latitude, position.Longitude);
-
- return WebHelper.Json<FullForecast>(url);
- }
-
- public Task<Forecast> GetBriefForecastAsync(Position position)
- {
- //https://api.darkskyapp.com/v1/brief_forecast/APIKEY/LAT,LON
- string url = "https://api.darkskyapp.com/v1/forecast/{0}/{1},{2}";
- url = string.Format(url, apikey, position.Latitude, position.Longitude);
-
- return WebHelper.Json<Forecast>(url);
- }
-
- public Task<HourPrecipitation[]> GetPrecipitationAsync(params TimePosition[] values)
- {
- //https://api.darkskyapp.com/v1/precipitation/APIKEY/LAT1,LON1,TIME1;LAT2,LON2,TIME2;...
- string url = "https://api.darkskyapp.com/v1/precipitation/{0}/{1}";
-
- var stringLocations = values.Select(v => v.ToString()).ToArray();
- string locations = string.Join(";", stringLocations);
-
- url = string.Format(url, apikey, locations);
-
- return WebHelper.Json<PrecipitationRoot>(url)
- .ContinueWith<HourPrecipitation[]>(response => response.Result.Precipitation);
- }
-
- public Task<InterestingStorm[]> GetInterestingStormsAsync()
- {
- //https://api.darkskyapp.com/v1/interesting/APIKEY
- string url = "https://api.darkskyapp.com/v1/interesting/{0}";
- url = string.Format(url, apikey);
-
- return WebHelper.Json<InterestingStormRoot>(url)
- .ContinueWith<InterestingStorm[]>(r => r.Result.Storms);
- }
- }
-}
-
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+
+namespace DarkSky
+{
+ public class Api
+ {
+ string apikey;
+
+ public Api(string key)
+ {
+ this.apikey = key;
+ }
+
+ public Task<FullForecast> GetForecastAsync(Position position)
+ {
+ //https://api.darkskyapp.com/v1/forecast/APIKEY/LAT,LON
+ string url = "https://api.darkskyapp.com/v1/forecast/{0}/{1},{2}";
+ url = string.Format(url, apikey, position.Latitude, position.Longitude);
+
+ return WebHelper.Json<FullForecast>(url);
+ }
+
+ public Task<Forecast> GetBriefForecastAsync(Position position)
+ {
+ //https://api.darkskyapp.com/v1/brief_forecast/APIKEY/LAT,LON
+ string url = "https://api.darkskyapp.com/v1/forecast/{0}/{1},{2}";
+ url = string.Format(url, apikey, position.Latitude, position.Longitude);
+
+ return WebHelper.Json<Forecast>(url);
+ }
+
+ public Task<HourPrecipitation[]> GetPrecipitationAsync(params TimePosition[] values)
+ {
+ //https://api.darkskyapp.com/v1/precipitation/APIKEY/LAT1,LON1,TIME1;LAT2,LON2,TIME2;...
+ string url = "https://api.darkskyapp.com/v1/precipitation/{0}/{1}";
+
+ var stringLocations = values.Select(v => v.ToString()).ToArray();
+ string locations = string.Join(";", stringLocations);
+
+ url = string.Format(url, apikey, locations);
+
+ return WebHelper.Json<PrecipitationRoot>(url)
+ .ContinueWith<HourPrecipitation[]>(response => response.Result.Precipitation);
+ }
+
+ public Task<InterestingStorm[]> GetInterestingStormsAsync()
+ {
+ //https://api.darkskyapp.com/v1/interesting/APIKEY
+ string url = "https://api.darkskyapp.com/v1/interesting/{0}";
+ url = string.Format(url, apikey);
+
+ return WebHelper.Json<InterestingStormRoot>(url)
+ .ContinueWith<InterestingStorm[]>(r => r.Result.Storms);
+ }
+
+ #region Weather Notifications
+
+ public Task<Notification> GetNotification(string id)
+ {
+ //https://api.darkskyapp.com/v1/notification/APIKEY/ID
+ string url = "https://api.darkskyapp.com/v1/notification/{0}/{1}";
+ url = string.Format(url, apikey, Uri.EscapeDataString(id));
+
+ return WebHelper.Json<Notification>(url);
+ }
+
+ #endregion
+ }
+}
+
View
59 DarkSky/DarkSky.csproj
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{69AAA614-89A7-45B3-878C-EB04F2FDE89C}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>DarkSky</RootNamespace>
+ <AssemblyName>DarkSky</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</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\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Runtime.Serialization" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Api.cs" />
+ <Compile Include="Epoch.cs" />
+ <Compile Include="Forecast.cs" />
+ <Compile Include="Notification.cs" />
+ <Compile Include="Position.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TimePosition.cs" />
+ <Compile Include="WebHelper.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- 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>
View
6 DarkSky/DarkSky.csproj.user
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectView>ProjectFiles</ProjectView>
+ </PropertyGroup>
+</Project>
View
20 DarkSky/DarkSky.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DarkSky", "DarkSky.csproj", "{69AAA614-89A7-45B3-878C-EB04F2FDE89C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {69AAA614-89A7-45B3-878C-EB04F2FDE89C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {69AAA614-89A7-45B3-878C-EB04F2FDE89C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {69AAA614-89A7-45B3-878C-EB04F2FDE89C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {69AAA614-89A7-45B3-878C-EB04F2FDE89C}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
41 DarkSky/Notification.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Runtime.Serialization;
+using Epoch.Extensions;
+
+namespace DarkSky
+{
+ [DataContract]
+ public class Notification
+ {
+ [DataMember(Name="id")]
+ public string Id { get; set; }
+
+ [DataMember(Name = "latitude")]
+ public double Latitude { get; set; }
+
+ [DataMember(Name = "longitude")]
+ public double Longitude { get; set; }
+
+ [DataMember(Name = "threshold")]
+ public string Threshold { get; set; }
+
+ [DataMember(Name = "createdAt")]
+ public int CreatedAtUnix { get; set; }
+
+ public DateTime CreatedAt { get { return this.CreatedAtUnix.FromUnix(); } }
+
+ [DataMember(Name = "lastNotificationAt")]
+ public int LastNotificationAtUnix { get; set; }
+
+ public DateTime LastNotificationAt { get { return this.LastNotificationAtUnix.FromUnix(); } }
+
+ [DataMember(Name = "notificationCount")]
+ public int NotificationCount { get; set; }
+
+ [DataMember(Name = "callback")]
+ public string CallBack { get; set; }
+
+ [DataMember(Name = "enabled")]
+ public bool Enabled { get; set; }
+ }
+}
View
36 DarkSky/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("DarkSky")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("DarkSky")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("78848954-2100-4af2-906d-4a2e555d37b9")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Please sign in to comment.
Something went wrong with that request. Please try again.