Skip to content
Merged
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
255 changes: 255 additions & 0 deletions Source/ZoomNet.UnitTests/PhoneWebhookParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,116 @@ public void PhoneWarmTransferInitiated()
parsedEvent.TransferCallId.ShouldBe("6986878782238080584");
}

[Fact]
public void PhoneAiCallSummaryChanged()
{
var parsedEvent = ParseWebhookEvent<PhoneAiCallSummaryChangedEvent>(Resource.phone_ai_call_summary_changed_webhook);

parsedEvent.EventType.ShouldBe(ZoomNet.Models.Webhooks.EventType.PhoneAiCallSummaryChanged);
parsedEvent.Timestamp.ShouldBe(eventTimestamp);
parsedEvent.AccountId.ShouldBe(AccountId);

VerifyAiCallSummary(parsedEvent.CallSummary);
}

[Fact]
public void PhoneConferenceStarted()
{
var parsedEvent = ParseWebhookEvent<PhoneConferenceStartedEvent>(Resource.phone_conference_started_webhook);

parsedEvent.EventType.ShouldBe(ZoomNet.Models.Webhooks.EventType.PhoneConferenceStarted);
parsedEvent.Timestamp.ShouldBe(eventTimestamp);
parsedEvent.AccountId.ShouldBe(AccountId);

parsedEvent.ConferenceCall.ShouldNotBeNull();
parsedEvent.ConferenceCall.Id.ShouldBe("2074969d-621f-41d3-890c-8a44a03fa3e0");
parsedEvent.ConferenceCall.CallId.ShouldBe(CallId);
parsedEvent.ConferenceCall.StartedOn.ShouldBe(timestamp);
parsedEvent.ConferenceCall.EnableMultiplePartyConference.ShouldBeTrue();
parsedEvent.ConferenceCall.FailureReason.ShouldBeEmpty();

VerifyCallOwnerInfo(parsedEvent.ConferenceCall.Owner);
}

[Fact]
public void PhoneDeviceRegistration()
{
var parsedEvent = ParseWebhookEvent<PhoneDeviceRegistrationEvent>(Resource.phone_device_registration_webhook);

parsedEvent.EventType.ShouldBe(ZoomNet.Models.Webhooks.EventType.PhoneDeviceRegistration);
parsedEvent.Timestamp.ShouldBe(eventTimestamp);
parsedEvent.AccountId.ShouldBe(AccountId);

parsedEvent.Device.ShouldNotBeNull();
parsedEvent.Device.Id.ShouldBe("JOZmuJ30Spyrw-v9vUzIrA");
parsedEvent.Device.Name.ShouldBe("New_DeskPhone");
parsedEvent.Device.MacAddress.ShouldBe("012345678912");
}

[Fact]
public void PhoneEmergencyAlert()
{
var parsedEvent = ParseWebhookEvent<PhoneEmergencyAlertEvent>(Resource.phone_emergency_alert_webhook);

parsedEvent.EventType.ShouldBe(ZoomNet.Models.Webhooks.EventType.PhoneEmergencyAlert);
parsedEvent.Timestamp.ShouldBe(eventTimestamp);
parsedEvent.AccountId.ShouldBe(AccountId);

VerifyEmergencyCallAlert(parsedEvent.Alert);
}

[Fact]
public void PhoneGenericDeviceProvision()
{
var parsedEvent = ParseWebhookEvent<PhoneGenericDeviceProvisionEvent>(Resource.phone_generic_device_provision_webhook);

parsedEvent.EventType.ShouldBe(ZoomNet.Models.Webhooks.EventType.PhoneGenericDeviceProvision);
parsedEvent.Timestamp.ShouldBe(eventTimestamp);
parsedEvent.AccountId.ShouldBe(AccountId);

VerifyPhoneDevice(parsedEvent.Device);
}

[Fact]
public void PhonePeeringNumberCallerIdNameUpdated()
{
var parsedEvent = ParseWebhookEvent<PhonePeeringNumberCallerIdNameUpdatedEvent>(Resource.phone_peering_number_cnam_updated_webhook);

VerifyPeeringNumberUpdatedEvent(parsedEvent, ZoomNet.Models.Webhooks.EventType.PhonePeeringNumberCallerIdNameUpdated);

VerifyWebhookPeeringNumberUpdate(parsedEvent.PeeringNumber);
}

