Пример #1
0
        public IEnumerable<RtTicket> FindByQuery(string query, string orderby, TicketSearchResponseFormat format)
        {
            Client.Login();
            var response = Client.SearchTickets(query, orderby, format);
            Client.Logout();
            ITicketSearchResponseParser parser = null;

            switch (format.InnerEnumValue())
            {
                case TicketSearchResponseFormat.InnerEnum.IdOnly:
                    break;
                case TicketSearchResponseFormat.InnerEnum.IdAndSubject:
                    break;
                case TicketSearchResponseFormat.InnerEnum.MultiLine:
                    parser = MultilineTicketSearchResponseParser.Instance;
                    break;
            }

            if (parser == null) throw new NotSupportedException("Could not create parser for response format.");

            switch (response.StatusCode)
            {
                case 200:
                    return parser.ParseTicketSearchResponse(response);
                case 401:
                    throw new InvalidCredentialException(response.StatusMessage);
                default:
                    throw new IOException(String.Format("Server returned {0} ({1})", response.StatusCode, response.StatusMessage));
            }
        }
Пример #2
0
 public RtResponse SearchTickets(string query, string orderby = null, TicketSearchResponseFormat format = null)
 {
     var queryParams = new Dictionary<string, string> {{"query", query}};
     if (orderby != null) queryParams.Add("orderby", orderby);
     if (format != null) queryParams.Add("format", format.FormatString);
     return GetResponse("search/ticket", queryParams);
 }
Пример #3
0
 public IEnumerable<RtTicket> FindByQuery(string query, TicketSearchResponseFormat format)
 {
     return FindByQuery(query, null, format);
 }