Skip to content

iterable-client-dotnet is a client library (C# wrapper) 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

License

Notifications You must be signed in to change notification settings

armutcom/iterable-client-dotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iterable-client-dotnet - iterable.com Client Library for .Net

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.

Supported Platforms

Features

  • Dependency injection friendly (can also be used standalone, see below)
  • Supports async and sync calls.

Continuous integration

Build server Platform Build status
Travis Linux Build Status
Azure Pipelines Ubuntu Build status
Azure Pipelines MacOs Build status
Azure Pipelines Windows Build status

Table of Contents

  1. Installation
  2. Usage
  3. Samples
  4. License

Installation

Package
iterable-client-dotnet NuGet
iterable-client-extension-dotnet NuGet

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

Usage

Armut.Iterable.Client can be used with any DI library, or it can be used standalone.

Standalone Initialization

If you do not want to use any DI framework, you have to instantiate IterableStandalone as follows.

IterableStandalone

IIterableFactory iterableFactory = IterableStandalone.Create("your_api_key");
UserClient client = iterableFactory.CreateUserClient();

IIterableFactory contains all necessary clients.

Microsoft.Extensions.DependencyInjection Initialization

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>();

Call Endpoints

The methods that end with Async returns model itself without additional HTTP response information.

var userModel = await userClient.GetByEmailAsync("info@armut.com");

Samples

You can find all of the samples from here

License

Licensed under MIT, see LICENSE for the full text.

About

iterable-client-dotnet is a client library (C# wrapper) 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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •