Sinch 0.1.8-alpha

This is a prerelease version of Sinch.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Sinch --version 0.1.8-alpha                
NuGet\Install-Package Sinch -Version 0.1.8-alpha                
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="Sinch" Version="0.1.8-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sinch --version 0.1.8-alpha                
#r "nuget: Sinch, 0.1.8-alpha"                
#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.
// Install Sinch as a Cake Addin
#addin nuget:?package=Sinch&version=0.1.8-alpha&prerelease

// Install Sinch as a Cake Tool
#tool nuget:?package=Sinch&version=0.1.8-alpha&prerelease                

.NET SDK

License

.NET 5.0 .NET 6.0 .NET 7.0

Welcome to Sinch's .NET SDK.

Here you'll find documentation to start developing C# code using Sinch services.

To use this SDK you'll need a Sinch account and API keys. Please sign up at sinch.com

For more in depth version of the Sinch APIs, please refer to the official developer portal - developers.sinch.com

[!WARNING] This SDK is currently available as a technical preview. It is being provided for the purpose of collecting feedback, and should not be used in production environments.

Installation

SinchSDK can be installed using the Nuget package manager or the dotnet CLI.

dotnet add package Sinch

Getting started

Client initialization

To initialize communication with Sinch backed, credentials obtained from Sinch portal have to be provided to the main client class of this SDK.

[!NOTE] Always store your credentials securely as an environment variables or with a secret manager

using Sinch;

var sinch = new SinchClient(configuration["Sinch:KeyId"], configuration["Sinch:KeySecret"], configuration["Sinch:ProjectId"]);

To configure Conversation and SMS regions, use options:

var sinch = new SinchClient(
    configuration["Sinch:KeyId"],
    configuration["Sinch:KeySecret"], 
    configuration["Sinch:ProjectId"],
    options =>
    {
        options.SmsRegion = Sinch.SMS.SmsRegion.Eu;
        options.ConversationRegion = Sinch.Conversation.ConversationRegion.Eu;
    });

With ASP.NET dependency injection:

// SinchClient is thread safe so it's okay to add it as a singleton
builder.Services.AddSingleton<ISinch>(x => new SinchClient(
    builder.Configuration["Sinch:KeyId"],
    builder.Configuration["Sinch:KeySecret"],
    builder.Configuration["Sinch:ProjectId"]));

Products

Sinch client provides access to the following Sinch products:

  • Numbers
  • SMS
  • Work-in-Progress Conversation API

Usage example of the numbers product:

Sinch.Numbers.Active.List.Response response = await sinch.Numbers.Active.List(new Sinch.Numbers.Active.List.Request
{
    RegionCode = "US",
    Type = Types.Mobile
});

Handling exceptions

For an unsuccessful API calls ApiException will be thrown.

using Sinch;

try {
    var batch = await sinch.Sms.Batches.Send(new Sinch.SMS.Batches.Send.Request
    {
        Body = "Hello, World!",
        DeliveryReport = DeliveryReport.None,
        To = new List<string>()
        {
            123456789
        }
    });
}
catch(ApiException e) 
{
    logger.LogError("Api Exception. Status: {status}. Detailed message: {message}", e.Status, e.DetailedMessage);
}

Logging, HttpClient, and additional options

To configure logger, provide own HttpClient, and additional options utilize SinchOptions within constructor:

var sinch = new SinchClient(
    configuration["Sinch:KeyId"],
    configuration["Sinch:KeySecret"], 
    configuration["Sinch:ProjectId"],
    options =>
    {
        // provde any logger factory which satisfies Microsoft.Extensions.Logging.ILoggerFactory
        options.LoggerFactory = LoggerFactory.Create(config => { 
            // add log output to console
            config.AddConsole();
        });
        // Provide your http client here
        options.HttpClient = new HttpClient();
        // Set a region for SMS product
        options.SmsRegion = Sinch.SMS.SmsRegion.Eu;
    });
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 was computed.  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. 
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
1.1.2 172 10/16/2024
1.1.1 1,144 7/16/2024
1.1.0 97 7/15/2024
1.0.1 1,229 5/13/2024
1.0.0 122 5/7/2024
0.1.19-alpha 247 4/17/2024
0.1.18-alpha 121 3/25/2024
0.1.17-alpha 152 2/21/2024
0.1.16-alpha 112 2/5/2024
0.1.15-alpha 105 2/1/2024
0.1.14-alpha 113 1/22/2024
0.1.13-alpha 1,505 12/13/2023
0.1.11-alpha 135 11/30/2023
0.1.10-alpha 111 11/29/2023
0.1.9-alpha 834 10/27/2023
0.1.8-alpha 133 10/26/2023
0.1.7-alpha 106 9/21/2023
0.1.6-alpha 130 9/11/2023
0.1.5-alpha 144 9/1/2023
0.1.4-alpha 131 8/21/2023
0.1.2-alpha.1 92 7/19/2023