[Fact]
public void PhonePeeringNumberEmergencyAddressUpdated()
{
var parsedEvent = ParseWebhookEvent<PhonePeeringNumberEmergencyAddressUpdatedEvent>(Resource.phone_peering_number_emergency_address_updated_webhook);

VerifyPeeringNumberUpdatedEvent(parsedEvent, ZoomNet.Models.Webhooks.EventType.PhonePeeringNumberEmergencyAddressUpdated);

VerifyWebhookPeeringNumberUpdate(parsedEvent.PeeringNumber, callerIdName: null);
}

[Fact]
public void NumberManagementPeeringNumberCallerIdNameUpdated()
{
var parsedEvent = ParseWebhookEvent<NumberManagementPeeringNumberCallerIdNameUpdatedEvent>(Resource.number_management_peering_number_cnam_updated_webhook);

VerifyPeeringNumberUpdatedEvent(parsedEvent, ZoomNet.Models.Webhooks.EventType.NumberManagementPeeringNumberCallerIdNameUpdated);

VerifyWebhookPeeringNumberUpdate(parsedEvent.PeeringNumber);
}

[Fact]
public void NumberManagementPeeringNumberEmergencyAddressUpdated()
{
var parsedEvent = ParseWebhookEvent<NumberManagementPeeringNumberEmergencyAddressUpdatedEvent>(Resource.number_management_peering_number_emergency_address_updated_webhook);

VerifyPeeringNumberUpdatedEvent(parsedEvent, ZoomNet.Models.Webhooks.EventType.NumberManagementPeeringNumberEmergencyAddressUpdated);

VerifyWebhookPeeringNumberUpdate(parsedEvent.PeeringNumber, callerIdName: null);
}

#endregion

#region private methods
Expand Down Expand Up @@ -1294,6 +1404,151 @@ private static void VerifyCallTransferRecipient(WebhookCallTransferRecipient inf
info.Name.ShouldBe("Jane Smith");
}

/// <summary>
/// Verify <see cref="AiCallSummary"/> properties.
/// </summary>
private static void VerifyAiCallSummary(AiCallSummary summary)
{
summary.ShouldNotBeNull();
summary.Id.ShouldBe("iNsfqK6gQOCiILiKhrlLqQ");
summary.CallId.ShouldBe(CallId);
summary.UserId.ShouldBe("FvB3CRfOQUuhF1IOB176Tg");
summary.CreatedOn.ShouldBe(new DateTime(2023, 10, 8, 16, 12, 4));
summary.ModifiedOn.ShouldBe(new DateTime(2023, 10, 8, 16, 13, 5));
summary.IsModified.ShouldBeTrue();
summary.IsDeleted.ShouldBeFalse();

summary.CallLogIds.ShouldNotBeNull();
summary.CallLogIds.Length.ShouldBe(2);
summary.CallLogIds.ShouldBeSubsetOf(new[] { "6afdf3e3-87e3-47d0-834c-6ee3598e3b96", "6afdf3e3-87e3-47d0-834c-6ee3598e3b00" });
}

