iterable-client-dotnet is a client library targeting .NET Standard 1.3, .NET Standard 2.0, .NET 4.5 and .NET 4.6.1 that provides an easy way to interact with iterable.com API
All API requests must be accompanied by a api key. You need to register then create an api key from iterable.com Integrations
Because of armut.com is already using iterable, armut.com will keep this client library up to date and maintain it.
- .NET 4.5 (Desktop / Server)
- .NET 4.6.1 (Desktop / Server)
- .NET Standard 1.3
- .NET Standard 2.0
- Dependency injection friendly (can also be used standalone, see below)
- Supports async and sync calls.
Build server | Platform | Build status |
---|---|---|
Travis | Linux | |
Azure Pipelines | Ubuntu | |
Azure Pipelines | MacOs | |
Azure Pipelines | Windows |
Package | |
---|---|
iterable-client-dotnet | |
iterable-client-extension-dotnet |
Following commands can be used to install both Armut.Iterable.Client and Armut.Iterable.Client.Extension, run the following command in the Package Manager Console
Install-Package Armut.Iterable.Client
Install-Package Armut.Iterable.Client.Extension
Or use dotnet cli
dotnet Armut.Iterable.Client
dotnet Armut.Iterable.Client.Extension
Armut.Iterable.Client can be used with any DI library, or it can be used standalone.
If you do not want to use any DI framework, you have to instantiate IterableStandalone
as follows.
IIterableFactory iterableFactory = IterableStandalone.Create("your_api_key");
UserClient client = iterableFactory.CreateUserClient();
IIterableFactory
contains all necessary clients.
First, you need to install Microsoft.Extensions.DependencyInjection
and Microsoft.Extensions.Http
NuGet package as follows
dotnet add package Microsoft.Extensions.DependencyInjection
dotnet add package Microsoft.Extensions.Http
By installing Microsoft.Extensions.Http
you will be able to use HttpClientFactory
.In the words of the ASP.NET Team it is “an opinionated factory for creating HttpClient instances” and is a new feature comes with the release of ASP.NET Core 2.1.
If you don't want to use HttpClientFactory
, you must register HttpClient
yourself with the container or you can use a factory with yout DI framework as follows
var serviceCollection = new ServiceCollection();
HttpClient iterableHttpClient = new HttpClient
{
BaseAddress = new Uri("https://api.iterable.com/")
};
iterableHttpClient.DefaultRequestHeaders.Add("Api-Key", "your_api_key");
serviceCollection.AddSingleton(clientFactory =>
{
return (Func<string, HttpClient>)(key =>
{
switch (key)
{
case "IterableClient":
return iterableHttpClient;
default:
return null;
}
});
});
var serviceProvider = services.BuildServiceProvider();
var userClient = serviceProvider.GetRequiredService<IUserClient>();
By referencing Armut.Iterable.Client.Extension, register necessary dependencies to ServiceCollection
as follows
var serviceCollection = new ServiceCollection();
serviceCollection.AddIterableClient("your_api_key");
var serviceProvider = services.BuildServiceProvider();
var userClient = serviceProvider.GetRequiredService<IUserClient>();
or
var serviceCollection = new ServiceCollection();
HttpClient iterableHttpClient = new HttpClient
{
BaseAddress = new Uri("https://api.iterable.com/")
};
iterableHttpClient.DefaultRequestHeaders.Add("Api-Key", "your_api_key");
serviceCollection.AddSingleton(clientFactory =>
{
return (Func<string, HttpClient>)(key =>
{
switch (key)
{
case "IterableClient":
return iterableHttpClient;
default:
return null;
}
});
});
serviceCollection.AddIterableClient();
var serviceProvider = services.BuildServiceProvider();
var userClient = serviceProvider.GetRequiredService<IUserClient>();
The methods that end with Async returns model itself without additional HTTP response information.
var userModel = await userClient.GetByEmailAsync("info@armut.com");
You can find all of the samples from here
Licensed under MIT, see LICENSE for the full text.