Last active
August 29, 2015 14:24
-
-
Save Corstiaan84/96336c8be29cdbde7c8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
using System.Text; | |
using System.Threading.Tasks; | |
using RestSharp; | |
namespace Fluxmatix.Authentication | |
{ | |
public class EmailOctopusUserEmailDataExporter : IUserEmailDataExporter | |
{ | |
public static string ApiKey { get; set; } | |
public void Export(IUser user, object listIdentifier) | |
{ | |
var listId = (string)listIdentifier; | |
var rest = new RestClient("https://emailoctopus.com/api/1/"); | |
var req = new RestRequest(string.Format("lists/{0}/members", listId)); | |
var data = new EmailOctopusRequestData() { | |
api_key = ApiKey, | |
email_address = user.Email, | |
first_name = user.Username, | |
last_name = "", | |
subscribed = true | |
}; | |
req.AddBody(data); | |
req.Method = Method.POST; | |
var response = rest.Execute<EmailOctopusReponseData>(req); | |
} | |
} | |
public class EmailOctopusRequestData | |
{ | |
public string api_key { get; set; } | |
public string email_address { get; set; } | |
public string first_name { get; set; } | |
public string last_name { get; set; } | |
public bool subscribed { get; set; } | |
} | |
public class EmailOctopusReponseData | |
{ | |
public Member member { get; set; } | |
} | |
public class Member | |
{ | |
public string id { get; set; } | |
public string email_address { get; set; } | |
public string first_name { get; set; } | |
public string last_name { get; set; } | |
public bool subscribed { get; set; } | |
public DateTime created_at { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment