Skip to content

Commit

Permalink
Numbers KDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Sep 4, 2024
1 parent 5044c0b commit 575c9e4
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/main/kotlin/com/vonage/client/kt/Numbers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,78 @@ import com.vonage.client.numbers.*
*/
class Numbers internal constructor(private val client: NumbersClient) {

/**
* Call this method to work with an existing number.
*
* @param countryCode The two-character country code of the number.
* @param msisdn The phone number in E.164 format.
*
* @return An [ExistingNumber] object with methods to interact with the number.
*/
fun number(countryCode: String, msisdn: String) = ExistingNumber(countryCode, msisdn)

/**
* Class for working with an existing number.
*
* @property countryCode The two-character country code of the number.
* @property msisdn The phone number in E.164 format.
*/
inner class ExistingNumber internal constructor(val countryCode: String, val msisdn: String) {

/**
* Purchase the number.
*
* @param targetApiKey (OPTIONAL) The API key of the subaccount to assign the number to.
* If unspecified (the default), the action will be performed on the main account.
*
* @throws [NumbersResponseException] If the number could not be purchased.
*/
fun buy(targetApiKey: String? = null): Unit =
client.buyNumber(countryCode, msisdn, targetApiKey)

/**
* Cancel the number.
*
* @param targetApiKey (OPTIONAL) The API key of the subaccount to cancel the number on.
* If unspecified (the default), the action will be performed on the main account.
*
* @throws [NumbersResponseException] If the number could not be cancelled.
*/
fun cancel(targetApiKey: String? = null): Unit =
client.cancelNumber(countryCode, msisdn, targetApiKey)

/**
* Update the number's assignment on your account.
*
* @param properties A lambda function for specifying the properties to update.
*
* @throws [NumbersResponseException] If the number could not be updated.
*/
fun update(properties: UpdateNumberRequest.Builder.() -> Unit): Unit =
client.updateNumber(UpdateNumberRequest.builder(msisdn, countryCode).apply(properties).build())
}

/**
* List numbers owned by the account.
*
* @param filter (OPTIONAL) A lambda function for specifying the filter properties.
*
* @return A [ListNumbersResponse] object containing the list of owned numbers.
*
* @throws [NumbersResponseException] If the list could not be retrieved.
*/
fun listOwned(filter: ListNumbersFilter.Builder.() -> Unit = {}): ListNumbersResponse =
client.listNumbers(ListNumbersFilter.builder().apply(filter).build())

/**
* Search for numbers that are available to purchase.
*
* @param filter A lambda function for specifying the search filter properties.
*
* @return A [SearchNumbersResponse] object containing the list of available numbers.
*
* @throws [NumbersResponseException] If the search request could not be completed.
*/
fun searchAvailable(filter: SearchNumbersFilter.Builder.() -> Unit): SearchNumbersResponse =
client.searchNumbers(SearchNumbersFilter.builder().apply(filter).build())
}
1 change: 1 addition & 0 deletions src/main/kotlin/com/vonage/client/kt/Video.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Video(private val client: VideoClient) {

fun session(sessionId: String): ExistingSession = ExistingSession(sessionId)


inner class ExistingSession internal constructor(id: String): ExistingResource(id) {

fun stream(streamId: String): ExistingStream = ExistingStream(streamId)
Expand Down

0 comments on commit 575c9e4

Please sign in to comment.