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

NullValueHandling for Deal-Update (#105) #134

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions src/Pipedrive.net/Converters/CustomFieldConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
var property_name = property.PropertyName;
var property_value = property.ValueProvider.GetValue(value);

if(property.NullValueHandling == NullValueHandling.Ignore && property_value == null)
{
continue;
}

writer.WritePropertyName(property_name);
if (property.Converter != null && property.Converter.CanWrite)
{
Expand Down
36 changes: 18 additions & 18 deletions src/Pipedrive.net/Models/Request/Deals/DealUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,56 @@ namespace Pipedrive
[JsonConverter(typeof(CustomFieldConverter))]
public class DealUpdate : IEntityWithCustomFields
{
[JsonProperty("title")]
[JsonProperty("title", NullValueHandling=NullValueHandling.Ignore)]
public string Title { get; set; }

[JsonProperty("value")]
[JsonProperty("value", NullValueHandling=NullValueHandling.Ignore)]
public decimal? Value { get; set; }

[JsonProperty("currency")]
[JsonProperty("currency", NullValueHandling=NullValueHandling.Ignore)]
public string Currency { get; set; }

[JsonProperty("user_id")]
[JsonProperty("user_id", NullValueHandling=NullValueHandling.Ignore)]
public long? UserId { get; set; }

[JsonProperty("person_id")]
[JsonProperty("person_id", NullValueHandling=NullValueHandling.Ignore)]
public long? PersonId { get; set; }

[JsonProperty("org_id")]
[JsonProperty("org_id", NullValueHandling=NullValueHandling.Ignore)]
public long? OrgId { get; set; }

[JsonProperty("stage_id")]
[JsonProperty("stage_id", NullValueHandling=NullValueHandling.Ignore)]
public long? StageId { get; set; }

[JsonProperty("status")]
[JsonProperty("status", NullValueHandling=NullValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
public DealStatus? Status { get; set; }

[JsonProperty("probability")]
[JsonProperty("probability", NullValueHandling=NullValueHandling.Ignore)]
public double? Probability { get; set; }

[JsonProperty("lost_reason")]
[JsonProperty("lost_reason", NullValueHandling=NullValueHandling.Ignore)]
public string LostReason { get; set; }

[JsonProperty("visible_to")]
public Visibility VisibleTo { get; set; }
[JsonProperty("visible_to", NullValueHandling=NullValueHandling.Ignore)]
public Visibility? VisibleTo { get; set; }

[JsonProperty("add_time")]
[JsonProperty("add_time", NullValueHandling=NullValueHandling.Ignore)]
public DateTime? AddTime { get; set; }

[JsonProperty("close_time")]
[JsonProperty("close_time", NullValueHandling=NullValueHandling.Ignore)]
public DateTime? CloseTime { get; set; }

[JsonProperty("lost_time")]
[JsonProperty("lost_time", NullValueHandling=NullValueHandling.Ignore)]
public DateTime? LostTime { get; set; }

[JsonProperty("first_won_time")]
[JsonProperty("first_won_time", NullValueHandling=NullValueHandling.Ignore)]
public DateTime? FirstWonTime { get; set; }

[JsonProperty("won_time")]
[JsonProperty("won_time", NullValueHandling=NullValueHandling.Ignore)]
public DateTime? WonTime { get; set; }

[JsonProperty("expected_close_date")]
[JsonProperty("expected_close_date", NullValueHandling=NullValueHandling.Ignore)]
public DateTime? ExpectedCloseDate { get; set; }

[JsonIgnore]
Expand Down