Vonage / vonage-java-sdk

Vonage Server SDK for Java. API support for SMS, Messages, Voice, Text-to-Speech, Numbers, Verify (2FA), Video and more.
https://developer.vonage.com/en/home
Apache License 2.0
95 stars 119 forks source link

feat: Reimplement webhooks for Voice API #506

Closed SMadani closed 6 months ago

SMadani commented 6 months ago

The current implementation of webhooks for Voice in the com.vonage.client.incoming.* package is incomplete as described in #475. Furthermore, it requires a priori knowledge of the event type, which further devalues the classes since some form of parsing is needed to determine the correct class to map the JSON payload to. This PR aims to follow the same approach as the implementations for Messages and Verify v2: use a single class for each inbound URL. That way, the user can simply call the fromJson method on a single class based on which URL is hit, and obtain the relevant fields based on the event type.

codecov-commenter commented 6 months ago

Codecov Report

Merging #506 (3854fcf) into main (8b34038) will decrease coverage by 0.03%. The diff coverage is 92.92%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #506 +/- ## ============================================ - Coverage 94.22% 94.19% -0.03% - Complexity 2797 2854 +57 ============================================ Files 405 413 +8 Lines 6748 6842 +94 Branches 444 445 +1 ============================================ + Hits 6358 6445 +87 - Misses 203 204 +1 - Partials 187 193 +6 ``` | [Files](https://app.codecov.io/gh/Vonage/vonage-java-sdk/pull/506?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vonage) | Coverage Δ | | |---|---|---| | [...java/com/vonage/client/incoming/CallDirection.java](https://app.codecov.io/gh/Vonage/vonage-java-sdk/pull/506?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vonage#diff-c3JjL21haW4vamF2YS9jb20vdm9uYWdlL2NsaWVudC9pbmNvbWluZy9DYWxsRGlyZWN0aW9uLmphdmE=) | `100.00% <100.00%> (ø)` | | | [...ain/java/com/vonage/client/incoming/CallEvent.java](https://app.codecov.io/gh/Vonage/vonage-java-sdk/pull/506?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vonage#diff-c3JjL21haW4vamF2YS9jb20vdm9uYWdlL2NsaWVudC9pbmNvbWluZy9DYWxsRXZlbnQuamF2YQ==) | `100.00% <ø> (ø)` | | | [...in/java/com/vonage/client/incoming/CallStatus.java](https://app.codecov.io/gh/Vonage/vonage-java-sdk/pull/506?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vonage#diff-c3JjL21haW4vamF2YS9jb20vdm9uYWdlL2NsaWVudC9pbmNvbWluZy9DYWxsU3RhdHVzLmphdmE=) | `100.00% <100.00%> (ø)` | | | [...a/com/vonage/client/incoming/CallStatusDetail.java](https://app.codecov.io/gh/Vonage/vonage-java-sdk/pull/506?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vonage#diff-c3JjL21haW4vamF2YS9jb20vdm9uYWdlL2NsaWVudC9pbmNvbWluZy9DYWxsU3RhdHVzRGV0YWlsLmphdmE=) | `100.00% <100.00%> (ø)` | | | [...in/java/com/vonage/client/incoming/DtmfResult.java](https://app.codecov.io/gh/Vonage/vonage-java-sdk/pull/506?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vonage#diff-c3JjL21haW4vamF2YS9jb20vdm9uYWdlL2NsaWVudC9pbmNvbWluZy9EdG1mUmVzdWx0LmphdmE=) | `100.00% <ø> (ø)` | | | [...in/java/com/vonage/client/incoming/InputEvent.java](https://app.codecov.io/gh/Vonage/vonage-java-sdk/pull/506?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vonage#diff-c3JjL21haW4vamF2YS9jb20vdm9uYWdlL2NsaWVudC9pbmNvbWluZy9JbnB1dEV2ZW50LmphdmE=) | `100.00% <ø> (ø)` | | | [...n/java/com/vonage/client/incoming/RecordEvent.java](https://app.codecov.io/gh/Vonage/vonage-java-sdk/pull/506?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vonage#diff-c3JjL21haW4vamF2YS9jb20vdm9uYWdlL2NsaWVudC9pbmNvbWluZy9SZWNvcmRFdmVudC5qYXZh) | `100.00% <ø> (ø)` | | | [...c/main/java/com/vonage/client/incoming/Result.java](https://app.codecov.io/gh/Vonage/vonage-java-sdk/pull/506?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vonage#diff-c3JjL21haW4vamF2YS9jb20vdm9uYWdlL2NsaWVudC9pbmNvbWluZy9SZXN1bHQuamF2YQ==) | `100.00% <ø> (ø)` | | | [.../vonage/client/voice/AdvancedMachineDetection.java](https://app.codecov.io/gh/Vonage/vonage-java-sdk/pull/506?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vonage#diff-c3JjL21haW4vamF2YS9jb20vdm9uYWdlL2NsaWVudC92b2ljZS9BZHZhbmNlZE1hY2hpbmVEZXRlY3Rpb24uamF2YQ==) | `100.00% <100.00%> (ø)` | | | [.../main/java/com/vonage/client/voice/CallStatus.java](https://app.codecov.io/gh/Vonage/vonage-java-sdk/pull/506?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vonage#diff-c3JjL21haW4vamF2YS9jb20vdm9uYWdlL2NsaWVudC92b2ljZS9DYWxsU3RhdHVzLmphdmE=) | `100.00% <100.00%> (ø)` | | | ... and [10 more](https://app.codecov.io/gh/Vonage/vonage-java-sdk/pull/506?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vonage) | |