Skip to content

Commit

Permalink
fix: [breaking] make StartTime nullable on Answered webhook (#568)
Browse files Browse the repository at this point in the history
* fix: [breaking] make StartTime nullable on Answered webhook

* refactor: update test content
  • Loading branch information
Tr00d committed Mar 13, 2024
1 parent 8948ead commit 426d91f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"start_time": null,
"headers": {
"[redacted]": "[redacted]"
},
"rate": null,
"from": "[redacted]",
"to": "[redacted]",
"uuid": "c8061992c89a65e3790bfa0aaca6f069",
"conversation_uuid": "CON-5a0cdebb-0f35-45a4-9b38-a99f9d12d6d7",
"status": "answered",
"direction": "inbound",
"network": null,
"timestamp": "2024-01-25T12:16:32.319Z"
}
3 changes: 3 additions & 0 deletions Vonage.Test/Vonage.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,9 @@
<None Update="VerifyV2\StartVerification\Data\ShouldSerializeSmsWorkflowWithOptionalValues-request.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Data\Webhooks\ShouldDeserializedAnswered_GivenStartTimeIsNull.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="node ../.scripts/init.js"/>
Expand Down
11 changes: 11 additions & 0 deletions Vonage.Test/WebhookStructsTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Globalization;
using System.IO;
using FluentAssertions;
using Newtonsoft.Json;
using Vonage.Voice.AnswerWebhooks;
using Vonage.Voice.EventWebhooks;
Expand Down Expand Up @@ -384,6 +386,15 @@ public void TestTransfer()
Assert.Equal("aaaaaaaa-bbbb-cccc-dddd-0123456789ab", transferWebhook.Uuid);
}

[Fact]
public void ShouldDeserializedAnswered_GivenStartTimeIsNull()
{
var deserializedEvent =
(Answered) EventBase.ParseEvent(
File.ReadAllText("Data/Webhooks/ShouldDeserializedAnswered_GivenStartTimeIsNull.json"));
deserializedEvent.StartTime.Should().BeNull();
}

public class Foo
{
public string bar { get; set; }
Expand Down
8 changes: 4 additions & 4 deletions Vonage/Voice/EventWebhooks/Answered.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System;
using System;
using Newtonsoft.Json;

namespace Vonage.Voice.EventWebhooks;

Expand All @@ -9,14 +9,14 @@ public class Answered : CallStatusEvent
/// call start time
/// </summary>
[JsonProperty("start_time")]
public DateTime StartTime { get; set; }
public DateTime? StartTime { get; set; }

/// <summary>
/// cost rate for the call
/// </summary>
[JsonProperty("rate")]
public string Rate { get; set; }

/// <summary>
/// Network the call came from
/// </summary>
Expand Down

0 comments on commit 426d91f

Please sign in to comment.