Skip to content

Commit

Permalink
fix: Deprecate NumberInsight realTimeData
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Jan 31, 2025
1 parent c308ec2 commit 33a9234
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
23 changes: 22 additions & 1 deletion src/main/kotlin/com/vonage/client/kt/NumberInsight.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,33 @@ class NumberInsight internal constructor(private val client: InsightClient) {
*
* @return Advanced details about the number and insight metadata.
*/
@Deprecated("`realTimeData` is deprecated and will be removed in a future release.")
fun advanced(number: String, countryCode: String? = null, cnam: Boolean = false,
realTimeData: Boolean = false): AdvancedInsightResponse =
realTimeData: Boolean): AdvancedInsightResponse =
client.getAdvancedNumberInsight(AdvancedInsightRequest.builder().async(false)
.number(number).country(countryCode).cnam(cnam).realTimeData(realTimeData).build()
)

/**
* Obtain advanced insight about a number synchronously. This is not recommended due to potential timeouts.
*
* @param number The phone number to look up in E.164 format.
*
* @param countryCode (OPTIONAL) The two-character country code in ISO 3166-1 alpha-2 format.
*
* @param cnam (OPTIONAL) Whether the name of the person who owns the phone number should be looked up
* and returned in the response. Set to true to receive phone number owner name in the response. This
* feature is available for US numbers only and incurs an additional charge.
*
* @return Advanced details about the number and insight metadata.
*
* @since 1.1.3
*/
fun advanced(number: String, countryCode: String? = null, cnam: Boolean = false): AdvancedInsightResponse =
client.getAdvancedNumberInsight(AdvancedInsightRequest.builder().async(false)
.number(number).country(countryCode).cnam(cnam).build()
)

/**
* Obtain advanced insight about a number asynchronously. This is recommended to avoid timeouts.
*
Expand Down
16 changes: 14 additions & 2 deletions src/test/kotlin/com/vonage/client/kt/NumberInsightTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ class NumberInsightTest : AbstractTest() {
BASIC, STANDARD, ADVANCED, ADVANCED_ASYNC
}

private fun mockInsight(type: InsightType, optionalParams: Boolean = false) {
private fun mockInsight(type: InsightType, optionalParams: Boolean = false, includeRtd: Boolean = false) {
val expectedRequestParams = mutableMapOf<String, Any>("number" to toNumber)
if (optionalParams) {
expectedRequestParams["country"] = countryCode
if (type != InsightType.BASIC) {
expectedRequestParams["cnam"] = cnam
}
if (type == InsightType.ADVANCED) {
if (includeRtd) {
expectedRequestParams["real_time_data"] = realTimeData
}
}
Expand Down Expand Up @@ -262,9 +262,21 @@ class NumberInsightTest : AbstractTest() {
@Test
fun `advanced insight all params`() {
mockInsight(InsightType.ADVANCED, true)
assertAdvancedResponse(client.advanced(toNumber, countryCode, cnam))
}

@Test
fun `advanced insight real time data all params`() {
mockInsight(InsightType.ADVANCED, true, true)
assertAdvancedResponse(client.advanced(toNumber, countryCode, cnam, realTimeData))
}

@Test
fun `advanced insight real time data required params`() {
mockInsight(InsightType.ADVANCED, false, true)
assertAdvancedResponse(client.advanced(toNumber, realTimeData = realTimeData))
}

@Test
fun `advanced async insight required params`() {
mockInsight(InsightType.ADVANCED_ASYNC, false)
Expand Down

0 comments on commit 33a9234

Please sign in to comment.