Giter Club home page Giter Club logo

sendyclient.net's Introduction

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("[email protected]", "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("[email protected]", "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 = "[email protected]",
  FromName = "Jeroen",
  HtmlText = "<html><body><b>Hi</b></body></html>",
  PlainText = "Hi",
  Querystring = "querystring=sjaak",
  ReplyTo = "[email protected]",
  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.

sendyclient.net's People

Contributors

kloarubeek avatar mguinness avatar anwarjaved avatar

Stargazers

yo·bu·ko avatar Steven Lee avatar Pascal Tbf avatar  avatar Erik Ammerlaan avatar

Watchers

James Cloos avatar  avatar

Forkers

schwoi mguinness

sendyclient.net's Issues

Updated API support

Thanks for the great library, I've just started using it and it works great so far. One minor quibble is that it would be nice to suffix the method names with Async (or alternatively the class name) as is convention.

One issue I've come across is that the library doesn't support the newer features of the Create Campaign API as it's missing the segment_ids, exclude_list_ids & exclude_segments_ids parameters. Also the Subscribe API is missing country, ipaddress, referrer & gdpr parameters.

I'd be happy to try a PR if that's something you don't have time for, but I wanted to get your input first. I think SendyClient would also need a version number to determine support.

Allow injecting HttpClient for re-use

Hi, thanks for the handy tool, this simplifies sendy implementation quite a bit.

One thing I noticed though was that the SendyClient creates a new HttpClient for each instance. From what I understand, current wisdom is to re-use an HttpClient for the lifetime of your application. You do have a constructor for injecting an HttpClient, but it is marked internal, and can't be used by an external application. Do you think it would be possible to expose this constructor?

Create new (mailing) list

The current Sendy API doesn't support the creation of a new mailing list/ sending list. It would be nice if we can append it to the Sendy API and then add support in this client as well 😎

Nuget Package Installation Error

Hi,

Not sure where to start but

I was trying to install the SendyClient.Net 3.0.0 using nuget package but keep getting the error that "the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."

If any insight of what I should be looking at to get this working would be great.

Also the SendyCampaignsAPI.zip link is dead was wondering if you have a copy would be great.

Thanks in adavnce

Regards,
Karembeu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.