11using System ;
2+ using System . Linq ;
3+ using Flurl ;
24using HubSpot . NET . Api . Company . Dto ;
5+ using HubSpot . NET . Core ;
36using HubSpot . NET . Core . Interfaces ;
47using RestSharp ;
58
@@ -48,7 +51,7 @@ public HubSpotCompanyApi(IHubSpotClient client)
4851 /// <param name="domain">Domain name to search for</param>
4952 /// <param name="options">Set of search options</param>
5053 /// <returns>The company entity</returns>
51- public T GetByDomain < T > ( string domain , CompanySearchByDomain options = null ) where T : CompanySearchResultModel , new ( )
54+ public CompanySearchResultModel < T > GetByDomain < T > ( string domain , CompanySearchByDomain options = null ) where T : CompanyHubSpotModel , new ( )
5255 {
5356 if ( options == null )
5457 {
@@ -57,7 +60,31 @@ public HubSpotCompanyApi(IHubSpotClient client)
5760
5861 var path = $ "{ new CompanyHubSpotModel ( ) . RouteBasePath } /domains/{ domain } /companies";
5962
60- var data = _client . ExecuteList < T > ( path , options , Method . POST ) ;
63+ var data = _client . ExecuteList < CompanySearchResultModel < T > > ( path , options , Method . POST ) ;
64+
65+ return data ;
66+ }
67+
68+ public CompanyListHubSpotModel < T > List < T > ( ListRequestOptions opts = null ) where T : CompanyHubSpotModel , new ( )
69+ {
70+ if ( opts == null )
71+ {
72+ opts = new ListRequestOptions ( ) ;
73+ }
74+
75+ var path = $ "{ new CompanyHubSpotModel ( ) . RouteBasePath } /companies/paged"
76+ . SetQueryParam ( "count" , opts . Limit ) ;
77+
78+ if ( opts . PropertiesToInclude . Any ( ) )
79+ {
80+ path . SetQueryParam ( "properties" , opts . PropertiesToInclude ) ;
81+ }
82+ if ( opts . Offset . HasValue )
83+ {
84+ path = path . SetQueryParam ( "offset" , opts . Offset ) ;
85+ }
86+
87+ var data = _client . ExecuteList < CompanyListHubSpotModel < T > > ( path , opts ) ;
6188
6289 return data ;
6390 }
0 commit comments