/// <summary> /// Initializes a new instance of the <see cref="T:Switchvox.CallLogs.Search"/> class for searches where a single search criterion must be specified. /// </summary> /// <param name="startDate">The minimum date to search from.</param> /// <param name="endDate">The maximum date to search to.</param> /// <param name="searchData">A <see cref="Switchvox.CallLogs.Search.SingleItemSearchData"/> value representing the type of data this request will search for.</param> /// <param name="data">A single value corresponding with the type of data specified in <paramref name="searchData"/></param> /// <param name="sortOrder">How the response will be sorted</param> /// <param name="itemsPerPage">The maximum number of records to be returned by the response. An additional <paramref name="itemsPerPage"/> number of records can be retrieved by making additional requests and modifying the <paramref name="pageNumber"/></param> /// <param name="pageNumber">The page number of call record results to return.</param> public Search(DateTime startDate, DateTime endDate, SingleItemSearchData searchData, string data, SortOrder sortOrder = SortOrder.Desc, int itemsPerPage = 50, int pageNumber = 1) : base("switchvox.callLogs.search") { var searchDataElms = GetSingleItemSearchDataElms(searchData, data); ConstructXml(startDate, endDate, searchDataElms, sortOrder, itemsPerPage, pageNumber); }
private XElement GetSingleItemSearchDataElms(SingleItemSearchData searchData, string data) { string tagName; string groupTagName = null; switch(searchData) { case SingleItemSearchData.AccountIds: groupTagName = "account_ids"; tagName = "account_id"; break; case SingleItemSearchData.ChannelGroupIds: groupTagName = "channel_group_ids"; tagName = "channel_group_id"; break; case SingleItemSearchData.IAXProviderIds: groupTagName = "iax_provider_ids"; tagName = "iax_provider_id"; break; case SingleItemSearchData.SIPProviderIds: groupTagName = "sip_provider_ids"; tagName = "sip_provider_id"; break; case SingleItemSearchData.CallerIdName: tagName = "caller_id_name"; break; case SingleItemSearchData.CallerIdNumber: tagName = "caller_id_number"; break; case SingleItemSearchData.IncomingDID: tagName = "incoming_did"; break; default: throw new NotImplementedException("No handler for the value " + searchData.ToString() + " has been implemented."); } XElement xml; if (groupTagName == null) xml = new XElement(tagName, data); else xml = new XElement(groupTagName, new XElement(tagName, data)); return xml; }