From 3e9151086860de502bf8cbf72ab1877c12c8d254 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 18 Jun 2016 16:10:09 -0400 Subject: [PATCH] implemented repository for device apis --- src/Android/MainApplication.cs | 2 +- .../Repositories/IDeviceApiRepository.cs | 10 ++++++++++ src/App/App.csproj | 4 ++++ src/App/Models/Api/Request/DeviceRequest.cs | 11 +++++++++++ src/App/Models/Api/Response/DeviceResponse.cs | 13 +++++++++++++ src/App/Repositories/DeviceApiRepository.cs | 11 +++++++++++ src/iOS/AppDelegate.cs | 1 + 7 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/App/Abstractions/Repositories/IDeviceApiRepository.cs create mode 100644 src/App/Models/Api/Request/DeviceRequest.cs create mode 100644 src/App/Models/Api/Response/DeviceResponse.cs create mode 100644 src/App/Repositories/DeviceApiRepository.cs diff --git a/src/Android/MainApplication.cs b/src/Android/MainApplication.cs index 171cd0a99..49d34b55f 100644 --- a/src/Android/MainApplication.cs +++ b/src/Android/MainApplication.cs @@ -84,7 +84,6 @@ namespace Bit.Android public static void StartPushService() { AppContext.StartService(new Intent(AppContext, typeof(PushNotificationService))); - if(global::Android.OS.Build.VERSION.SdkInt >= global::Android.OS.BuildVersionCodes.Kitkat) { PendingIntent pintent = PendingIntent.GetService(AppContext, 0, new Intent(AppContext, typeof(PushNotificationService)), 0); @@ -126,6 +125,7 @@ namespace Bit.Android .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) // Other .RegisterInstance(CrossSettings.Current, new ContainerControlledLifetimeManager()) .RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager()) diff --git a/src/App/Abstractions/Repositories/IDeviceApiRepository.cs b/src/App/Abstractions/Repositories/IDeviceApiRepository.cs new file mode 100644 index 000000000..962362c3e --- /dev/null +++ b/src/App/Abstractions/Repositories/IDeviceApiRepository.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Bit.App.Models.Api; + +namespace Bit.App.Abstractions +{ + public interface IDeviceApiRepository : IApiRepository + { } +} \ No newline at end of file diff --git a/src/App/App.csproj b/src/App/App.csproj index db05d0964..5e6f37d38 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -35,6 +35,7 @@ 4 + @@ -65,12 +66,14 @@ + + @@ -102,6 +105,7 @@ + diff --git a/src/App/Models/Api/Request/DeviceRequest.cs b/src/App/Models/Api/Request/DeviceRequest.cs new file mode 100644 index 000000000..2797d274f --- /dev/null +++ b/src/App/Models/Api/Request/DeviceRequest.cs @@ -0,0 +1,11 @@ +using PushNotification.Plugin.Abstractions; + +namespace Bit.App.Models.Api +{ + public class DeviceRequest + { + public DeviceType Type { get; set; } + public string Name { get; set; } + public string PushToken { get; set; } + } +} diff --git a/src/App/Models/Api/Response/DeviceResponse.cs b/src/App/Models/Api/Response/DeviceResponse.cs new file mode 100644 index 000000000..10fc40802 --- /dev/null +++ b/src/App/Models/Api/Response/DeviceResponse.cs @@ -0,0 +1,13 @@ +using System; +using PushNotification.Plugin.Abstractions; + +namespace Bit.App.Models.Api +{ + public class DeviceResponse + { + public string Id { get; set; } + public string Name { get; set; } + public DeviceType Type { get; set; } + public DateTime CreationDate { get; set; } + } +} diff --git a/src/App/Repositories/DeviceApiRepository.cs b/src/App/Repositories/DeviceApiRepository.cs new file mode 100644 index 000000000..1a0a0a78a --- /dev/null +++ b/src/App/Repositories/DeviceApiRepository.cs @@ -0,0 +1,11 @@ +using System; +using Bit.App.Abstractions; +using Bit.App.Models.Api; + +namespace Bit.App.Repositories +{ + public class DeviceApiRepository : ApiRepository, IDeviceApiRepository + { + protected override string ApiRoute => "devices"; + } +} diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index 67169aae3..25a157db2 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -193,6 +193,7 @@ namespace Bit.iOS .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) .RegisterType(new ContainerControlledLifetimeManager()) + .RegisterType(new ContainerControlledLifetimeManager()) // Other .RegisterInstance(CrossSettings.Current, new ContainerControlledLifetimeManager()) .RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager())