IronServices Core SDK for .NET
Go to file
David Friedel d64072a334 Initial commit: IronServices.Client SDK
Unified client for Iron Services APIs with:
- Session-based authentication
- Automatic token persistence
- Access to IronLicensing, IronNotify, and IronTelemetry APIs
- Generic HTTP methods for custom endpoints
2025-12-25 09:09:12 +00:00
.gitignore Initial commit: IronServices.Client SDK 2025-12-25 09:09:12 +00:00
ApiModels.cs Initial commit: IronServices.Client SDK 2025-12-25 09:09:12 +00:00
ITokenStorage.cs Initial commit: IronServices.Client SDK 2025-12-25 09:09:12 +00:00
IronServices.Client.csproj Initial commit: IronServices.Client SDK 2025-12-25 09:09:12 +00:00
IronServicesClient.cs Initial commit: IronServices.Client SDK 2025-12-25 09:09:12 +00:00
LICENSE Initial commit: IronServices.Client SDK 2025-12-25 09:09:12 +00:00
LicensingApi.cs Initial commit: IronServices.Client SDK 2025-12-25 09:09:12 +00:00
Models.cs Initial commit: IronServices.Client SDK 2025-12-25 09:09:12 +00:00
NotifyApi.cs Initial commit: IronServices.Client SDK 2025-12-25 09:09:12 +00:00
README.md Initial commit: IronServices.Client SDK 2025-12-25 09:09:12 +00:00
TelemetryApi.cs Initial commit: IronServices.Client SDK 2025-12-25 09:09:12 +00:00

README.md

IronServices.Client

Unified client for Iron Services APIs with session-based authentication. Access IronLicensing, IronNotify, and IronTelemetry from a single authenticated client.

NuGet License: MIT

Installation

dotnet add package IronServices.Client

Quick Start

using IronServices.Client;

// Create client
var client = new IronServicesClient(new IronServicesClientOptions
{
    LicensingUrl = "https://ironlicensing.com",
    NotifyUrl = "https://ironnotify.com",
    TelemetryUrl = "https://irontelemetry.com"
});

// Login
var loginResult = await client.LoginAsync("user@example.com", "password");

if (loginResult.Success)
{
    Console.WriteLine($"Welcome, {loginResult.DisplayName}!");

    // Access all Iron Services APIs
    var licenses = await client.Licensing.GetLicensesAsync();
    var events = await client.Notify.GetEventsAsync();
    var errors = await client.Telemetry.GetErrorsAsync();
}

Authentication

Login

var result = await client.LoginAsync("user@example.com", "password");

if (result.Success)
{
    Console.WriteLine($"User ID: {result.UserId}");
    Console.WriteLine($"Role: {result.Role}");
    Console.WriteLine($"Expires: {result.ExpiresAt}");
}
else
{
    Console.WriteLine($"Login failed: {result.Error}");
}

Register

var result = await client.RegisterAsync(
    email: "newuser@example.com",
    password: "securepassword",
    displayName: "John Doe"
);

if (result.Success)
{
    Console.WriteLine($"Registered! API Key: {result.ApiKey}");
}

Email Verification

var result = await client.VerifyEmailAsync("user@example.com", "123456");

if (result.Success)
{
    Console.WriteLine("Email verified!");
}

Password Reset

// Request reset email
await client.RequestPasswordResetAsync("user@example.com");

// Reset with token from email
var result = await client.ResetPasswordAsync(token, "newpassword");

Session Management

// Check authentication status
if (client.IsAuthenticated)
{
    Console.WriteLine($"Session expires: {client.SessionExpiresAt}");
}

// Get current user profile
var profile = await client.GetProfileAsync();

// Logout
await client.LogoutAsync();

Token Storage

Sessions are persisted automatically. Provide a custom storage for platform-specific secure storage:

public class SecureTokenStorage : ITokenStorage
{
    public async Task SaveTokenAsync(string token, DateTime? expiresAt)
    {
        await SecureStorage.SetAsync("session_token", token);
        if (expiresAt.HasValue)
            await SecureStorage.SetAsync("session_expires", expiresAt.Value.ToString("O"));
    }

    public async Task<(string? token, DateTime? expiresAt)> GetTokenAsync()
    {
        var token = await SecureStorage.GetAsync("session_token");
        var expiresStr = await SecureStorage.GetAsync("session_expires");
        DateTime? expires = expiresStr != null ? DateTime.Parse(expiresStr) : null;
        return (token, expires);
    }

    public async Task ClearTokenAsync()
    {
        SecureStorage.Remove("session_token");
        SecureStorage.Remove("session_expires");
    }
}

// Use custom storage
var client = new IronServicesClient(options, new SecureTokenStorage());

Service APIs

IronLicensing

// Get all licenses
var licenses = await client.Licensing.GetLicensesAsync();

// Get license details
var license = await client.Licensing.GetLicenseAsync(licenseId);

// Create license
var newLicense = await client.Licensing.CreateLicenseAsync(new CreateLicenseRequest
{
    TierId = tierId,
    CustomerEmail = "customer@example.com"
});

IronNotify

// Get events
var events = await client.Notify.GetEventsAsync();

// Get apps
var apps = await client.Notify.GetAppsAsync();

IronTelemetry

// Get errors
var errors = await client.Telemetry.GetErrorsAsync();

// Get projects
var projects = await client.Telemetry.GetProjectsAsync();

Configuration

var client = new IronServicesClient(new IronServicesClientOptions
{
    // Service URLs (defaults shown)
    LicensingUrl = "https://ironlicensing.com",
    NotifyUrl = "https://ironnotify.com",
    TelemetryUrl = "https://irontelemetry.com"
});

For local development:

var client = new IronServicesClient(new IronServicesClientOptions
{
    LicensingUrl = "https://localhost:5001",
    NotifyUrl = "https://localhost:5003",
    TelemetryUrl = "https://localhost:5005"
});

Generic API Methods

Make authenticated requests to any endpoint:

// GET
var data = await client.GetAsync<MyResponse>("https://ironlicensing.com/api/v1/custom");

// POST
var result = await client.PostAsync<MyRequest, MyResponse>(
    "https://ironlicensing.com/api/v1/custom",
    new MyRequest { /* ... */ }
);

// PUT
await client.PutAsync<MyRequest, MyResponse>(url, data);

// DELETE
await client.DeleteAsync(url);

License

MIT License - see LICENSE for details.