Untitled diff
599 lines
using System;
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics;
using System.Reflection;
using System.Reflection;
using Google.Voice.Entities;
using Google.Voice.Entities;
using Google.Voice.Extensions;
using Google.Voice.Extensions;
using Google.Voice.Web;
using Google.Voice.Web;
using Google.Voice.Exceptions;
using Google.Voice.Exceptions;
namespace Google.Voice
namespace Google.Voice
{
{
public class GoogleVoice
public class GoogleVoice
{
{
/// <summary>
/// <summary>
/// WebClient object used when making requests to Google Voice
/// WebClient object used when making requests to Google Voice
/// </summary>
/// </summary>
public virtual WebClient WebClient { get; protected set; }
public virtual WebClient WebClient { get; protected set; }
/// <summary>
/// <summary>
/// GALX data provided by Google
/// GALX data provided by Google
/// </summary>
/// </summary>
public string GALX { get; protected set; }
public string GALX { get; protected set; }
/// <summary>
/// <summary>
/// Session ID data provided by Google
/// Session ID data provided by Google
/// </summary>
/// </summary>
public string Session { get; protected set; }
public string Session { get; protected set; }
public AccountData Account { get; protected set; }
public AccountData Account { get; protected set; }
/// <summary>
/// <summary>
/// Login parameters used for login requests
/// Login parameters used for login requests
/// </summary>
/// </summary>
protected VariableCollection LoginParameters { get; set; }
protected VariableCollection LoginParameters { get; set; }
/// <summary>
/// <summary>
/// Creates a new instance of the GoogleVoice service
/// Creates a new instance of the GoogleVoice service
/// </summary>
/// </summary>
public GoogleVoice()
public GoogleVoice()
{
{
WebClient = new WebClient();
WebClient = new WebClient();
}
}
/// <summary>
/// <summary>
/// Generates a URL that corresponds to the correct web service endpoint
/// Generates a URL that corresponds to the correct web service endpoint
/// on Google Voice; this method returns a URL based on the calling method or the supplied
/// on Google Voice; this method returns a URL based on the calling method or the supplied
/// parameter
/// parameter
/// </summary>
/// </summary>
protected static string GenerateUrl(string method = null)
protected static string GenerateUrl(string method = null)
{
{
method = method ?? (new StackTrace(1).GetFrame(0).GetMethod().Name);
method = method ?? (new StackTrace(1).GetFrame(0).GetMethod().Name);
switch (method.ToLower())
switch (method.ToLower())
{
{
case "login":
case "login":
return "https://accounts.google.com/ServiceLoginAuth";
return "https://accounts.google.com/ServiceLoginAuth";
case "executelogin":
case "executelogin":
return "https://accounts.google.com/signin/challenge/sl/password?service=grandcentral&continue=https://www.google.com/voice";
return "https://accounts.google.com/signin/challenge/sl/password?service=grandcentral&continue=https://www.google.com/voice";
//return "https://accounts.google.com/ServiceLogin?service=grandcentral&continue=https://www.google.com/voice";
//return "https://accounts.google.com/ServiceLogin?service=grandcentral&continue=https://www.google.com/voice";
case "inbox":
case "inbox":
return "https://www.google.com/voice/b/0/inbox/recent/";
return "https://www.google.com/voice/b/0/inbox/recent/";
case "starred":
case "starred":
return "https://www.google.com/voice/b/0/inbox/recent/starred/";
return "https://www.google.com/voice/b/0/inbox/recent/starred/";
case "spam":
case "spam":
return "https://www.google.com/voice/b/0/inbox/recent/spam/";
return "https://www.google.com/voice/b/0/inbox/recent/spam/";
case "trash":
case "trash":
return "https://www.google.com/voice/b/0/inbox/recent/trash/";
return "https://www.google.com/voice/b/0/inbox/recent/trash/";
case "history":
case "history":
return "https://www.google.com/voice/b/0/inbox/recent/all/";
return "https://www.google.com/voice/b/0/inbox/recent/all/";
case "voicemail":
case "voicemail":
return "https://www.google.com/voice/b/0/inbox/recent/voicemail/";
return "https://www.google.com/voice/b/0/inbox/recent/voicemail/";
case "texts":
case "texts":
return "https://www.google.com/voice/b/0/inbox/recent/sms/";
return "https://www.google.com/voice/b/0/inbox/recent/sms/";
case "recorded":
case "recorded":
return "https://www.google.com/voice/b/0/inbox/recent/recorded/";
return "https://www.google.com/voice/b/0/inbox/recent/recorded/";
case "placed":
case "placed":
return "https://www.google.com/voice/b/0/inbox/recent/placed/";
return "https://www.google.com/voice/b/0/inbox/recent/placed/";
case "missed":
case "missed":
return "https://www.google.com/voice/b/0/inbox/recent/missed/";
return "https://www.google.com/voice/b/0/inbox/recent/missed/";
case "received":
case "received":
return "https://www.google.com/voice/b/0/inbox/recent/received/";
return "https://www.google.com/voice/b/0/inbox/recent/received/";
case "sms":
case "sms":
return "https://www.google.com/voice/b/0/sms/send/";
return "https://www.google.com/voice/b/0/sms/send/";
case "call":
case "call":
return "https://www.google.com/voice/b/0/call/connect/";
return "https://www.google.com/voice/b/0/call/connect/";
case "search":
case "search":
return "https://www.google.com/voice/b/0/inbox/search/";
return "https://www.google.com/voice/b/0/inbox/search/";
case "mark":
return "https://www.google.com/voice/b/0/inbox/mark/";
case "delete":
return "https://www.google.com/voice/b/0/inbox/deleteMessages/";
default: return "http://www.google.com/voice/b/0/";
default: return "http://www.google.com/voice/b/0/";
}
}
}
}
/// <summary>
/// <summary>
/// Checks the IGVRequestResult
/// Checks the IGVRequestResult
/// </summary>
/// </summary>
protected virtual IGVRequestResult CheckRelogin(IGVRequestResult rr, Result result)
protected virtual IGVRequestResult CheckRelogin(IGVRequestResult rr, Result result)
{
{
rr.RequiresRelogin = result.Content.Contains("The username or password you entered is incorrect.");
rr.RequiresRelogin = result.Content.Contains("The username or password you entered is incorrect.");
return rr;
return rr;
}
}
public bool Logout()
public bool Logout()
{
{
Session = "";
Session = "";
return true;
return true;
}
}
/// <summary>
/// <summary>
/// Performs a login to Google Voice
/// Performs a login to Google Voice
/// </summary>
/// </summary>
public virtual LoginResult Login(string emailAddress, string password)
public virtual LoginResult Login(string emailAddress, string password)
{
{
try
try
{
{
var result = WebClient.Get(GenerateUrl());
var result = WebClient.Get(GenerateUrl());
GALX = result.GetInputValueByRegEx("GALX");
GALX = result.GetInputValueByRegEx("GALX");
VariableCollection parameters = new VariableCollection();
VariableCollection parameters = new VariableCollection();
parameters["continue"].Value = result.GetInputValueByRegEx("continue");
parameters["continue"].Value = result.GetInputValueByRegEx("continue");
parameters["followup"].Value = result.GetInputValueByRegEx("followup");
parameters["followup"].Value = result.GetInputValueByRegEx("followup");
parameters["dsh"].Value = result.GetInputValueByRegEx("dsh");
parameters["dsh"].Value = result.GetInputValueByRegEx("dsh");
parameters["ltmpl"].Value = result.GetInputValueByRegEx("ltmpl");
parameters["ltmpl"].Value = result.GetInputValueByRegEx("ltmpl");
parameters["timeStmp"].Value = result.GetInputValueByRegEx("timeStmp");
parameters["timeStmp"].Value = result.GetInputValueByRegEx("timeStmp");
parameters["secTok"].Value = result.GetInputValueByRegEx("secTok");
parameters["secTok"].Value = result.GetInputValueByRegEx("secTok");
parameters["rmShown"].Value = result.GetInputValueByRegEx("rmShown");
parameters["rmShown"].Value = result.GetInputValueByRegEx("rmShown");
parameters["signIn"].Value = result.GetInputValueByRegEx("signIn");
parameters["signIn"].Value = result.GetInputValueByRegEx("signIn");
parameters["asts"].Value = result.GetInputValueByRegEx("asts");
parameters["asts"].Value = result.GetInputValueByRegEx("asts");
parameters["PersistentCookie"].Value = "yes";
parameters["PersistentCookie"].Value = "yes";
parameters["GALX"].Value = GALX;
parameters["GALX"].Value = GALX;
parameters["pstMsg"].Value = 1;
parameters["pstMsg"].Value = 1;
parameters["service"].Value = "grandcentral";
parameters["service"].Value = "grandcentral";
return ExecuteLogin(emailAddress, password, parameters);
return ExecuteLogin(emailAddress, password, parameters);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
LoginResult failed = new LoginResult();
LoginResult failed = new LoginResult();
failed.RequiresRelogin = true;
failed.RequiresRelogin = true;
failed.Exception = ex.Message;
failed.Exception = ex.Message;
return failed;
return failed;
///throw new LoginException(ex);
///throw new LoginException(ex);
}
}
}
}
/// <summary>
/// <summary>
/// Executes the secondary process of POSTing login credentials
/// Executes the secondary process of POSTing login credentials
/// </summary>
/// </summary>
/// <param name="emailAddress"></param>
/// <param name="emailAddress"></param>
/// <param name="password"></param>
/// <param name="password"></param>
/// <param name="parameters"></param>
/// <param name="parameters"></param>
/// <returns></returns>
/// <returns></returns>
protected virtual LoginResult ExecuteLogin(string emailAddress, string password, VariableCollection parameters)
protected virtual LoginResult ExecuteLogin(string emailAddress, string password, VariableCollection parameters)
{
{
try
try
{
{
parameters["Email"].Value = emailAddress;
parameters["Email"].Value = emailAddress;
parameters["Passwd"].Value = password;
parameters["Passwd"].Value = password;
Result result = WebClient.Post(GenerateUrl(), parameters);
Result result = WebClient.Post(GenerateUrl(), parameters);
Session = result.GetInputValueByRegExLiberal("_rnr_se");
Session = result.GetInputValueByRegExLiberal("_rnr_se");
string genericInformationPart1 = result.GetBlock("_gcData =", "'contacts'");
string genericInformationPart1 = result.GetBlock("_gcData =", "'contacts'");
string genericInformationPart2 = "'rank':" + result.GetBlock("'rank':", "};") + "}";
string genericInformationPart2 = "'rank':" + result.GetBlock("'rank':", "};") + "}";
Account = (genericInformationPart1 + genericInformationPart2).ToObject<AccountData>();
Account = (genericInformationPart1 + genericInformationPart2).ToObject<AccountData>();
Account.contacts = new Dictionary<string, Contact>();
Account.contacts = new Dictionary<string, Contact>();
var contactDetails = result.GetBlocks("{\"contactId\":", true, "{\"contactId\":", "'rank':");
var contactDetails = result.GetBlocks("{\"contactId\":", true, "{\"contactId\":", "'rank':");
if (contactDetails != null)
if (contactDetails != null)
{
{
foreach (var contactDetail in contactDetails)
foreach (var contactDetail in contactDetails)
{
{
string json = contactDetail.Substring(0, contactDetail.LastIndexOf('}') + 1);
string json = contactDetail.Substring(0, contactDetail.LastIndexOf('}') + 1);
Contact contact = json.ToObject<Contact>();
Contact contact = json.ToObject<Contact>();
if (!Account.contacts.ContainsKey(contact.contactId) || Account.contacts[contact.contactId].phoneNumber == null)
if (!Account.contacts.ContainsKey(contact.contactId) || Account.contacts[contact.contactId].phoneNumber == null)
{
{
Account.contacts[contact.contactId] = contact;
Account.contacts[contact.contactId] = contact;
}
}
}
}
}
}
LoginResult returnValue = new LoginResult();
LoginResult returnValue = new LoginResult();
CheckRelogin(returnValue, result);
CheckRelogin(returnValue, result);
if (!returnValue.RequiresRelogin)
if (!returnValue.RequiresRelogin)
{
{
LoginParameters = parameters;
LoginParameters = parameters;
}
}
return returnValue;
return returnValue;
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new LoginException(ex);
throw new LoginException(ex);
}
}
}
}
/// <summary>
/// <summary>
/// Re-logins to the Google Voice service
/// Re-logins to the Google Voice service
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
protected virtual LoginResult ExecuteRelogin()
protected virtual LoginResult ExecuteRelogin()
{
{
try
try
{
{
string emailAddress = LoginParameters["Email"].ToString();
string emailAddress = LoginParameters["Email"].ToString();
string password = LoginParameters["Passwd"].ToString();
string password = LoginParameters["Passwd"].ToString();
return Login(emailAddress, password);
return Login(emailAddress, password);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new LoginException(ex);
throw new LoginException(ex);
}
}
}
}
/// <summary>
/// <summary>
/// Re-logins to the Google Voice service and executes a request
/// Re-logins to the Google Voice service and executes a request
/// </summary>
/// </summary>
/// <typeparam name="T">Type of object to return</typeparam>
/// <typeparam name="T">Type of object to return</typeparam>
/// <param name="result">The object to return</param>
/// <param name="result">The object to return</param>
/// <param name="method">Method to execute that returns the object</param>
/// <param name="method">Method to execute that returns the object</param>
/// <param name="parameters">Parameters to provide to the object</param>
/// <param name="parameters">Parameters to provide to the object</param>
protected virtual bool ReloginAnd<T>(out T result, MethodBase method = null, params object[] parameters)
protected virtual bool ReloginAnd<T>(out T result, MethodBase method = null, params object[] parameters)
{
{
method = method ?? new StackTrace(1).GetFrame(0).GetMethod();
method = method ?? new StackTrace(1).GetFrame(0).GetMethod();
result = default(T);
result = default(T);
if (ExecuteRelogin().RequiresRelogin)
if (ExecuteRelogin().RequiresRelogin)
{
{
throw new LoginException();
throw new LoginException();
}
}
else
else
{
{
result = (T)method.Invoke(this, parameters);
result = (T)method.Invoke(this, parameters);
return true;
return true;
}
}
}
}
/// <summary>
/// <summary>
/// Re-logins to the Google Voice service and executes a request
/// Re-logins to the Google Voice service and executes a request
/// </summary>
/// </summary>
/// <typeparam name="T">Type of object to return</typeparam>
/// <typeparam name="T">Type of object to return</typeparam>
/// <param name="result">The object to return</param>
/// <param name="result">The object to return</param>
/// <param name="parameters">Parameters to provide to the object</param>
/// <param name="parameters">Parameters to provide to the object</param>
protected virtual bool ReloginAnd<T>(out T result, params object[] parameters)
protected virtual bool ReloginAnd<T>(out T result, params object[] parameters)
{
{
return ReloginAnd<T>(out result, new StackTrace(1).GetFrame(0).GetMethod(), parameters);
return ReloginAnd<T>(out result, new StackTrace(1).GetFrame(0).GetMethod(), parameters);
}
}
/// <summary>
/// <summary>
/// Generates generic parameters based on supplied parameter data
/// Generates generic parameters based on supplied parameter data
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
private static VariableCollection GenerateParameters(uint? pageNumber = null)
private static VariableCollection GenerateParameters(uint? pageNumber = null)
{
{
VariableCollection parameters = new VariableCollection();
VariableCollection parameters = new VariableCollection();
if (pageNumber.HasValue)
if (pageNumber.HasValue)
{
{
parameters["page"].Value = "p" + pageNumber;
parameters["page"].Value = "p" + pageNumber;
}
}
return parameters;
return parameters;
}
}
/// <summary>
/// <summary>
/// Sends a SMS message to the destination phone number with the specified message
/// Sends a SMS message to the destination phone number with the specified message
/// </summary>
/// </summary>
public bool SMS(string destinationPhoneNumber, string message)
public bool SMS(string destinationPhoneNumber, string message)
{
{
try
try
{
{
VariableCollection parameters = GenerateParameters();
VariableCollection parameters = GenerateParameters();
parameters["phoneNumber"].Value = destinationPhoneNumber;
parameters["phoneNumber"].Value = destinationPhoneNumber;
parameters["text"].Value = message;
parameters["text"].Value = message;
parameters["sendErrorSms"].Value = 0;
parameters["sendErrorSms"].Value = 0;
parameters["_rnr_se"].Value = Session;
parameters["_rnr_se"].Value = Session;
var result = WebClient.Post(GenerateUrl(), parameters);
var result = WebClient.Post(GenerateUrl(), parameters);
GetFolderResult returnValue = new GetFolderResult();
GetFolderResult returnValue = new GetFolderResult();
var dictionary = result.Content.ToObject<Dictionary<string, object>>();
var dictionary = result.Content.ToObject<Dictionary<string, object>>();
return Convert.ToBoolean(dictionary["ok"]);
return Convert.ToBoolean(dictionary["ok"]);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new SmsException(ex);
throw new SmsException(ex);
}
}
}
}
/// <summary>
/// <summary>
/// Initiates a call to the destination phone number from the local phone
/// Initiates a call to the destination phone number from the local phone
/// </summary>
/// </summary>
public bool Call(string localPhone, string destinationPhoneNumber)
public bool Call(string localPhone, string destinationPhoneNumber)
{
{
try
try
{
{
VariableCollection parameters = GenerateParameters();
VariableCollection parameters = GenerateParameters();
parameters["outgoingNumber"].Value = destinationPhoneNumber;
parameters["outgoingNumber"].Value = destinationPhoneNumber;
parameters["forwardingNumber"].Value = localPhone;
parameters["forwardingNumber"].Value = localPhone;
parameters["subscriberNumber"].Value = "undefined";
parameters["subscriberNumber"].Value = "undefined";
parameters["phoneType"].Value = 2;
parameters["phoneType"].Value = 2;
parameters["remember"].Value = 0;
parameters["remember"].Value = 0;
parameters["_rnr_se"].Value = Session;
parameters["_rnr_se"].Value = Session;
var result = WebClient.Post(GenerateUrl(), parameters);
var result = WebClient.Post(GenerateUrl(), parameters);
GetFolderResult returnValue = new GetFolderResult();
GetFolderResult returnValue = new GetFolderResult();
var dictionary = result.Content.ToObject<Dictionary<string, object>>();
var dictionary = result.Content.ToObject<Dictionary<string, object>>();
return Convert.ToBoolean(dictionary["ok"]);
return Convert.ToBoolean(dictionary["ok"]);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new CallException(ex);
throw new CallException(ex);
}
}
}
}
/// <summary>
/// Mark the message based on parameters provided
/// </summary>
/// <param name="messageId"></param>
/// <param name="flagType"></param>
/// <param name="isMarked"></param>
/// <returns></returns>
protected bool Mark(string messageId, bool isMarked = true)
{
int i = isMarked ? 1 : 0;
string flagType = (new StackTrace(1).GetFrame(0).GetMethod().Name);
switch (flagType.ToLower())
{
case "isspam":
flagType = "spam";
break;
case "isread":
flagType = "read";
break;
default:
flagType = "read";
break;
}
try
{
VariableCollection parameters = GenerateParameters();
parameters["messages"].Value = messageId;
parameters[flagType].Value = i;
parameters["_rnr_se"].Value = Session;
var result = WebClient.Post(GenerateUrl(), parameters);
var dictionary = result.Content.ToObject<Dictionary<string, object>>();
return Convert.ToBoolean(dictionary["ok"]);
}
catch (Exception ex)
{
throw new CallException(ex);
}
}
/// <summary>
/// Flag the message as spam, based on the parameters provided
/// </summary>
/// <param name="messageId"></param>
/// <param name="isMarked"></param>
/// <returns></returns>
public bool IsSpam(string messageId, bool isMarked)
{
return Mark(messageId, isMarked);
}
/// <summary>
/// Flag the message as read, based on the parameters provided
/// </summary>
/// <param name="messageId"></param>
/// <param name="isMarked"></param>
/// <returns></returns>
public bool IsRead(string messageId, bool isMarked)
{
return Mark(messageId, isMarked);
}
/// <summary>
/// Delete/retrieve the message based on the parameters provided
/// </summary>
/// <param name="messageId"></param>
/// <param name="isMarked"></param>
/// <returns></returns>
protected bool Delete(string messageId, bool isMarked = true)
{
int i = isMarked ? 1 : 0;
try
{
VariableCollection parameters = GenerateParameters();
parameters["messages"].Value = messageId;
parameters["trash"].Value = i;
parameters["_rnr_se"].Value = Session;
var result = WebClient.Post(GenerateUrl(), parameters);
var dictionary = result.Content.ToObject<Dictionary<string, object>>();
return Convert.ToBoolean(dictionary["ok"]);
}
catch (Exception ex)
{
throw new CallException(ex);
}
}
/// <summary>
/// Flag the message as trash based on the parameters provided
/// </summary>
/// <param name="messageId"></param>
/// <param name="isMarked"></param>
/// <returns></returns>
public bool IsTrash(string messageId, bool isMarked)
{
return Delete(messageId, isMarked);
}
/// <summary>
/// <summary>
/// Retrieves a collection of contacts
/// Retrieves a collection of contacts
/// </summary>
/// </summary>
/// <param name="reload">Reload all contacts from the server</param>
/// <param name="reload">Reload all contacts from the server</param>
public Dictionary<string, Contact> GetContacts(bool reload = false)
public Dictionary<string, Contact> GetContacts(bool reload = false)
{
{
if (reload)
if (reload)
{
{
if (ExecuteRelogin().RequiresRelogin)
if (ExecuteRelogin().RequiresRelogin)
{
{
throw new LoginException();
throw new LoginException();
}
}
}
}
return Account.contacts;
return Account.contacts;
}
}
/// <summary>
/// <summary>
/// Performs a search for the specified term
/// Performs a search for the specified term
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
public GetFolderResult Search(string term, uint? pageNumber = null)
public GetFolderResult Search(string term, uint? pageNumber = null)
{
{
try
try
{
{
VariableCollection parameters = GenerateParameters(pageNumber);
VariableCollection parameters = GenerateParameters(pageNumber);
parameters["q"].Value = term;
parameters["q"].Value = term;
var result = WebClient.Get(GenerateUrl(), parameters);
var result = WebClient.Get(GenerateUrl(), parameters);
GetFolderResult returnValue = new GetFolderResult();
GetFolderResult returnValue = new GetFolderResult();
string json = result.GetJsonFromXml();
string json = result.GetJsonFromXml();
returnValue = json.ToObject<GetFolderResult>();
returnValue = json.ToObject<GetFolderResult>();
return returnValue;
return returnValue;
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new SearchException(ex);
throw new SearchException(ex);
}
}
}
}
/// <summary>
/// <summary>
/// Retrieves the Inbox folder
/// Retrieves the Inbox folder
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="urlOverride">URL override, if retrieving from a different location</param>
/// <param name="urlOverride">URL override, if retrieving from a different location</param>
public GetFolderResult Inbox(uint? pageNumber = null, string urlOverride = null, bool unread = false)
public GetFolderResult Inbox(uint? pageNumber = null, string urlOverride = null, bool unread = false)
{
{
string url = (urlOverride ?? GenerateUrl()) + (unread ? "unread/" : "");
string url = (urlOverride ?? GenerateUrl()) + (unread ? "unread/" : "");
VariableCollection parameters = GenerateParameters(pageNumber);
VariableCollection parameters = GenerateParameters(pageNumber);
try
try
{
{
var result = WebClient.Get(url, parameters);
var result = WebClient.Get(url, parameters);
GetFolderResult returnValue = new GetFolderResult();
GetFolderResult returnValue = new GetFolderResult();
string json = result.GetJsonFromXml();
string json = result.GetJsonFromXml();
try
try
{
{
returnValue = json.ToObject<GetFolderResult>();
returnValue = json.ToObject<GetFolderResult>();
}
}
catch (Exception ex)
catch (Exception ex)
{
{
object[] methodParameters = { pageNumber, urlOverride };
object[] methodParameters = { pageNumber, urlOverride };
if (!ReloginAnd<GetFolderResult>(out returnValue, pageNumber, urlOverride))
if (!ReloginAnd<GetFolderResult>(out returnValue, pageNumber, urlOverride))
{
{
throw new FolderException(url, ex);
throw new FolderException(url, ex);
}
}
}
}
return returnValue;
return returnValue;
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new FolderException(url, ex);
throw new FolderException(url, ex);
}
}
}
}
/// <summary>
/// <summary>
/// Retrieves the Starred folder
/// Retrieves the Starred folder
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
public GetFolderResult Starred(uint? pageNumber = null, bool unread = false)
public GetFolderResult Starred(uint? pageNumber = null, bool unread = false)
{
{
try
try
{
{
return Inbox(pageNumber, GenerateUrl(), unread);
return Inbox(pageNumber, GenerateUrl(), unread);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
}
}
}
}
/// <summary>
/// <summary>
/// Retrieves the Starred folder
/// Retrieves the Starred folder
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
public GetFolderResult Spam(uint? pageNumber = null, bool unread = false)
public GetFolderResult Spam(uint? pageNumber = null, bool unread = false)
{
{
try
try
{
{
return Inbox(pageNumber, GenerateUrl(), unread);
return Inbox(pageNumber, GenerateUrl(), unread);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
}
}
}
}
/// <summary>
/// <summary>
/// Retrieves the Trash folder
/// Retrieves the Trash folder
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
public GetFolderResult Trash(uint? pageNumber = null, bool unread = false)
public GetFolderResult Trash(uint? pageNumber = null, bool unread = false)
{
{
try
try
{
{
return Inbox(pageNumber, GenerateUrl(), unread);
return Inbox(pageNumber, GenerateUrl(), unread);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
}
}
}
}
/// <summary>
/// <summary>
/// Retrieves the History folder
/// Retrieves the History folder
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
public GetFolderResult History(uint? pageNumber = null, bool unread = false)
public GetFolderResult History(uint? pageNumber = null, bool unread = false)
{
{
try
try
{
{
return Inbox(pageNumber, GenerateUrl(), unread);
return Inbox(pageNumber, GenerateUrl(), unread);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
}
}
}
}
/// <summary>
/// <summary>
/// Retrieves the Voicemail folder
/// Retrieves the Voicemail folder
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
public GetFolderResult Voicemail(uint? pageNumber = null, bool unread = false)
public GetFolderResult Voicemail(uint? pageNumber = null, bool unread = false)
{
{
try
try
{
{
return Inbox(pageNumber, GenerateUrl(), unread);
return Inbox(pageNumber, GenerateUrl(), unread);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
}
}
}
}
/// <summary>
/// <summary>
/// Retrieves the Texts/SMS folder
/// Retrieves the Texts/SMS folder
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
public GetFolderResult Texts(uint? pageNumber = null, bool unread = false)
public GetFolderResult Texts(uint? pageNumber = null, bool unread = false)
{
{
try
try
{
{
return Inbox(pageNumber, GenerateUrl(), unread);
return Inbox(pageNumber, GenerateUrl(), unread);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
}
}
}
}
/// <summary>
/// <summary>
/// Retrieves the Texts/SMS folder
/// Retrieves the Texts/SMS folder
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
public GetFolderResult SMS(uint? pageNumber = null, bool unread = false)
public GetFolderResult SMS(uint? pageNumber = null, bool unread = false)
{
{
try
try
{
{
return Texts(pageNumber);
return Texts(pageNumber);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
}
}
}
}
/// <summary>
/// <summary>
/// Retrieves the Recorded folder
/// Retrieves the Recorded folder
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
public GetFolderResult Recorded(uint? pageNumber = null, bool unread = false)
public GetFolderResult Recorded(uint? pageNumber = null, bool unread = false)
{
{
try
try
{
{
return Inbox(pageNumber, GenerateUrl(), unread);
return Inbox(pageNumber, GenerateUrl(), unread);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
}
}
}
}
/// <summary>
/// <summary>
/// Retrieves the Placed folder
/// Retrieves the Placed folder
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
public GetFolderResult Placed(uint? pageNumber = null, bool unread = false)
public GetFolderResult Placed(uint? pageNumber = null, bool unread = false)
{
{
try
try
{
{
return Inbox(pageNumber, GenerateUrl(), unread);
return Inbox(pageNumber, GenerateUrl(), unread);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
}
}
}
}
/// <summary>
/// <summary>
/// Retrieves the Missed folder
/// Retrieves the Missed folder
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
public GetFolderResult Missed(uint? pageNumber = null, bool unread = false)
public GetFolderResult Missed(uint? pageNumber = null, bool unread = false)
{
{
try
try
{
{
return Inbox(pageNumber, GenerateUrl(), unread);
return Inbox(pageNumber, GenerateUrl(), unread);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
}
}
}
}
/// <summary>
/// <summary>
/// Retrieves the Received folder
/// Retrieves the Received folder
/// </summary>
/// </summary>
/// <param name="pageNumber">Page number to retrieve</param>
/// <param name="pageNumber">Page number to retrieve</param>
public GetFolderResult Received(uint? pageNumber = null, bool unread = false)
public GetFolderResult Received(uint? pageNumber = null, bool unread = false)
{
{
try
try
{
{
return Inbox(pageNumber, GenerateUrl(), unread);
return Inbox(pageNumber, GenerateUrl(), unread);
}
}
catch (Exception ex)
catch (Exception ex)
{
{
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
throw new FolderException(MethodInfo.GetCurrentMethod().Name.ToLower(), ex);
}
}
}
}
}
}
}
}