This repository has been archived by the owner on Jan 5, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor for compile issues adding badges refactor interfaces ignore nuget packages documentation remove excess methods add multiple notifications sanitizing code change text update uri change data type refactor properties in winphone client changing names of variables
- Loading branch information
Shawn Feldman
committed
Jan 23, 2015
1 parent
2d0d68c
commit eb025c9
Showing
19 changed files
with
805 additions
and
266 deletions.
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
40 changes: 40 additions & 0 deletions
40
sdks/dotnet/samples/notifications/Usergrid.Notifications.sln
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,40 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.31101.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Usergrid.Notifications", "Usergrid.Notifications\Usergrid.Notifications.csproj", "{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|ARM = Debug|ARM | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|ARM = Release|ARM | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.ActiveCfg = Debug|ARM | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.Build.0 = Debug|ARM | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|ARM.Deploy.0 = Debug|ARM | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.ActiveCfg = Debug|x86 | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.Build.0 = Debug|x86 | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Debug|x86.Deploy.0 = Debug|x86 | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|Any CPU.Deploy.0 = Release|Any CPU | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.ActiveCfg = Release|ARM | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.Build.0 = Release|ARM | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|ARM.Deploy.0 = Release|ARM | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.ActiveCfg = Release|x86 | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.Build.0 = Release|x86 | ||
{EB364B8E-B7C1-45C2-BF13-1CBF731EA8B6}.Release|x86.Deploy.0 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
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
21 changes: 20 additions & 1 deletion
21
sdks/dotnet/samples/notifications/Usergrid.Notifications/App.xaml.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
80 changes: 80 additions & 0 deletions
80
sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/EntityResponse.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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* | ||
* * Licensed to the Apache Software Foundation (ASF) under one or more | ||
* * contributor license agreements. The ASF licenses this file to You | ||
* * under the Apache License, Version 2.0 (the "License"); you may not | ||
* * use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * http://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. For additional information regarding | ||
* * copyright in this work, please see the NOTICE file in the top level | ||
* * directory of this distribution. | ||
* | ||
*/ | ||
|
||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Usergrid.Notifications.Client | ||
{ | ||
public class EntityResponse : JObject | ||
{ | ||
private HttpResponseMessage response; | ||
|
||
private EntityResponse(HttpResponseMessage response, JObject jObject) | ||
: base() | ||
{ | ||
this.response = response; | ||
parseResponse(jObject); | ||
} | ||
|
||
private void parseResponse(JObject jobject) | ||
{ | ||
foreach (var kv in jobject) | ||
{ | ||
this[kv.Key] = kv.Value; | ||
} | ||
} | ||
|
||
public HttpStatusCode Status | ||
{ | ||
get { return this.response.StatusCode; } | ||
} | ||
|
||
public static async Task<EntityResponse> Parse(HttpResponseMessage httpResponseMessage) | ||
{ | ||
JObject jobject; | ||
|
||
using (var stream = await httpResponseMessage.Content.ReadAsStreamAsync()) | ||
{ | ||
using (var reader = new StreamReader(stream, Encoding.UTF8)) | ||
{ | ||
jobject = JObject.Parse(reader.ReadToEnd()); | ||
} | ||
} | ||
|
||
return new EntityResponse(httpResponseMessage, jobject); | ||
} | ||
|
||
public bool StatusIsOk | ||
{ | ||
get | ||
{ | ||
return this.Status == HttpStatusCode.OK; | ||
} | ||
} | ||
} | ||
} |
123 changes: 123 additions & 0 deletions
123
sdks/dotnet/samples/notifications/Usergrid.Notifications/Client/IUsergridClient.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 |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* | ||
* * Licensed to the Apache Software Foundation (ASF) under one or more | ||
* * contributor license agreements. The ASF licenses this file to You | ||
* * under the Apache License, Version 2.0 (the "License"); you may not | ||
* * use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * http://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. For additional information regarding | ||
* * copyright in this work, please see the NOTICE file in the top level | ||
* * directory of this distribution. | ||
* | ||
*/ | ||
|
||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Windows.Networking.PushNotifications; | ||
namespace Usergrid.Notifications.Client | ||
{ | ||
/// <summary> | ||
/// encapsulates usergrid calls, use UsergridFactory | ||
/// </summary> | ||
public interface IUsergridClient | ||
{ | ||
/// <summary> | ||
/// Authenticate your calls | ||
/// </summary> | ||
/// <param name="user"></param> | ||
/// <param name="password"></param> | ||
/// <param name="isManagement"></param> | ||
/// <returns></returns> | ||
Task Authenticate(string user, string password, bool isManagement); | ||
/// <summary> | ||
/// Send a message | ||
/// </summary> | ||
/// <param name="method"></param> | ||
/// <param name="url"></param> | ||
/// <param name="obj"></param> | ||
/// <returns></returns> | ||
Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj); | ||
/// <summary> | ||
/// Send a message | ||
/// </summary> | ||
/// <param name="method"></param> | ||
/// <param name="url"></param> | ||
/// <param name="obj"></param> | ||
/// <param name="useManagementUrl"></param> | ||
/// <returns></returns> | ||
Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl); | ||
/// <summary> | ||
/// Reference the push client, you should call register before using | ||
/// </summary> | ||
IPushClient Push { get; } | ||
|
||
Exception LastException { get; } | ||
|
||
} | ||
|
||
/// <summary> | ||
/// Only show http calls | ||
/// </summary> | ||
public interface IUsergridHttpClient | ||
{ | ||
/// <summary> | ||
/// Send Http call async | ||
/// </summary> | ||
/// <param name="method"></param> | ||
/// <param name="url"></param> | ||
/// <param name="obj"></param> | ||
/// <param name="useManagementUrl">use management endpoint</param> | ||
/// <returns></returns> | ||
Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj, bool useManagementUrl); | ||
/// <summary> | ||
/// send Http call async | ||
/// </summary> | ||
/// <param name="method"></param> | ||
/// <param name="url"></param> | ||
/// <param name="obj"></param> | ||
/// <returns></returns> | ||
Task<EntityResponse> SendAsync(HttpMethod method, string url, object obj); | ||
} | ||
|
||
/// <summary> | ||
/// Push client, call register | ||
/// </summary> | ||
public interface IPushClient | ||
{ | ||
/// <summary> | ||
/// the notifier you are currently using | ||
/// </summary> | ||
string Notifier { get; set; } | ||
|
||
/// <summary> | ||
/// Device id in usergrid | ||
/// </summary> | ||
Guid DeviceId { get; set; } | ||
/// <summary> | ||
/// send a toast | ||
/// </summary> | ||
/// <param name="message"></param> | ||
/// <returns></returns> | ||
Task<bool> SendToast(string message); | ||
|
||
/// <summary> | ||
/// Send a badge update | ||
/// </summary> | ||
/// <param name="message"></param> | ||
/// <returns></returns> | ||
Task<bool> SendBadge<T>(T message); | ||
|
||
Exception LastException { get; } | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.