Skip to content

Commit 247895f

Browse files
authored
Merge pull request #24 from nsp37/master
Add GetByUserToken to contacts API
2 parents da7f7e4 + 67cd0e9 commit 247895f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

HubSpot.NET/Api/Contact/HubSpotContactApi.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ public HubSpotContactApi(IHubSpotClient client)
5656
var data = _client.Execute<T>(path, Method.GET);
5757
return data;
5858
}
59+
60+
/// <summary>
61+
/// Gets a contact by their user token
62+
/// </summary>
63+
/// <param name="userToken">User token to search for from hubspotutk cookie</param>
64+
/// <typeparam name="T">Implementation of ContactHubSpotModel</typeparam>
65+
/// <returns>The contact entity</returns>
66+
public T GetByUserToken<T>(string userToken) where T : ContactHubSpotModel, new()
67+
{
68+
var path = $"{new T().RouteBasePath}/contact/utk/{userToken}/profile";
69+
var data = _client.Execute<T>(path, Method.GET);
70+
return data;
71+
}
5972

6073
/// <summary>
6174
/// List all available contacts
@@ -214,4 +227,4 @@ public void Delete(long contactId)
214227
return data;
215228
}
216229
}
217-
}
230+
}

HubSpot.NET/Core/Interfaces/IHubSpotContactApi.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ public interface IHubSpotContactApi
1111
void Batch<T>(List<T> entities) where T : ContactHubSpotModel, new();
1212
T GetByEmail<T>(string email) where T : ContactHubSpotModel, new();
1313
T GetById<T>(long contactId) where T : ContactHubSpotModel, new();
14+
T GetByUserToken<T>(string userToken) where T : ContactHubSpotModel, new();
1415
ContactListHubSpotModel<T> List<T>(ListRequestOptions opts = null) where T : ContactHubSpotModel, new();
1516
void Update<T>(T contact) where T : ContactHubSpotModel, new();
1617
ContactListHubSpotModel<T> RecentlyCreated<T>(ListRecentRequestOptions opts = null) where T : ContactHubSpotModel, new();
1718
ContactListHubSpotModel<T> RecentlyUpdated<T>(ListRecentRequestOptions opts = null) where T : ContactHubSpotModel, new();
1819
}
19-
}
20+
}

0 commit comments

Comments
 (0)