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
<PackageReference Include="Kemenkeu.Client.Core" Version="0.1.0" />
<PackageVersion Include="Kemenkeu.Client.Core" Version="0.1.0" />
<PackageReference Include="Kemenkeu.Client.Core" />
paket add Kemenkeu.Client.Core --version 0.1.0
#r "nuget: Kemenkeu.Client.Core, 0.1.0"
#addin nuget:?package=Kemenkeu.Client.Core&version=0.1.0
#tool nuget:?package=Kemenkeu.Client.Core&version=0.1.0
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
- Add a reference to the
Kemenkeu.Client.Core
package in your project. - Import the necessary namespaces in your code:
using Kemenkeu.Client.Core;
- 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 | Versions 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. |
-
.NETCoreApp 3.1
- Microsoft.AspNetCore.HeaderPropagation (>= 3.1.32)
- Microsoft.Extensions.Configuration (>= 9.0.4)
- Microsoft.Extensions.Http (>= 9.0.4)
- System.Net.Http.Json (>= 9.0.4)
-
.NETStandard 2.0
- Microsoft.AspNetCore.Authentication (>= 2.3.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.Extensions.Configuration (>= 9.0.4)
- Microsoft.Extensions.Http (>= 9.0.4)
- Microsoft.Extensions.Options (>= 9.0.4)
- System.Net.Http.Json (>= 9.0.4)
-
net5.0
- Microsoft.AspNetCore.HeaderPropagation (>= 5.0.17)
- Microsoft.Extensions.Configuration (>= 9.0.4)
- Microsoft.Extensions.Http (>= 9.0.4)
- System.Net.Http.Json (>= 9.0.4)
-
net6.0
- Microsoft.AspNetCore.HeaderPropagation (>= 6.0.36)
- Microsoft.Extensions.Configuration (>= 9.0.4)
- Microsoft.Extensions.Http (>= 9.0.4)
- System.Net.Http.Json (>= 9.0.4)
-
net7.0
- Microsoft.AspNetCore.HeaderPropagation (>= 7.0.20)
- Microsoft.Extensions.Configuration (>= 9.0.4)
- Microsoft.Extensions.Http (>= 9.0.4)
- System.Net.Http.Json (>= 9.0.4)
-
net8.0
- Microsoft.AspNetCore.HeaderPropagation (>= 8.0.15)
- Microsoft.Extensions.Configuration (>= 9.0.4)
- Microsoft.Extensions.Http (>= 9.0.4)
- System.Net.Http.Json (>= 9.0.4)
-
net9.0
- Microsoft.AspNetCore.HeaderPropagation (>= 9.0.4)
- Microsoft.Extensions.Configuration (>= 9.0.4)
- Microsoft.Extensions.Http (>= 9.0.4)
- System.Net.Http.Json (>= 9.0.4)
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 |