/// <summary> /// Gets a company by domain name /// </summary> /// <typeparam name="T">Implementation of CompanyHubSpotModel</typeparam> /// <param name="domain">Domain name to search for</param> /// <param name="options">Set of search options</param> /// <returns>The company entity</returns> public CompanySearchResultModel <T> GetByDomain <T>(string domain, CompanySearchByDomain options = null) where T : CompanyHubSpotModel, new() { if (options == null) { options = new CompanySearchByDomain(); } var path = $"{new CompanyHubSpotModel().RouteBasePath}/domains/{domain}/companies"; var data = _client.ExecuteList <CompanySearchResultModel <T> >(path, options, Method.POST); return(data); }
/// <summary> /// Gets a company by domain name /// </summary> /// <typeparam name="T">Implementation of CompanyHubSpotModel</typeparam> /// <param name="domain">Domain name to search for</param> /// <param name="options">Set of search options</param> /// <returns>The company entity or null if the company does not exist.</returns> public CompanySearchResultModel <CompanyHubSpotModel> GetByDomain(string domain, CompanySearchByDomain opts = null) { opts = opts ?? new CompanySearchByDomain(); var path = GetRoute <CompanyHubSpotModel>("domains", domain, "companies"); try { return(_client.Execute <CompanySearchResultModel <CompanyHubSpotModel>, CompanySearchByDomain>(path, opts, Method.POST)); } catch (HubSpotException exception) { if (exception.ReturnedError.StatusCode == HttpStatusCode.NotFound) { return(null); } throw; } }
/// <summary> /// Gets a company by domain name /// </summary> /// <typeparam name="T">Implementation of CompanyHubSpotModel</typeparam> /// <param name="domain">Domain name to search for</param> /// <param name="options">Set of search options</param> /// <returns>The company entity</returns> public Task <CompanySearchResultModel <CompanyHubSpotModel> > GetByDomainAsync(string domain, CompanySearchByDomain opts = null, CancellationToken cancellationToken = default) { opts = opts ?? new CompanySearchByDomain(); var path = GetRoute <CompanyHubSpotModel>("domains", domain, "companies"); return(_client.ExecuteAsync <CompanySearchResultModel <CompanyHubSpotModel>, CompanySearchByDomain>(path, opts, Method.POST, cancellationToken)); }
/// <summary> /// Gets a company by domain name /// </summary> /// <typeparam name="T">Implementation of CompanyHubSpotModel</typeparam> /// <param name="domain">Domain name to search for</param> /// <param name="options">Set of search options</param> /// <returns>The company entity</returns> public CompanySearchResultModel <CompanyHubSpotModel> GetByDomain(string domain, CompanySearchByDomain opts = null) { opts = opts ?? new CompanySearchByDomain(); var path = GetRoute <CompanyHubSpotModel>("domains", domain, "companies"); return(_client.Execute <CompanySearchResultModel <CompanyHubSpotModel>, CompanySearchByDomain>(path, opts, Method.POST)); }