.NET SDK Usage

Once the SDK is installed you can start working with the ConvergeApiClient by either adding to your dependency injection container or by instantiating the ConvergeApiClient stand-alone.

It is recommended to add the ConvergeApiClient to your service collection as ConvergeApiClient is thread safe and can be re-used as a singleton instance in your application.

Using Microsoft.Extensions.DependencyInjection

The below method will register and allow the Converge SDK to log operations with the Microsoft.Extensions.Logging library.

Program.cs
using Seeka.Converge.Dotnet;
using Seeka.Converge.Dotnet.Authentication;
using Seeka.Converge.Dotnet.Services;
using Microsoft.Extensions.DependencyInjection;

...

public void ConfigureServices(IServiceCollection services)
{
    ...

    services.AddSeekaConvergeClient(new ConvergeApiConfig()
    {
        Authentication = new ConvergeKeyAuthenticationHandler("(Organisation ID)", "(public key)")
    });
}

You can then inject ConvergeApiConfig into your application services.

using Seeka.Converge.Dotnet;
using Seeka.Converge.Dotnet.Authentication;

public class SeekaApiHandler {
    public SeekaApiHandler(ConvergeApiConfig converge){
        _converge = converge;
    }

    private readonly ConvergeApiConfig _converge;

    public async Task SendLeadEventAsync(){
        var identity = await _converge.Identity.SetProfileAsync(new PersonIdentificationResolutionRequest()
        {
            Id = new PersonIdentifiers()
            {
                FirstName = new List<string>()
                {
                    "John"
                },
                LastName = new List<string>()
                {
                    "Smith"
                },
                Email = new List<string>()
                {
                    "john.smith@testing.com"
                }
            }
        });

        await _converge.Track.LeadAsync(new LeadActivityTrackingEventMetadata()
        {
            SourceContentName = "Enquiry form",
            PredictedValue = 30000,
            CurrencyCode = "USD"
        }, new ActivityCommonProps()
        {
            PersonId = identity.PersonId
        });
    }
}

Standalone ConvergeApiClient

using Seeka.Converge.Dotnet;
using Seeka.Converge.Dotnet.Authentication;

using var converge = new ConvergeApiClient(
    new ConvergeApiConfig()
    {
        Authentication = new ConvergeKeyAuthenticationHandler("(Organisation ID)", "(public key)")
    }
);

var identity = await converge.Identity.SetProfileAsync(new PersonIdentificationResolutionRequest()
{
    Id = new PersonIdentifiers()
    {
        FirstName = new List<string>()
        {
            "John"
        },
        LastName = new List<string>()
        {
            "Smith"
        },
        Email = new List<string>()
        {
            "john.smith@testing.com"
        }
    }
});

await converge.Track.LeadAsync(new LeadActivityTrackingEventMetadata()
{
    SourceContentName = "Enquiry form",
    PredictedValue = 30000,
    CurrencyCode = "USD"
}, new ActivityCommonProps()
{
    PersonId = identity.PersonId
});