Newline53.Sdk 0.5.12

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

Newline .NET SDK

Developer-friendly and type-safe .NET SDK built to leverage the Newline Platform APIs.

Table of Contents

SDK Installation

Install the Newline SDK as a package in your .NET project:

dotnet package add Newline53.sdk

SDK Example Usage

Example

using Newline53.Sdk;
using Newline53.Sdk.Models.Components;

var sdk = new NewlineSDK(security: new Security() {
    ProgramUid = "<YOUR_PROGRAM_UID_HERE>",
    HmacKey = "<YOUR_HMAC_KEY_HERE>",
});

var res = await sdk.Auth.GenerateTokenAsync();

// handle response

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
ProgramUid<br/>HmacKey http Custom HTTP

You can set the security parameters through the security optional parameter when initializing the SDK client instance. For example:

using Newline53.Sdk;
using Newline53.Sdk.Models.Components;

var sdk = new NewlineSDK(security: new Security() {
    ProgramUid = "<YOUR_PROGRAM_UID_HERE>",
    HmacKey = "<YOUR_HMAC_KEY_HERE>",
});

var res = await sdk.Auth.GenerateTokenAsync();

// handle response

Available Resources and Operations

<details open> <summary>Available methods</summary>

Auth

CombinedTransfers

  • List - List Combined Transfers
  • Create - Create a new Combined Transfer
  • Get - Get a single Combined Transfer

CustodialAccounts

CustomerProducts

  • List - List Customer Products
  • Onboard - Onboard Customer onto a Product
  • Get - Get a single Customer Product

Customers

  • List - Get a list of Customers
  • Create - Create a new Customer
  • Get - Get a single Customer
  • Update - Adjust Customer Data
  • Archive - Archive a Customer

Pools

  • List - List Pools
  • Get - Get a single Pool

Products

  • List - List Products
  • Get - Get a single Product

Returns

  • List - List Returns
  • Create - Create a new Return
  • Get - Get a single Return

SyntheticAccounts

Transactions

Transfers

  • List - List Transfers
  • Create - Initiate a Transfer
  • Get - Get a single Transfer
  • Cancel - Cancel a Transfer

VirtualReferenceNumbers

  • List - List Virtual Reference Numbers
  • Create - Create a new Virtual Reference Number
  • Get - Get a single Virtual Reference Number
  • Update - Edit a Virtual Reference Number
  • Archive - Archive a single Virtual Reference Number
  • Lock - Lock a single Virtual Reference Number
  • Unlock - Unlock a single Virtual Reference Number

</details>

Error Handling

NewlineSDKException is the base exception class for all HTTP error responses. It has the following properties:

Property Type Description
Message string Error message
Request HttpRequestMessage HTTP request object
Response HttpResponseMessage HTTP response object

Some exceptions in this SDK include an additional Payload field, which will contain deserialized custom error data when present. Possible exceptions are listed in the Error Classes section.

Example

using Newline53.Sdk;
using Newline53.Sdk.Models.Components;
using Newline53.Sdk.Models.Errors;
using Newline53.Sdk.Models.Requests;
using System.Collections.Generic;

var sdk = new NewlineSDK(security: new Security() {
    ProgramUid = "<YOUR_PROGRAM_UID_HERE>",
    HmacKey = "<YOUR_HMAC_KEY_HERE>",
});

try
{
    OnboardCustomerProductRequest req = new OnboardCustomerProductRequest() {
        CustomerUid = "S62MaHx6WwsqG9vQ",
        ProductUid = "pQtTCSXz57fuefzp",
    };

    var res = await sdk.CustomerProducts.OnboardAsync(req);

    // handle response
}
catch (NewlineSDKException ex) // all SDK exceptions inherit from NewlineSDKException
{
    // ex.ToString() provides a detailed error message
    System.Console.WriteLine(ex);

    // Base exception fields
    HttpRequestMessage request = ex.Request;
    HttpResponseMessage response = ex.Response;
    var statusCode = (int)response.StatusCode;
    var responseBody = ex.Body;

    if (ex is OnboardCustomerProductUnprocessableEntityException) // different exceptions may be thrown depending on the method
    {
        // Check error data fields
        OnboardCustomerProductUnprocessableEntityExceptionPayload payload = ex.Payload;
        List<OnboardCustomerProductError> Errors = payload.Errors;
        long Status = payload.Status;
        // ...
    }

    // An underlying cause may be provided
    if (ex.InnerException != null)
    {
        Exception cause = ex.InnerException;
    }
}
catch (OperationCanceledException ex)
{
    // CancellationToken was cancelled
}
catch (System.Net.Http.HttpRequestException ex)
{
    // Check ex.InnerException for Network connectivity errors
}

Error Classes

Primary exception:

<details><summary>Less common exceptions (34)</summary>

* Refer to the relevant documentation to determine whether an exception applies to a specific operation.

Server Selection

Select Server by Name

