Listar Empresas

Recupera uma lista de empresas por um critério de pesquisa

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…
public async Task<string> ConsultarEmpresasAsync(int pageNumber, int pageSize, string searchBy = "", string searchTerm = "", string sortBy = "", string sortDirection = "")
{
  try
  {
    var parameters = new StringBuilder(string.Format("/empresas?pageNumber={0}&pageSize={1}", pageNumber.ToString(), pageSize.ToString()));

    if (!string.IsNullOrEmpty(searchBy))
      parameters.Append("&searchBy=" + searchBy);

    if (!string.IsNullOrEmpty(searchTerm))
      parameters.Append("&searchTerm=" + searchTerm);

    if (!string.IsNullOrEmpty(sortBy))
      parameters.Append("&sortBy=" + sortBy);

    if (!string.IsNullOrEmpty(sortDirection))
      parameters.Append("&sortDirection=" + sortDirection);

    using (var httpClient = new HttpClient())
    {
        httpClient.DefaultRequestHeaders.Clear();
        httpClient.DefaultRequestHeaders.Add("Authorization", "Basic {Sua-ApiKey-Aqui}");
        httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

      using (var request = new HttpRequestMessage(HttpMethod.Get, string.Format("https://api.notagateway.com.br/v2", parameters.ToString())))
      {
         using (var response = await httpClient.SendAsync(request))
         {
           var resultContent = await response.Content.ReadAsStringAsync();

           if (response.IsSuccessStatusCode)
           {
               return resultContent;
           }
           else
           {
               throw new Exception(((int)response.StatusCode) + " - " + response.ReasonPhrase);
           }
         }
       }
     }
  }
  catch (Exception)
  {
    throw;
  }
}
Query Params
string
required
Defaults to 0

Número da página

string
required
Defaults to 5

Total de itens a serem retornados por página

string
required
Defaults to nome_fantasia

Campo no qual será aplicado o termo de pesquisa. Valores possíveis: nome_fantasia, razao_social

string
required

Termo de pesquisa

string
required
Defaults to nome_fantasia

Campo no qual será aplicado a ordenação. Valores possíveis: nome_fantasia, razao_social, cidade, data_criacao, data_ultima_modificacao

string
required
Defaults to asc

Direção na qual será feita a ordenação. Valores possíveis: ASC, DESC

Headers
string
enum
Defaults to application/json

Generated from available response content types

Allowed:
Responses

Language
Credentials
Header
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json
text/plain