/// <summary>
/// Verify <see cref="EmergencyCallAlert"/> properties.
/// </summary>
private static void VerifyEmergencyCallAlert(EmergencyCallAlert alert)
{
alert.ShouldNotBeNull();
alert.CallId.ShouldBe(CallId);
alert.Router.ShouldBe(EmergencyCallSource.Zoom);
alert.DeliverTo.ShouldBe(EmergencyCallDestination.SafetyTeam);
alert.RingingStartedOn.ShouldBe(ringingStartedTimestamp);

alert.Callee.ShouldNotBeNull();
alert.Callee.PhoneNumber.ShouldBe("933");

alert.Caller.ShouldNotBeNull();
alert.Caller.UserId.ShouldBe("DnEopNmXQEGU2uvvzjgojw");
alert.Caller.ExtensionNumber.ShouldBe("1002");
alert.Caller.ExtensionType.ShouldBe(EmergencyCallExtensionType.User);
alert.Caller.DisplayName.ShouldBe("pbxta api");
alert.Caller.SiteId.ShouldBe(SiteId);
alert.Caller.SiteName.ShouldBe("Main Site");
alert.Caller.PhoneNumber.ShouldBe("+12192818492");
alert.Caller.Timezone.ShouldBe(TimeZones.America_Los_Angeles);

alert.Location.ShouldNotBeNull();
alert.Location.BssId.ShouldNotBeNull();
alert.Location.BssId.ShouldHaveSingleItem();
alert.Location.BssId[0].ShouldBe("fc:7f:49:12:45:01");
alert.Location.Gps.ShouldNotBeNull();
alert.Location.Gps.ShouldHaveSingleItem();
alert.Location.Gps[0].ShouldBe("31.29846,120.6645");
alert.Location.IpAddress.ShouldNotBeNull();
alert.Location.IpAddress.ShouldHaveSingleItem();
alert.Location.IpAddress[0].ShouldBe("192.0.2.1,192.0.2.2");

VerifyEmergencyAddress(alert.EmergencyAddress);
}

/// <summary>
/// Verify <see cref="EmergencyAddress"/> properties.
/// </summary>
private static void VerifyEmergencyAddress(EmergencyAddress address)
{
address.ShouldNotBeNull();
address.AddressLine1.ShouldBe("55 ALMADEN BLVD");
address.AddressLine2.ShouldBe("8 Floor");
address.City.ShouldBe("San Jose");
address.Country.ShouldBe("US");
address.StateCode.ShouldBe("CA");
address.Zip.ShouldBe("95113");
}

/// <summary>
/// Verify <see cref="PhoneDevice"/> properties.
/// </summary>
private static void VerifyPhoneDevice(PhoneDevice device)
{
device.ShouldNotBeNull();
device.Id.ShouldBe("JOZmuJ30Spyrw-v9vUzIrA");
device.DisplayName.ShouldBe("test_cap");
device.Type.ShouldBe("Other");
device.MacAddress.ShouldBe("012345678912");

device.Site.ShouldNotBeNull();
device.Site.Id.ShouldBe(SiteId);
device.Site.Name.ShouldBe("Main Site");

device.Provision.ShouldNotBeNull();
device.Provision.Type.ShouldBe(DeviceProvisioningType.Manual);
device.Provision.SipAccounts.ShouldNotBeNull();
device.Provision.SipAccounts.ShouldHaveSingleItem();

SipAccount sipAccount = device.Provision.SipAccounts[0];

sipAccount.AuthorizationId.ShouldBe("875586205903");
sipAccount.OutboundProxy.ShouldBe("example.com");
sipAccount.Password.ShouldBe("4dL09r0H");
sipAccount.SecondaryOutboundProxy.ShouldBe("example.com");
sipAccount.SipDomain.ShouldBe("example.com");
sipAccount.UserName.ShouldBe("83600015247557791369");

SharedLine sharedLine = sipAccount.SharedLine;

sharedLine.ShouldNotBeNull();
sharedLine.Alias.ShouldBe("Example line");
sharedLine.OutboundCallerId.ShouldBe(PhoneNumberB);
sharedLine.LineSubscription.ShouldNotBeNull();
sharedLine.LineSubscription.PhoneNumber.ShouldBe(PhoneNumberA);
sharedLine.LineSubscription.ExtensionNumber.ShouldBe(1040);
sharedLine.LineSubscription.DisplayName.ShouldBe("test_cap");
}

/// <summary>
/// Verify <see cref="PeeringNumberUpdatedEvent"/> properties.
/// </summary>
private static void VerifyPeeringNumberUpdatedEvent(PeeringNumberUpdatedEvent parsedEvent, ZoomNet.Models.Webhooks.EventType eventType)
{
parsedEvent.EventType.ShouldBe(eventType);
parsedEvent.Timestamp.ShouldBe(eventTimestamp);
parsedEvent.AccountId.ShouldBe(AccountId);
}

