Penzle.Net.Microsoft.DependencyInjection 2.1.4

dotnet add package Penzle.Net.Microsoft.DependencyInjection --version 2.1.4
                    
NuGet\Install-Package Penzle.Net.Microsoft.DependencyInjection -Version 2.1.4
                    
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="Penzle.Net.Microsoft.DependencyInjection" Version="2.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Penzle.Net.Microsoft.DependencyInjection" Version="2.1.4" />
                    
Directory.Packages.props
<PackageReference Include="Penzle.Net.Microsoft.DependencyInjection" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Penzle.Net.Microsoft.DependencyInjection --version 2.1.4
                    
#r "nuget: Penzle.Net.Microsoft.DependencyInjection, 2.1.4"
                    
#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.
#:package Penzle.Net.Microsoft.DependencyInjection@2.1.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Penzle.Net.Microsoft.DependencyInjection&version=2.1.4
                    
Install as a Cake Addin
#tool nuget:?package=Penzle.Net.Microsoft.DependencyInjection&version=2.1.4
                    
Install as a Cake Tool

Penzle.Net.Microsoft.DependencyInjection

Build and Test Licence W3C Paradigm

Getting started

Installation of the penzle package with support for dependency injection using the Visual Studio Package Manager Console:

Install-Package Penzle.Net.Microsoft.DependencyInjection

Installation using .NET CLI:

dotnet add <your project> package Penzle.Net.Microsoft.DependencyInjection

Usage

You can access data from the Penzle APIs by employing the IDeliveryPenzleClient, which offers functions for fetching information from the Penzle Delivery API. For tasks involving entries creation, updating, and deletion, you'll utilize the IManagementPenzleClient.

Reference the Penzle Dependency Injection Namespace

In your project files (e.g., Startup.cs or Program.cs), add a reference to the Penzle.Net.Microsoft.DependencyInjection namespace:

using Penzle.Net.Microsoft.DependencyInjection;

Configure the Service Collection

Set up the Penzle client by calling service.AddPenzleClient and providing it with your configuration:

using Microsoft.Extensions.Configuration;
using Penzle.Net.Microsoft.DependencyInjection;

// Retrieve your configuration, typically from an appsettings.json file
var configuration = new ConfigurationBuilder()
    .SetBasePath(Directory.GetCurrentDirectory())
    .AddJsonFile("appsettings.json")
    .Build();

// Configure the Penzle client with your PenzleApiConfig
service.AddPenzleClient((IConfigurationRoot)configuration);

Configuration in appsettings.json

To use the Penzle.Net.Microsoft.DependencyInjection package, it's essential to have the necessary Penzle API configuration properties in your appsettings.json file. These properties are used to configure the Penzle client. Here's an example configuration structure:

{
  "PenzleApiConfig": {
    "ApiManagementKey": "YourApiManagementKey",
    "ApiDeliveryKey": "YourApiDeliveryKey",
    "BaseUri": "https://api.penzle.com",
    "Environment": "YourEnvironment",
    "Project": "YourProject"
  }
}

Example of usage IDeliveryPenzleClient and IManagementPenzleClient

public class PenzleDataManagementRepository : IPenzleDataManagementRepository
{
    private readonly IDeliveryPenzleClient _deliveryPenzleClient;
    private readonly IManagementPenzleClient _managementPenzleClient;

    public PenzleDataManagementRepository(IManagementPenzleClient managementPenzleClient,
        IDeliveryPenzleClient deliveryPenzleClient)
    {
        _managementPenzleClient = managementPenzleClient;
        _deliveryPenzleClient = deliveryPenzleClient;
    }

    public async Task<TResponse> GetEntry<TResponse>(Guid entityId, CancellationToken cancellationToken) where TResponse : new()
    {
        return await _deliveryPenzleClient.Entry.GetEntry<TResponse>(entityId, cancellationToken: cancellationToken);
    }

    public async Task<Guid> SaveEntry<TInput>(TInput fields, string name, Guid? parentId = null, Guid? id = null, CancellationToken cancellationToken = default) where TInput : new()
    {
        var entry = new CreateEntryRequest<TInput>
        {
            Fields = fields,
            Name = name,
            Template = GetTemplateNameFromType(typeof(TInput).Name),
            ParentId = parentId,
            Id = id
        };
        return await _managementPenzleClient.Entry.CreateEntry(entry, cancellationToken);
    }

    public async Task<bool> UpdateEntry<TInput>(Guid entityId, TInput fields, string name, CancellationToken cancellationToken)
        where TInput : new()
    {
        var updateEntry = new UpdateEntryRequest<TInput>
        {
            Fields = fields,
            Name = name,
            Template = GetTemplateNameFromType(typeof(TInput).Name),
            Id = entityId
        };

        var response = await _managementPenzleClient.Entry.UpdateEntry(entityId, updateEntry,
            cancellationToken);

        return response == HttpStatusCode.NoContent;
    }

    public async Task<bool> DeleteEntry(Guid entryId, CancellationToken cancellationToken)
    {
        var response = await _managementPenzleClient.Entry.DeleteEntry(entryId, cancellationToken);

        return response == HttpStatusCode.NoContent;
    }

    public async Task<IReadOnlyList<TResponse>> GetEntriesByQuery<TResponse>(QueryEntryBuilder<TResponse> query, CancellationToken cancellationToken)
        where TResponse : new()
    {
        return await _deliveryPenzleClient.Entry.GetEntries(query, cancellationToken: cancellationToken);
    }
}

Contributing to Penzle.Net.Microsoft.DependencyInjection

Your thoughts and ideas are much appreciated. If you're interested in helping out with this project in any way, we'd like to make it as clear and straightforward as possible for you to do so, whether that's by:

  • Bug reporting
  • Addressing the present codebase
  • Offering a patch
  • Advancing ideas for brand new capabilities
  • Taking on the role of a maintainer

Github is where we host our code, manage bug reports and feature requests, and incorporate changes suggested by our users. Report bugs using Github's issues. We host our code on Github, which is also where we manage user bug reports and feature requests and incorporate modifications made by users. In general, high-quality bug reports consist of the following components: background information; reproducible steps; an example of the code, if the reporter possesses such an example.

License

MIT License

Copyright (c) 2022 Penzle LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.4 414 10/17/2023
2.1.3 137 10/17/2023
2.1.2 198 10/11/2023
2.1.1 162 10/4/2023
2.0.11 186 9/14/2023
2.0.10 180 9/7/2023
2.0.9 169 9/6/2023
2.0.8 165 9/6/2023
2.0.7 166 9/6/2023
2.0.6 161 9/6/2023
2.0.5 164 9/5/2023
2.0.4 177 8/23/2023
2.0.3 173 8/23/2023
2.0.2 146 8/11/2023
2.0.1-beta.1 140 8/2/2023
2.0.0 179 2/28/2023
1.1.0 165 2/28/2023
1.0.0-rc.5 168 10/26/2022
1.0.0-rc.4 151 10/26/2022
1.0.0-rc.3 140 10/26/2022
1.0.0-rc.2 142 10/26/2022
1.0.0-rc.1 151 10/24/2022