public static List<ContactListDetails> GetContactLists(CredentialsDetails credentialsDetail,
out string strRequest, out string strResponse)
{
var contactURI = "https://api.constantcontact.com/ws/customers/" + credentialsDetail.User + "/lists";
var xmlResponse = ApiCallComponent.CallServiceGet(credentialsDetail, contactURI, out strRequest,
out strResponse);
var xdoc = XDocument.Parse(xmlResponse);
if (xdoc.Root == null)
{
return null;
}
var lists = from f in xdoc.Root.Descendants(W3Ns + "entry")
let element = f.Element(W3Ns + "id")
where element != null
let xElement = element
where
xElement != null &&
(!xElement.Value.Contains("do-not-mail") & !xElement.Value.Contains("active") &
!xElement.Value.Contains("removed"))
let xElement1 = f.Element(W3Ns + "content")
where xElement1 != null
let element1 = xElement1.Element(ConstantContactNs + "ContactList")
where element1 != null
let xElement2 = element1.Element(ConstantContactNs + "Name")
where xElement2 != null
select new
{
id = element.Value,
name = xElement2.Value
};
return
lists.Select(
list => new ContactListDetails {Id = "https" + Regex.Split(list.id, "http")[1], Name = list.name}).
ToList();
}