Skip to content

Commit

Permalink
NullValueHandling for Deal-Update (DavidRouyer#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasmo committed Nov 15, 2022
1 parent aead1e2 commit b990cb3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
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

0 comments on commit b990cb3

Please sign in to comment.