Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ConsoleAppCore/ConsoleAppCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

<ItemGroup>
<ProjectReference Include="..\Api\Api.csproj" />
<ProjectReference Include="..\Core\RecordingDownload.Core.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions Core/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace RecordingDownload.Core;

public class Class1
{

}
28 changes: 28 additions & 0 deletions Core/Models/DownloadProgress.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using KoenZomers.Ring.Api.Entities;

namespace KoenZomers.Ring.RecordingDownload.Core.Models;

public enum DownloadProgressState
{
Starting,
Retrying,
Completed,
Failed,
Skipped,
Waiting
}

public record DownloadProgress(
DownloadProgressState State,
DoorbotHistoryEvent Event,
int Index,
int Total,
int? DeviceId = null,
string? FilePath = null,
short Attempt = 1,
short MaxAttempts = 1,
string? Message = null,
Exception? Exception = null,
long? BytesDownloaded = null,
TimeSpan? Delay = null);
11 changes: 11 additions & 0 deletions Core/Models/DownloadSummary.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;
using KoenZomers.Ring.Api.Entities;

namespace KoenZomers.Ring.RecordingDownload.Core.Models;

public record DownloadFailure(DoorbotHistoryEvent Event, int? DeviceId, string? FilePath, string ErrorMessage);

public record DownloadSummary(int Requested, int Downloaded, int Failed, int Skipped, IReadOnlyList<DownloadFailure> Failures)
{
public bool HasAny => Requested > 0;
}
13 changes: 13 additions & 0 deletions Core/RecordingDownload.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Api\Api.csproj" />
</ItemGroup>

</Project>
36 changes: 36 additions & 0 deletions Core/RingDownloadOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;

namespace KoenZomers.Ring.RecordingDownload.Core;

/// <summary>
/// Configuration options describing what to download from Ring services.
/// </summary>
public class RingDownloadOptions
{
public DateTime? StartDate { get; set; }

public DateTime? EndDate { get; set; }

public string OutputPath { get; set; } = Environment.CurrentDirectory;

public string? Username { get; set; }

public string? Password { get; set; }

public bool ListBots { get; set; }

public string? Type { get; set; }

public short MaxRetries { get; set; } = 3;

public int? RingDeviceId { get; set; }

public IReadOnlyList<int>? RingDeviceIds { get; set; }

public bool ResumeFromLastDownload { get; set; }

public bool IgnoreCachedToken { get; set; }

public TimeSpan TimeBetweenCalls { get; set; } = TimeSpan.Zero;
}
14 changes: 14 additions & 0 deletions Core/Security/ITwoFactorCodeProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Threading;
using System.Threading.Tasks;

namespace KoenZomers.Ring.RecordingDownload.Core.Security;

/// <summary>
/// Obtains a two factor authentication code from the user when Ring requires it.
/// </summary>
public interface ITwoFactorCodeProvider
{
Task<string> RequestTwoFactorCodeAsync(TwoFactorRequest request, CancellationToken cancellationToken);
}

public record TwoFactorRequest(string Username);
Loading