VMelnalksnis.PaperlessDotNet 1.1.0

Prefix Reserved
dotnet add package VMelnalksnis.PaperlessDotNet --version 1.1.0                
NuGet\Install-Package VMelnalksnis.PaperlessDotNet -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VMelnalksnis.PaperlessDotNet" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VMelnalksnis.PaperlessDotNet --version 1.1.0                
#r "nuget: VMelnalksnis.PaperlessDotNet, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install VMelnalksnis.PaperlessDotNet as a Cake Addin
#addin nuget:?package=VMelnalksnis.PaperlessDotNet&version=1.1.0

// Install VMelnalksnis.PaperlessDotNet as a Cake Tool
#tool nuget:?package=VMelnalksnis.PaperlessDotNet&version=1.1.0                

Nuget Nuget Codecov Run tests

PaperlessDotNet

.NET client for the Paperless-ngx API.

Usage

A separate NuGet package is provided for ASP.NET Core (IConfiguration and IServiceCollection) . For use outside of ASP.NET Core, see the example in tests.

  1. Add configuration (see options)

    "Paperless": {
        "BaseAddress": "",
        "Token": ""
    }
    
  2. Register required services (see tests)

    serviceCollection
        .AddSingleton<IClock>(SystemClock.Instance)
        .AddSingleton(DateTimeZoneProviders.Tzdb)
        .AddPaperlessDotNet();
    
  3. Use IPaperlessClient to access all endpoints, or one of the specific clients defined in IPaperlessClient

Custom fields

Paperless supports adding custom fields to documents. In order to use custom fields, first define a class with a property for each field:

internal sealed class CustomFields
{
    public string? Field1 { get; set; }

    public Uri? Field2 { get; set; }

    public LocalDate? Field3 { get; set; }

    public bool? Field4 { get; set; }

    public int? Field5 { get; set; }

    public float? Field6 { get; set; }

    public float? Field7 { get; set; }

    public int[]? Field8 { get; set; }
}

Then create a JsonSerializerContext with all the API models that use custom fields:

[JsonSerializable(typeof(PaginatedList<Document<CustomFields>>))]
[JsonSerializable(typeof(DocumentUpdate<CustomFields>))]
internal sealed partial class SerializerContext : JsonSerializerContext;

And configure JSON serialization for the client:

serviceCollection.AddPaperlessDotNet(
    configuration,
    options =>
    {
        options.Options.Converters.Add(new CustomFieldsConverter<CustomFields>(options));
        options.Options.TypeInfoResolverChain.Add(SerializerContext.Default);
    });

For a working example see unit tests and integration tests.

Select custom fields

Version 2.11.0 introduced select custom fields, which require additional setup in order to serialize/deserialize properly. First, you'll need to define SmartEnum class for each select custom field:

public sealed class SelectOptions : SmartEnum<SelectOptions>
{
    public static readonly SelectOptions Option1 = new("First option", 0);
    public static readonly SelectOptions Option2 = new("Second option", 1);

    private SelectOptions(string name, int value)
        : base(name, value)
    {
    }
}

NOTE: the values MUST be sequential and start at 0 in order to match how they are stored in paperless.

Then you can add the property to your CustomFields class

    public SelectOptions? Field9 { get; set; }

and add the SmartEnumValueConverter<TEnum, TValue> in one of the possible ways:

    [JsonConverter(typeof(SmartEnumValueConverter<SelectOptions, int>))]
    public SelectOptions? Field9 { get; set; }

or

serviceCollection.AddPaperlessDotNet(
    configuration,
    options =>
    {
        options.Options.Converters.Add(new SmartEnumValueConverter<SelectOptions, int>())
        options.Options.Converters.Add(new CustomFieldsConverter<CustomFields>(options));
        options.Options.TypeInfoResolverChain.Add(SerializerContext.Default);
    });

In order to create a select custom field, you also need to use either SelectCustomFieldCreation<TEnum, TValue> or SelectCustomFieldCreation<TEnum> and add it to the JsonSerializerContext.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on VMelnalksnis.PaperlessDotNet:

Package Downloads
VMelnalksnis.PaperlessDotNet.DependencyInjection

Dependency injection configuration for VMelnalksnis.PaperlessDotNet

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 111 12/20/2024
1.0.1 124 12/5/2024
1.0.0 267 12/2/2024
0.3.3 417 10/10/2024
0.3.2 2,632 4/21/2024
0.3.1 1,153 2/3/2024
0.3.0 147 1/18/2024
0.2.0 3,108 11/8/2022
0.1.1 556 10/12/2022
0.1.0 585 8/29/2022