You can override the default server globally by passing a server name to the server: string optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:

Name Server Description
sandbox https://sandbox.newline53.com/api/v1 Sandbox
prod https://api.newline53.com/api/v1 Production
Example
using Newline53.Sdk;
using Newline53.Sdk.Models.Components;

var sdk = new NewlineSDK(
    server: SDKConfig.Server.Sandbox,
    security: new Security() {
        ProgramUid = "<YOUR_PROGRAM_UID_HERE>",
        HmacKey = "<YOUR_HMAC_KEY_HERE>",
    }
);

var res = await sdk.Auth.GenerateTokenAsync();

// handle response

Override Server URL Per-Client

The default server can also be overridden globally by passing a URL to the serverUrl: string optional parameter when initializing the SDK client instance. For example:

using Newline53.Sdk;
using Newline53.Sdk.Models.Components;

var sdk = new NewlineSDK(
    serverUrl: "https://sandbox.newline53.com/api/v1",
    security: new Security() {
        ProgramUid = "<YOUR_PROGRAM_UID_HERE>",
        HmacKey = "<YOUR_HMAC_KEY_HERE>",
    }
);

var res = await sdk.Auth.GenerateTokenAsync();

// handle response

Custom HTTP Client

The C# SDK makes API calls using an ISpeakeasyHttpClient that wraps the native HttpClient. This client provides the ability to attach hooks around the request lifecycle that can be used to modify the request or handle errors and response.

The ISpeakeasyHttpClient interface allows you to either use the default SpeakeasyHttpClient that comes with the SDK, or provide your own custom implementation with customized configuration such as custom message handlers, timeouts, connection pooling, and other HTTP client settings.

The following example shows how to create a custom HTTP client with request modification and error handling:

using Newline53.Sdk;
using Newline53.Sdk.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

// Create a custom HTTP client
public class CustomHttpClient : ISpeakeasyHttpClient
{
    private readonly ISpeakeasyHttpClient _defaultClient;

    public CustomHttpClient()
    {
        _defaultClient = new SpeakeasyHttpClient();
    }

    public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
    {
        // Add custom header and timeout
        request.Headers.Add("x-custom-header", "custom value");
        request.Headers.Add("x-request-timeout", "30");
        
        try
        {
            var response = await _defaultClient.SendAsync(request, cancellationToken);
            // Log successful response
            Console.WriteLine($"Request successful: {response.StatusCode}");
            return response;
        }
        catch (Exception error)
        {
            // Log error
            Console.WriteLine($"Request failed: {error.Message}");
            throw;
        }
    }

    public void Dispose()
    {
        _httpClient?.Dispose();
        _defaultClient?.Dispose();
    }
}

// Use the custom HTTP client with the SDK
var customHttpClient = new CustomHttpClient();
var sdk = new NewlineSDK(client: customHttpClient);

<details> <summary>You can also provide a completely custom HTTP client with your own configuration:</summary>

using Newline53.Sdk.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

// Custom HTTP client with custom configuration
public class AdvancedHttpClient : ISpeakeasyHttpClient
{
    private readonly HttpClient _httpClient;

    public AdvancedHttpClient()
    {
        var handler = new HttpClientHandler()
        {
            MaxConnectionsPerServer = 10,
            // ServerCertificateCustomValidationCallback = customCertValidation, // Custom SSL validation if needed
        };

        _httpClient = new HttpClient(handler)
        {
            Timeout = TimeSpan.FromSeconds(30)
        };
    }

    public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
    {
        return await _httpClient.SendAsync(request, cancellationToken ?? CancellationToken.None);
    }

    public void Dispose()
    {
        _httpClient?.Dispose();
    }
}

var sdk = NewlineSDK.Builder()
    .WithClient(new AdvancedHttpClient())
    .Build();

</details>

<details> <summary>For simple debugging, you can enable request/response logging by implementing a custom client:</summary>

public class LoggingHttpClient : ISpeakeasyHttpClient
{
    private readonly ISpeakeasyHttpClient _innerClient;

    public LoggingHttpClient(ISpeakeasyHttpClient innerClient = null)
    {
        _innerClient = innerClient ?? new SpeakeasyHttpClient();
    }

    public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
    {
        // Log request
        Console.WriteLine($"Sending {request.Method} request to {request.RequestUri}");
        
        var response = await _innerClient.SendAsync(request, cancellationToken);
        
        // Log response
        Console.WriteLine($"Received {response.StatusCode} response");
        
        return response;
    }

    public void Dispose() => _innerClient?.Dispose();
}

var sdk = new NewlineSDK(client: new LoggingHttpClient());

</details>

The SDK also provides built-in hook support through the SDKConfiguration.Hooks system, which automatically handles BeforeRequestAsync, AfterSuccessAsync, and AfterErrorAsync hooks for advanced request lifecycle management.

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

License

Apache 2.0

See Also

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
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
0.5.12 107 7/23/2026