Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue # 108 : Engagement Type cannot be null #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion HubSpot.NET/Api/Engagement/Dto/EngagementHubSpotModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class EngagementHubSpotAssociationsModel
public class EngagementHubSpotEngagementModel
{
[DataMember(Name = "id")]
public long? Id { get; set; }
public long Id { get; set; }

[DataMember(Name = "type")]
public string Type { get;set; }
Expand Down
14 changes: 10 additions & 4 deletions HubSpot.NET/Core/HubSpotBaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace HubSpot.NET.Core
using HubSpot.NET.Core.Interfaces;
using HubSpot.NET.Core.Serializers;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using RestSharp;
using System.Collections.Generic;

Expand Down Expand Up @@ -110,9 +111,15 @@ public void UpdateToken(HubSpotToken token)
private T SendReceiveRequest<T,K>(string path, Method method, K entity) where T: new()
{
RestRequest request = ConfigureRequestAuthentication(path, method);

if(!entity.Equals(default(K)))
request.AddJsonBody(entity);

var json = JsonConvert.SerializeObject(entity, new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore
});

if (!entity.Equals(default(K)))
request.AddJsonBody(json);

IRestResponse response = _client.Execute(request);

Expand Down Expand Up @@ -179,7 +186,6 @@ private RestRequest ConfigureRequestAuthentication(string path, Method method)
break;
}

request.JsonSerializer = new NewtonsoftRestSharpSerializer();
return request;
}

Expand Down