Yonoma .NET SDK provides a simple way to interact with the Yonoma API for managing lists, tags, contacts, and email sending.
dotnet add package Yonoma --version 1.1.2To use the Yonoma API, initialize the client with your API key:
var Yonoma = new Yonoma("YOUR-API-KEY");var response = await Yonoma.Lists.Create('list_name':'New group');
Console.WriteLine(response);var response = await Yonoma.Lists.Lists();
Console.WriteLine(response);var response = await Yonoma.Lists.Retrieve("list_id");
Console.WriteLine(response);var response = await Yonoma.Lists.Update("list_id", {
'list_name': 'Upadated list name'
});
Console.WriteLine(response);var response = await Yonoma.Lists.Delete("list_id");
Console.WriteLine(response);var response = await Yonoma.Tags.Create({'tag_name': 'New tag'});
Console.WriteLine(response);var response = await Yonoma.Tags.List();
Console.WriteLine(response);var response = await Yonoma.Tags.Retrieve("tag_id");
Console.WriteLine(response);var response = await Yonoma.Tags.Update("tag_id", {
'tag_name': 'Updated Tag Name'
});
Console.WriteLine(response);var response = await Yonoma.Tags.Delete("tag_id");
Console.WriteLine(response);var response = await Yonoma.Contacts.Create("list_id", {
email: "email@example.com",
status: "Subscribed" | "Unsubscribed",
data: {
firstName: string,
lastName: string,
phone: string,
gender: string,
address: string,
city: string,
state: string,
country: string,
zipcode: string,
}
});
Console.WriteLine(response);var response = await Yonoma.Contacts.Update("list_id", "contact_id", {
'status': "Subscribed" | "Unsubscribed"
});
Console.WriteLine(response);var response = await Yonoma.Contacts.AddTag("contact_id", {
'tag_id': 'Tag id'
});
Console.WriteLine(response);var response = await Yonoma.Contacts.RemoveTag("contact_id", {
'tag_id': 'Tag id'
});
Console.WriteLine(response);var response = await Yonoma.Email.SendEmail({
'from_email': 'updates@yonoma.io',
'to_email': 'email@yourdomain.com',
'subject':"Welcome to Yonoma - You're In!",
'mail_template': "We're excited to welcome you to Yonoma! Your successful signup marks the beginning of what we hope will be an exceptional journey."
});
Console.WriteLine(response);Each API call returns a response object that contains success or error messages. Handle errors using:
try
{
var response = Yonoma.Lists.Create("Existing List");
Console.WriteLine(response);
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}This project is licensed under the MIT License. See LICENSE for details.