-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add methods for tasks and document creation endpoints
- Loading branch information
1 parent
ea59b38
commit d6a90cc
Showing
24 changed files
with
489 additions
and
32 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
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
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
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
54 changes: 54 additions & 0 deletions
54
source/VMelnalksnis.PaperlessDotNet/Documents/DocumentCreation.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,54 @@ | ||
// Copyright 2022 Valters Melnalksnis | ||
// Licensed under the Apache License 2.0. | ||
// See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.IO; | ||
|
||
using NodaTime; | ||
|
||
namespace VMelnalksnis.PaperlessDotNet.Documents; | ||
|
||
/// <summary>Information needed to create a new <see cref="Document"/>.</summary> | ||
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global", Justification = "Required endpoints for testing not implemented")] | ||
public sealed class DocumentCreation | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="DocumentCreation"/> class.</summary> | ||
/// <param name="document">The document content.</param> | ||
/// <param name="fileName">The name of the file.</param> | ||
public DocumentCreation(Stream document, string fileName) | ||
{ | ||
Document = document; | ||
FileName = fileName; | ||
|
||
TagIds = Array.Empty<int>(); | ||
} | ||
|
||
/// <summary>Gets the content of the document.</summary> | ||
public Stream Document { get; } | ||
|
||
/// <inheritdoc cref="Document.OriginalFileName"/> | ||
public string FileName { get; } | ||
|
||
/// <inheritdoc cref="Document.Created"/> | ||
public Instant? Created { get; init; } | ||
|
||
/// <inheritdoc cref="Document.Title"/> | ||
public string? Title { get; init; } | ||
|
||
/// <inheritdoc cref="Document.CorrespondentId"/> | ||
public int? CorrespondentId { get; init; } | ||
|
||
/// <inheritdoc cref="Document.DocumentTypeId"/> | ||
public int? DocumentTypeId { get; init; } | ||
|
||
/// <summary>Gets the id of the storage path.</summary> | ||
public int? StoragePathId { get; init; } | ||
|
||
/// <inheritdoc cref="Document.TagIds"/> | ||
public int[] TagIds { get; init; } | ||
|
||
/// <inheritdoc cref="Document.ArchivedFileName"/> | ||
public uint? ArchiveSerialNumber { get; init; } | ||
} |
32 changes: 32 additions & 0 deletions
32
source/VMelnalksnis.PaperlessDotNet/Documents/DocumentCreationResult.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,32 @@ | ||
// Copyright 2022 Valters Melnalksnis | ||
// Licensed under the Apache License 2.0. | ||
// See LICENSE file in the project root for full license information. | ||
|
||
namespace VMelnalksnis.PaperlessDotNet.Documents; | ||
#pragma warning disable SA1402 | ||
|
||
/// <summary>Base class for possible results of creating a new document.</summary> | ||
/// <seealso cref="ImportStarted"/> | ||
/// <seealso cref="DocumentCreated"/> | ||
/// <seealso cref="ImportFailed"/> | ||
public abstract class DocumentCreationResult; | ||
|
||
/// <summary>Document was successfully created.</summary> | ||
/// <param name="id">The id of the created document.</param> | ||
public sealed class DocumentCreated(int id) : DocumentCreationResult | ||
{ | ||
/// <summary>Gets the id of the created document.</summary> | ||
public int Id { get; } = id; | ||
} | ||
|
||
/// <summary>Document was successfully submitted and import was started.</summary> | ||
/// <remarks>This is only returned for version below or equal to 1.9.2.</remarks> | ||
public sealed class ImportStarted : DocumentCreationResult; | ||
|
||
/// <summary>Document import process failed.</summary> | ||
/// <param name="result">The result message returned by paperless.</param> | ||
public sealed class ImportFailed(string? result) : DocumentCreationResult | ||
{ | ||
/// <summary>Gets the result message returned by paperless.</summary> | ||
public string? Result { get; } = result; | ||
} |
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
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
Oops, something went wrong.