Kemenkeu.Client.Core 0.1.0

dotnet add package Kemenkeu.Client.Core --version 0.1.0
                    
NuGet\Install-Package Kemenkeu.Client.Core -Version 0.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="Kemenkeu.Client.Core" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kemenkeu.Client.Core" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Kemenkeu.Client.Core" />
                    
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 Kemenkeu.Client.Core --version 0.1.0
                    
#r "nuget: Kemenkeu.Client.Core, 0.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.
#addin nuget:?package=Kemenkeu.Client.Core&version=0.1.0
                    
Install Kemenkeu.Client.Core as a Cake Addin
#tool nuget:?package=Kemenkeu.Client.Core&version=0.1.0
                    
Install Kemenkeu.Client.Core as a Cake Tool

NuGet Package Documentation for Kemenkeu.Client.Core

Overview

Kemenkeu.Client.Core is a .NET library designed to provide core functionalities for Kemenkeu services. This package simplifies development by offering reusable components and services.

Installation

To install the NuGet package, use the following command in the Package Manager Console:

Install-Package Kemenkeu.Client.Core

Or, using the .NET CLI:

dotnet add package Kemenkeu.Client.Core

Configuration

Add the following configuration to your appsettings.json and adjust according the system config:

1. With User Token

{
  "ExternalService": {
    "BaseUrl": "https://thegatewayservice.com"
  }
}

2. With Application Token

{
  "Auth": {
    "AuthorityUrl": "https://authorizationserver.net",
  },
  "ExternalService": {
    "BaseUrl": "https://gatewayserver.net",
    "Auth": {
      "ClientId": "client_id",
      "ClientSecret": "client_secret",
      "GrantType": "grant_type",
      "Scope": "scope"
    },
  }
}

or

{
  "ExternalService": {
    "BaseUrl": "https://gatewayserver.net",
    "AuthorityUrl": "https://authorizationserver.net",
    "Auth": {
      "ClientId": "client_id",
      "ClientSecret": "client_secret",
      "GrantType": "grant_type",
      "Scope": "scope"
    },
  }
}

Usage

1. With User Token

a. Setup in Startup.cs

In .NET 5 or Older, use Startup.cs to configure services.

Register Kemenkeu.Client.Core in the ConfigureServices method:

public class Startup
{
    public IConfiguration Configuration { get; }

    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddKemenkeuClient(config =>
        {
            config.WithUserToken(Configuration);
        });
            
        // Other services...
    }
}
b. Setup in Program.cs

In .NET 6 or later, configure services directly in Program.cs.

Configure services and add caching:

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddKemenkeuClient(config =>
{
    config.WithUserToken(builder.Configuration);
});

var app = builder.Build();

// Configure others.

app.Run();

2. With Application Token

a. Setup in Startup.cs

In .NET 5 or Older, use Startup.cs to configure services.

Register Kemenkeu.Client.Core in the ConfigureServices method:

public class Startup
{
    public IConfiguration Configuration { get; }

    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddKemenkeuClient(config =>
        {
            config.WithApplicationToken(Configuration);
        });
            
        // Other services...
    }
}
b. Setup in Program.cs

In .NET 6 or later, configure services directly in Program.cs.

Configure services and add caching:

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddKemenkeuClient(config =>
{
    config.WithApplicationToken(builder.Configuration);
});

var app = builder.Build();

// Configure others.

app.Run();

3. Setup in your Project Controller or Service

  1. Add a reference to the Kemenkeu.Client.Core package in your project.
  2. Import the necessary namespaces in your code:
using Kemenkeu.Client.Core;
  1. Utilize the provided classes and methods as needed.

Sample usage IKemenkeuClient directly in your controller:

[ApiController]
[Route("[controller]")]
public class SampleController : ControllerBase
{
    private readonly IKemenkeuClient _kemenkeuClient;

    public SampleController(IKemenkeuClient kemenkeuClient)
    {
        _kemenkeuClient = kemenkeuClient;
    }

    [HttpGet]
    public async Task<ActionResult<SomeModel>> GetAsync()
    {
        string path = "path/to/service/controller/endpoint";

        // Get the HttpClient
        HttpClient client = _kemenkeuClient.GetClient();

        // Execute with auxilary function GetFromApiDataAsync provided by this package
        // It will will automatically unwrap the data from the json "data" field
        SomeModel result = await client.GetFromApiDataAsync<SomeModel>(path);

        // or anothers ordinary HttpClient methods such as GetFromJsonAsync, GetAsync
        // SomeModel result = await client.GetFromJson<SomeModel>(path);

        return result;
    }
}

Sample usage IKemenkeuClient in service:

public class SampleService
{
    private readonly IKemenkeuClient _kemenkeuClient;

    public SampleService(IKemenkeuClient kemenkeuClient)
    {
        _kemenkeuClient = kemenkeuClient;
    }

    public async Task<SomeModel> GetDataAsync()
    {
        string path = "path/to/service/controller/endpoint";

        // Get the HttpClient
        HttpClient client = _kemenkeuClient.GetClient();

        // Execute with auxilary function GetFromApiDataAsync provided by this package
        // It will will automatically unwrap the data from the json "data" field
        SomeModel result = await client.GetFromApiDataAsync<SomeModel>(path);

        // or anothers ordinary HttpClient methods such as GetFromJsonAsync, GetAsync
        // SomeModel result = await client.GetFromJson<SomeModel>(path);

        return result;
    }
}

Requirements

  • .NET Version: This package compatible with .NET Core 2.1 (via .NET Standard 2.0), .NET Core 3.1 and later.
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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.  net9.0 is compatible.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.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 Kemenkeu.Client.Core:

Package Downloads
Kemenkeu.Client.Hris.Core

Kemenkeu HRIS Core client library.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0 202 4/14/2025