/// <summary>
/// Verify <see cref="WebhookPeeringNumberUpdate"/> properties.
/// </summary>
private static void VerifyWebhookPeeringNumberUpdate(WebhookPeeringNumberUpdate info, string callerIdName = "name")
{
info.ShouldNotBeNull();
info.CarrierCode.ShouldBe(3457);
info.PhoneNumbers.ShouldNotBeNull();
info.PhoneNumbers.ShouldHaveSingleItem();
info.PhoneNumbers[0].ShouldBe("+18008001000");

if (!string.IsNullOrEmpty(callerIdName))
{
info.CallerIdName.ShouldBe(callerIdName);
info.EmergencyAddress.ShouldBeNull();
}
else
{
VerifyEmergencyAddress(info.EmergencyAddress);

info.CallerIdName.ShouldBeNull();
}
}

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"event": "number_management.peering_number_cnam_updated",
"event_ts": 1619155436400,
"event_ts": 1626230691572,
"payload": {
"account_id": "Mt6sv4u0TAyPkwgsL2lxiA",
"account_id": "AAAAAABBBB",
"object": {
"cnam": "name",
"carrier_code": 3457,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"event": "number_management.peering_number_emergency_address_updated",
"event_ts": 1619155436400,
"event_ts": 1626230691572,
"payload": {
"account_id": "Mt6sv4u0TAyPkwgsL2lxiA",
"account_id": "AAAAAABBBB",
"object": {
"emergency_address": {
"address_line1": "55 ALMADEN BLVD",
"address_line2": "13F",
"city": "SAN JOSE",
"address_line2": "8 Floor",
"city": "San Jose",
"country": "US",
"state_code": "CA",
"zip": "95113"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"event": "phone.ai_call_summary_changed",
"event_ts": 1626230691572,
"payload": {
"account_id": "89gnHJQ9SdSmFpI9wmh6fQ",
"account_id": "AAAAAABBBB",
"object": {
"edited": true,
"deleted": false,
"ai_call_summary_id": "iNsfqK6gQOCiILiKhrlLqQ",
"user_id": "FvB3CRfOQUuhF1IOB176Tg",
"call_id": "066bd0dee0066150033",
"call_id": "6998252113337041462",
"call_log_ids": [
"6afdf3e3-87e3-47d0-834c-6ee3598e3b96",
"6afdf3e3-87e3-47d0-834c-6ee3598e3b00"
],
"created_time": "2023-10-08T16:12:04Z",
"modified_time": "2023-10-08T16:12:04Z"
"modified_time": "2023-10-08T16:13:05Z"
}
},
"event_ts": 1724455515040
}
}
26 changes: 13 additions & 13 deletions Source/ZoomNet.UnitTests/WebhookData/phone.conference_started.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"event" : "phone.conference_started",
"event_ts" : 1626759486127,
"payload" : {
"account_id" : "2TP-coFVSnmyvYZogk8gAg",
"object" : {
"event": "phone.conference_started",
"event_ts": 1626230691572,
"payload": {
"account_id": "AAAAAABBBB",
"object": {
"failure_reason": "",
"call_id" : "6986878782238080581",
"call_id": "6998252113337041462",
"enable_multiple_party_conference": true,
"conference_id": "2074969d-621f-41d3-890c-8a44a03fa3e0",
"owner" : {
"type" : "user",
"id" : "z8yCxjabcdEFGHfp8uQ",
"name" : "usersubsetting0001",
"extension_number": 6666
},
"date_time" : "2021-07-20T05:38:04Z"
"owner": {
"type": "user",
"id": "z8yCxjabcdEFGHfp8uQ",
"name": "Jill Chill",
"extension_number": 6666
},
"date_time": "2021-07-13T21:44:51Z"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"event": "phone.device_registration",
"event_ts": 1626230691572,
"payload": {
"account_id": "TQTvjT52Tmi_wrhASNNOEw",
"account_id": "AAAAAABBBB",
"object": {
"device_id": "JOZmuJ30Spyrw-v9vUzIrA",
"device_name": "New_DeskPhone",
"mac_address": "012345678912"
}
},
"event_ts": 1625034680324
}
}
}
}
Loading