SeliseBlocks.Ecohub.SAF
0.0.0-preview.3
See the version list below for details.
dotnet add package SeliseBlocks.Ecohub.SAF --version 0.0.0-preview.3
NuGet\Install-Package SeliseBlocks.Ecohub.SAF -Version 0.0.0-preview.3
<PackageReference Include="SeliseBlocks.Ecohub.SAF" Version="0.0.0-preview.3" />
<PackageVersion Include="SeliseBlocks.Ecohub.SAF" Version="0.0.0-preview.3" />
<PackageReference Include="SeliseBlocks.Ecohub.SAF" />
paket add SeliseBlocks.Ecohub.SAF --version 0.0.0-preview.3
#r "nuget: SeliseBlocks.Ecohub.SAF, 0.0.0-preview.3"
#:package SeliseBlocks.Ecohub.SAF@0.0.0-preview.3
#addin nuget:?package=SeliseBlocks.Ecohub.SAF&version=0.0.0-preview.3&prerelease
#tool nuget:?package=SeliseBlocks.Ecohub.SAF&version=0.0.0-preview.3&prerelease
SeliseBlocks.Ecohub.SAF
Overview
SeliseBlocks.Ecohub.SAF
is a .NET library designed to integrate Ecohub SAF functionality into your application. It provides services for authentication, event handling, and API interactions with the SAF platform. This library simplifies the process of interacting with the SAF API by offering pre-built interfaces and models.
Installation
To install the SeliseBlocks.Ecohub.SAF
library, use the following command:
dotnet add package SeliseBlocks.Ecohub.SAF
This will add the library to your project as a NuGet package.
Getting Started
Register Dependencies
Before using the library, you need to register its services in your application's dependency injection container. Add the following line to your Program.cs
file:
services.RegisterSafDriverServices("https://your-saf-api-base-url");
This method registers the following services:
ISafAuthService
: Handles authentication with the SAF API.ISafApiService
: Provides methods for interacting with the SAF API.ISafEventService
: Manages SAF event handling.
Features and Usage
1. Authentication
The ISafAuthService
interface provides methods for handling authentication with the SAF API.
Retrieve Bearer Token
To obtain a bearer token, use the GetBearerToken
method:
Task<SafBearerTokenResponse> GetBearerToken(SafBearerTokenRequest request);
Parameters:
SafBearerTokenRequest
: Contains the request URL and body for obtaining the bearer token.RequestUrl
: The endpoint for obtaining the token.Body
: Includes authentication details such asgrantType
,clientId
,clientSecret
, andscope
.
Returns: A
SafBearerTokenResponse
object containing the bearer token and related information.
Example:
var tokenRequest = new SafBearerTokenRequest
{
RequestUrl = "https://your-saf-api-url/token",
Body = new SafAccessTokenRequestBody
{
GrantType = "client_credentials",
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
Scope = "your-scope"
}
};
var tokenResponse = await authService.GetBearerToken(tokenRequest);
Console.WriteLine($"Access Token: {tokenResponse.AccessToken}");
2. SAF API Interactions
The ISafApiService
interface provides methods for interacting with the SAF API.
Retrieve Receivers
To retrieve a list of receivers, use the GetReceiversAsync
method:
Task<SafReceiversResponse> GetReceiversAsync(SafReceiversRequest request);
Parameters:
SafReceiversRequest
: Contains the request details for retrieving receiver information.
Returns: A
SafReceiversResponse
object containing the list of receivers.
Retrieve Member Public Key
To retrieve the public key of a member, use the GetMemberPublicKey
method:
Task<SafMemberPublicKeyResponse> GetMemberPublicKey(string bearerToken, string idpNumber);
Parameters:
bearerToken
: The authentication token.idpNumber
: The IDP number of the member.
Returns: A
SafMemberPublicKeyResponse
object containing the member's public key.
Example:
var publicKeyResponse = await apiService.GetMemberPublicKey("your-bearer-token", "12345");
Console.WriteLine($"Public Key: {publicKeyResponse.Key}");
3. SAF Event Handling
The ISafEventService
interface provides methods for sending and receiving SAF events.
Send Offer NLPI Event
To send an offer NLPI event, use the SendOfferNlpiEventAsync
method:
Task<SafSendOfferNlpiEventResponse> SendOfferNlpiEventAsync(SafSendOfferNlpiEventRequest request);
Parameters:
SafSendOfferNlpiEventRequest
: Contains the event payload, schema version IDs, and authentication details.
Returns: A
SafSendOfferNlpiEventResponse
object containing schema IDs and offsets of the sent event.
Example:
var sendRequest = new SafSendOfferNlpiEventRequest
{
SchemaVersionId = "1",
KeySchemaVersionId = "1",
BearerToken = "your-bearer-token",
EventPayload = new SafOfferNlpiEvent
{
Id = "event-id",
Source = "source",
Type = "type",
Data = new SafData
{
Payload = Encoding.UTF8.GetBytes("your-payload"),
PublicKey = "your-public-key"
}
}
};
var sendResponse = await eventService.SendOfferNlpiEventAsync(sendRequest);
Console.WriteLine($"Schema ID: {sendResponse.ValueSchemaId}");
Receive Offer NLPI Event
To receive an offer NLPI event, use the ReceiveOfferNlpiEventAsync
method:
Task<SafOfferNlpiEvent> ReceiveOfferNlpiEventAsync(SafReceiveOfferNlpiEventRequest request);
Parameters:
SafReceiveOfferNlpiEventRequest
: Contains the bearer token, Ecohub ID, offset reset configuration, and private key.
Returns: A
SafOfferNlpiEvent
object containing the details of the received event.
Example:
var receiveRequest = new SafReceiveOfferNlpiEventRequest
{
BearerToken = "your-bearer-token",
EcohubId = "your-ecohub-id",
AutoOffsetReset = "earliest",
PrivateKey = "your-private-key"
};
var receivedEvent = await eventService.ReceiveOfferNlpiEventAsync(receiveRequest);
Console.WriteLine($"Event ID: {receivedEvent.Id}");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 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. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Http (>= 9.0.4)
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 |
---|---|---|
8.0.0-beta.1 | 118 | 7/16/2025 |
1.0.0-beta.6 | 80 | 5/25/2025 |
1.0.0-beta.5 | 52 | 5/24/2025 |
1.0.0-beta.4 | 124 | 5/7/2025 |
1.0.0-beta.3 | 128 | 5/7/2025 |
1.0.0-beta.2 | 132 | 4/23/2025 |
1.0.0-beta.1 | 134 | 4/21/2025 |
0.0.0-preview.3 | 63 | 4/19/2025 |
0.0.0-preview.2 | 135 | 4/9/2025 |
0.0.0-preview.1 | 332 | 3/22/2025 |