Coder Social home page Coder Social logo

sailthru-net-client's Introduction

sailthru-net-client

For installation instructions, documentation, and examples please visit: https://getstarted.sailthru.com/developers/api-client/net/

A simple client library to remotely access the Sailthru REST API as per http://getstarted.sailthru.com/developers/api

As of commit b8714e2, UserRequest.OptoutEmail is now an enum rather than a string. Replace "all" with "OptoutStatus.All", "blast" with "OptoutStatus.Blast", "basic" with "OptoutStatus.Basic", and "none" with "OptoutStatus.None". For example, "userRequest.OptoutEmail = "all";" should now be "userRequest.OptoutEmail = OptoutStatus.All;"

API Rate Limiting

Here is an example how to check rate limiting and throttle API calls based on that. For more information about Rate Limiting, see Sailthru Documentation

SailthruClient sailthruClient = new SailthruClient(apiKey, apiSec);

// ... make some api calls ....

Hashtable lastRateLimitInfo = sailthruClient.getLastRateLimitInfo("user", "post");

// getLastRateLimitInfo returns null if given endpoint/method wasn't triggered previously
if (lastRateLimitInfo != null) {
	int limit = lastRateLimitInfo['limit'];
	int remaining = lastRateLimitInfo['remaining'];
	DateTime reset = (DateTime)lastRateLimitInfo['reset'];

    // throttle api calls based on last rate limit info
    if (remaining <= 0) {
        TimeSpan time_span_till_reset = reset.Subtract(DateTime.now());
        // sleep or perform other business logic before next user api call
        Thread.Sleep(time_span_till_reset);
    }
}

sailthru-net-client's People

Contributors

eklinkhammer avatar infynyxx avatar jack-lewis-87 avatar jethrocarr avatar joepikowski avatar kschoonovergs avatar marissa-englander avatar mydagobah avatar napernik avatar robertschultz avatar sinneduy avatar zencephalon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sailthru-net-client's Issues

API Response Improvements

I noticed to accessing data returned from your library we have to use a hash table from the SailthruResponse. It would make more sense if your library simply return a Model with all the data. I have to take an extra step of Deserializing the JSON.

Email Open Webhook

Please support an Email Open Webhook. Scheduling blast jobs to look back in time and get Email Opens is time consuming and wasteful.

Exception on PostEvent call

Error message "Cannot access a disposed object. Object name: 'System.Net.HttpWebResponse'."

This error occurs on file Sailthru/Sailthru/SailthruResponse.cs.
Function parseJSON(), object webResponse use on line 103 but the object disposed on line 82.

Best regards.

Design flaw in SailthruClient GetStat method definition

https://github.com/sailthru/sailthru-net-client/blob/master/Sailthru/Sailthru/SailthruClient.cs#L528

This GetStat method is overloaded:

public SailthruResponse GetStat(String stat, String list = null, String date = null, Hashtable htOptions = null)

public SailthruResponse GetStat(String stat, String template = null, String startDate = null, String endDate = null, Hashtable htOptions = null)

Every parameter after the first one is optional, but they're actually required if you want to call the method successfully. If you try calling GetStat("list") it's flagged as ambiguous because it doesn't know which to call. If you only want the first parameter to be specified, you instead have to call GetStat("list", null, null, new HashTable()).

Support .NET Core

Please support .NET Core, Microsoft is deprecating .NET Framework.

SailThruClient.ReceiveVerifyPost() method does not match the PHP version of this method

The PHP version of this method removes the signature parameter ("sig") from the parameters before attempting to extract the parameter values and perform the md5 hash on the secret key plus the parameter values:

md5(secretkey + all parameter values except the signature)

The C# version of this method does not do this, so it will include the signature as PART of the parameter values when doing the md5 hash:

md5(secretkey + all parameter values including the signature)

UserRequest Login property

Shouldn't the UserRequest Login property be a Hashtable vs string to support "site", "app", "ip" and "user_agent" values?

Change:
[JsonProperty(PropertyName = "login")]
public string Login { private get; set; }
To:
[JsonProperty(PropertyName = "login")]
public Hashtable Login { private get; set; }

Error with ApiGet - Signature hash does not match

I created an integration several months ago and have been semi-regularly maintaining it, however when doing work on it yesterday I noticed that my calls using ApiGet were failing with error code 5 and giving the message "Signature hash does not match".

As far as I understood the signature was handled by the client using the combination of api key and secret. I have double checked these have not changed for my account, but still am seeing this error. Note: This was all working in the past.

An example of a call that is failing with this error is the following:

SailthruClient client = new SailthruClient( apiKey, secretKey );
SailthruResponse response = client.ApiGet( "template", new Hashtable() );

If you could advise me on a fix, I would greatly appreciate it. Thanks.

Improve .NET documentation

Update your .NET documentation. Other languages you support have much more in depth documentation. and examples.

list_erase job requires array but ProcessJob turns that to string

Using the .NET client, the ProcessJob method requires a hashtable of parameters. I have added the lists to delete as an array to the parameters. It looks like within the ProcessJob method it converts the hashtable value to string (ignoring that this value is an array) so that it can url encode it. In doing this we lose the array typing and receive the error ‘The lists parameter must be passed as an array’.

The syntax I have tried using is:

Hashtable jobParams = new Hashtable();
jobParams.Add( "lists", JsonConvert.SerializeObject( listsToDelete.ToArray() ) );
SailthruResponse response = client.ProcessJob( "list_erase", null, null, jobParams );

And

Hashtable jobParams = new Hashtable();
jobParams.Add( "lists", listsToDelete.ToArray() );
SailthruResponse response = client.ProcessJob( "list_erase", null, null, jobParams );

Interaction with api/list endpoint

It seems that the client does not support list manipulation currently. It would be helpful if there was ListRequest class and applicable function in the client.

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.