Exemple #1
0
        private static string GetListQueryString(FreshdeskContactListOptions options)
        {
            if (options == null)
            {
                return("");
            }
            var filters = new List <string>();

            if (options.Email != default(string))
            {
                filters.Add($"email={WebUtility.UrlEncode(options.Email)}");
            }
            if (options.Phone != default(ulong?))
            {
                filters.Add($"phone={options.Phone.Value}");
            }
            if (options.Mobile != default(ulong?))
            {
                filters.Add($"mobile={options.Mobile.Value}");
            }
            if (options.CompanyId != default(ulong?))
            {
                filters.Add($"company_id={options.CompanyId.Value}");
            }
            if (options.State != default(FreshdeskContactState?))
            {
                filters.Add($"state={options.State.ToString().ToLower()}");
            }
            AddPageFilters(options, filters);
            return(filters.Count == 0 ? "" : $"?{string.Join("&", filters)}");
        }
Exemple #2
0
        public async Task <List <FreshdeskContact <TCustomFieldObject> > > GetListAsync <TCustomFieldObject>(FreshdeskContactListOptions options = null) where TCustomFieldObject : class
        {
            var query      = GetListQueryString(options);
            var requestUri = $"{_apiBaseUri}/contacts{query}";

            using (var response = await _httpClient.GetAsync(requestUri).ConfigureAwait(false))
            {
                var result = await GetResponseAsync <List <FreshdeskContactInternal <TCustomFieldObject> > >(response).ConfigureAwait(false);

                return(result.Select(contact => contact.ToContact()).ToList());
            }
        }
Exemple #3
0
 public async Task <List <FreshdeskContact <FreshdeskCustomFields> > > GetListAsync(FreshdeskContactListOptions options = null)
 {
     return(await GetListAsync <FreshdeskCustomFields>(options).ConfigureAwait(false));
 }