Skip to content
1 change: 0 additions & 1 deletion Vertical.HubSpot.Api.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Global
{651286E9-6DB5-440B-BD86-F5E8BB7777CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{651286E9-6DB5-440B-BD86-F5E8BB7777CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{651286E9-6DB5-440B-BD86-F5E8BB7777CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{651286E9-6DB5-440B-BD86-F5E8BB7777CA}.Release|Any CPU.Build.0 = Release|Any CPU
{C81B467D-DEE8-4E6D-B9DA-F4C5E32D7BA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C81B467D-DEE8-4E6D-B9DA-F4C5E32D7BA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C81B467D-DEE8-4E6D-B9DA-F4C5E32D7BA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
8 changes: 6 additions & 2 deletions Vertical.HubSpot.Api/Companies/CompanyApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ public async Task<PageResponse<T>> ListPage<T>(long? offset = null, params strin

JObject response = await rest.Get<JObject>("companies/v2/companies/paged", GetListParameters(offset, properties).ToArray());

var hasMore = response.Value<bool>("has-more");
return new PageResponse<T> {
Offset = response.Value<bool>("has-more") ? response.Value<long?>("offset") : null,
HasMore = hasMore,
Offset = hasMore ? response.Value<long?>("offset") : null,
Data = response.GetValue("companies").OfType<JObject>().Select(d => ToCompany<T>(d, model)).ToArray()
};
}
Expand All @@ -162,8 +164,10 @@ public async Task<PageResponse<T>> RecentlyModifiedPage<T>(long? offset = null)

JObject response = await rest.Get<JObject>("companies/v2/companies/recent/modified", GetListParameters(offset).ToArray());

var hasMore = response.Value<bool>("has-more");
return new PageResponse<T> {
Offset = response.Value<bool>("hasMore") ? response.Value<long?>("offset") : null,
HasMore = hasMore,
Offset = hasMore ? response.Value<long?>("offset") : null,
Data = response.GetValue("results").OfType<JObject>().Select(d => ToCompany<T>(d, model)).ToArray()
};
}
Expand Down
44 changes: 44 additions & 0 deletions Vertical.HubSpot.Api/Contacts/ContactApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,50 @@ public async Task<PageResponse<T>> ListPage<T>(long? offset = null, int? count =
};
}

/// <summary>
/// get recently modified contacts
/// </summary>
/// <typeparam name="T">type of contact model</typeparam>
/// <param name="offset">offset to use to get a specific result page (optional)</param>
/// <returns>a page of recently modified contacts</returns>
public async Task<PageResponse<T>> RecentlyUpdatedPage<T>(long? offset = null, int? count = null, params string[] properties)
where T : HubSpotContact
{
EntityModel model = models.Get(typeof(T));

JObject response = await rest.Get<JObject>("contacts/v1/lists/recently_updated/contacts/recent", GetListParameters(offset, count ?? 100, properties).ToArray());

var hasMore = response.Value<bool>("has-more");
return new PageResponse<T>
{
HasMore = hasMore,
Offset = hasMore ? response.Value<long?>("vid-offset") : null,
Data = response.GetValue("contacts").OfType<JObject>().Select(d => d.ToContact<T>(model)).ToArray()
};
}

/// <summary>
/// get recently created contacts
/// </summary>
/// <typeparam name="T">type of contact model</typeparam>
/// <param name="offset">offset to use to get a specific result page (optional)</param>
/// <returns>a page of recently created contacts</returns>
public async Task<PageResponse<T>> RecentlyCreatedPage<T>(long? offset = null, int? count = null, params string[] properties)
where T : HubSpotContact
{
EntityModel model = models.Get(typeof(T));

JObject response = await rest.Get<JObject>("contacts/v1/lists/all/contacts/recent", GetListParameters(offset, count ?? 100, properties).ToArray());

var hasMore = response.Value<bool>("has-more");
return new PageResponse<T>
{
HasMore = hasMore,
Offset = hasMore ? response.Value<long?>("vid-offset") : null,
Data = response.GetValue("contacts").OfType<JObject>().Select(d => d.ToContact<T>(model)).ToArray()
};
}

/// <summary>
/// get a contact by id
/// </summary>
Expand Down
18 changes: 18 additions & 0 deletions Vertical.HubSpot.Api/Contacts/IContactApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ Task Update<T>(T contact)
Task<PageResponse<T>> ListPage<T>(long? offset = null, int? count = null, params string[] properties)
where T:HubSpotContact;

/// <summary>
/// get recently modified contacts
/// </summary>
/// <typeparam name="T">type of contact model</typeparam>
/// <param name="offset">offset to use to get a specific result page (optional)</param>
/// <returns>a page of recently modified contacts</returns>
Task<PageResponse<T>> RecentlyUpdatedPage<T>(long? offset = null, int? count = null, params string[] properties)
where T : HubSpotContact;

/// <summary>
/// get recently created contacts
/// </summary>
/// <typeparam name="T">type of contact model</typeparam>
/// <param name="offset">offset to use to get a specific result page (optional)</param>
/// <returns>a page of recently created contacts</returns>
Task<PageResponse<T>> RecentlyCreatedPage<T>(long? offset = null, int? count = null, params string[] properties)
where T : HubSpotContact;

/// <summary>
/// get a contact by id
/// </summary>
Expand Down
8 changes: 6 additions & 2 deletions Vertical.HubSpot.Api/Deals/DealsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ public async Task<PageResponse<T>> ListPage<T>(long? offset = null, params strin

JObject response = await rest.Get<JObject>("deals/v1/deal/paged", GetListParameters(offset, properties).ToArray());

var hasMore = response.Value<bool>("hasMore");
return new PageResponse<T> {
Offset = response.Value<bool>("hasMore") ? response.Value<long?>("offset") : null,
HasMore = hasMore,
Offset = hasMore ? response.Value<long?>("offset") : null,
Data = response.GetValue("deals").OfType<JObject>().Select(d => ToDeal<T>(d, model)).ToArray()
};
}
Expand Down Expand Up @@ -207,8 +209,10 @@ public async Task<PageResponse<T>> RecentlyModifiedPage<T>(DateTime? since, long

JObject response = await rest.Get<JObject>("deals/v1/deal/recent/modified", GetRecentParameters(since, offset).ToArray());

var hasMore = response.Value<bool>("hasMore");
return new PageResponse<T> {
Offset = response.Value<bool>("hasMore") ? response.Value<long?>("offset") : null,
HasMore = hasMore,
Offset = hasMore ? response.Value<long?>("offset") : null,
Data = response.GetValue("results").OfType<JObject>().Select(d => ToDeal<T>(d, model)).ToArray()
};
}
Expand Down
2 changes: 1 addition & 1 deletion Vertical.HubSpot.Api/Engagements/EngagementsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Task<JObject> DeleteEngagement(long id)
public async Task<T> CreateEngagement<T>(HubSpotEngagementResult data)
where T : HubSpotEngagementResult
{
var requestData = JToken.FromObject(data);
var requestData = JToken.FromObject(data, new Newtonsoft.Json.JsonSerializer() { NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore });
JObject response = await rest.Post<JObject>($"/engagements/v1/engagements", requestData);
return ToEngagementResult<T>(response);
}
Expand Down
29 changes: 26 additions & 3 deletions Vertical.HubSpot.Api/Engagements/HubSpotEngagementMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ namespace Vertical.HubSpot.Api.Engagements
public class HubspotEngagementMetadata
{
[JsonProperty("startTime")]
public long StartTime { get; set; }
public long? StartTime { get; set; }

[JsonProperty("endTime")]
public long EndTime { get; set; }
public long? EndTime { get; set; }

[JsonProperty("title")]
public string Title { get; set; }
Expand All @@ -28,9 +28,32 @@ public class HubspotEngagementMetadata
public string SourceId { get; set; }

[JsonProperty("createdFromLinkId")]
public long CreatedFromLinkId { get; set; }
public long? CreatedFromLinkId { get; set; }

[JsonProperty("preMeetingProspectReminders")]
public List<object> PreMeetingProspectReminders { get; set; }

[JsonProperty("cc")]
public List<HubspotEngangementContact> Cc { get; set; }

[JsonProperty("bcc")]
public List<HubspotEngangementContact> Bcc { get; set; }

[JsonProperty("subject")]
public string Subject { get; set; }

[JsonProperty("html")]
public string Html { get; set; }

[JsonProperty("text")]
public string Text { get; set; }

[JsonProperty("from")]
public HubspotEngangementContact From { get; set; }

[JsonProperty("to")]
public List<HubspotEngangementContact> To { get; set; }
[JsonProperty("sender")]
public HubspotEngangementContact Sender { get; set; }
}
}
19 changes: 19 additions & 0 deletions Vertical.HubSpot.Api/Engagements/HubspotEngangementContact.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace Vertical.HubSpot.Api.Engagements
{
public class HubspotEngangementContact
{
[JsonProperty("email")]
public string Email { get; set; }
[JsonProperty("firstName")]
public string FirstName { get; set; }
[JsonProperty("lastName")]
public string LastName { get; set; }
[JsonProperty("raw")]
public string Raw { get; set; }
}
}