Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 

README.md

SendyClient.Net

A Sendy client to interact in .Net Core applications with the Sendy API!

BCH compliance NuGet

Sendy

It can be used to perform the following Sendy API actions:

  • Subscribe (including custom fields)
  • Unsubscribe
  • Delete subscriber
  • Subscription status
  • Active subscriber count
  • Create campaign (and send)
  • Create list (new!)

It has been built to interact with version v2.1.2.8.

Available on Nuget

SendyClient.Net is available to download via NuGet!

How to use

var sendyClient = new SendyClient(new Uri("https://mysendy"), "mySendySecret");

var result = await sendyClient.SubscribeAsync("sjaan@banaan.nl", "Sjaan", "myListId");

Subscribe with custom fields 'birthday' and 'logintoken'

var sendyClient = new SendyClient(new Uri("https://mysendy"), "mySendySecret");
var customFields = new Dictionary<string, string> {{"birthday", "12/9/1976"}, {"logintoken", "x4bla9!bg"}};

var result = await sendyClient.SubscribeAsync("sjaan@banaan.nl", "Sjaan", "myListId", customFields);

If you would like to use the campaign API, download it first.

var sendyClient = new SendyClient(new Uri("https://mysendy"), "mySendySecret");

var campaign = new Campaign
{
  BrandId = 1,
  FromEmail = "noreply@fromme.com",
  FromName = "Jeroen",
  HtmlText = "<html><body><b>Hi</b></body></html>",
  PlainText = "Hi",
  Querystring = "querystring=sjaak",
  ReplyTo = "sjaan@banaan.nl",
  Subject = "Sent with SendyClient.Net!",
  Title = "Campaign demo"
};

result = await sendyClient.CreateCampaignAsync(campaign, false, null);

Create list API

The create list is a new API. Copy the Sendy directory to your Sendy installation. This will add a new API call to create a list, including custom fields when necessary.

endpoint: /api/lists/create.php

POST data:

  • api_key
  • brand_id
  • list_name - the name of the new list (mandatory).
  • custom_fields - a comma separated list of new custom field names. Not allowed are email and name (similar to the UI validations)
  • field_types - possible values: Text or Date

Return value The id of the list that is created or an error message if something went wrong.

After this you can simply call:

var sendyClient = new SendyClient(new Uri("https://mysendy"), "mySendySecret");
var list = new MailingList
{
  BrandId = 1,
  Name = "Foo list"
};

list.CustomFields.Add(new CustomField("custom field 1"));
list.CustomFields.Add(new CustomField("custom field 2", CustomField.DataTypes.Date));

var result = await sendyClient.CreateListAsync(list);

API updates

The SendyClient class constructor now includes a new parameter named apiVer where you can pass in the version of Sendy you're working against. If not supplied it won't support version 3 enhancements.

var sendyClient = new SendyClient(new Uri("https://mysendy"), "mySendySecret", new Version(3, 0, 6));

Version 3 changes

  • Subscribe API now includes country, ipaddress, referrer & gdpr parameters.
  • CreateCampaign API now includes segment_ids, exclude_list_ids & exclude_segments_ids parameters.

Questions

Feel free to create an issue, or even better: submit a pull request.

About

A Sendy client, now support for .Net Core!

Resources

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.