Copy
grpcurl \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '
{
"destination": {
"name": "Some routing destination",
"routingCode": "C1234"
}
}
' \
sandbox.api.shamrock.wgtwo.com:443 \
wgtwo.number_portability.v1.RoutingDestinationService/CreateOrUpdateDestination
Copy
package com.example.numberPortability
import com.wgtwo.api.v1.number_portability.RoutingDestinationServiceGrpcKt
import com.wgtwo.api.v1.number_portability.createOrUpdateDestinationRequest
import com.wgtwo.api.v1.number_portability.routingDestination
import io.grpc.ManagedChannelBuilder
import io.grpc.Status
import io.grpc.StatusException
import kotlinx.coroutines.runBlocking
import java.util.UUID.randomUUID
import kotlin.test.assertFailsWith
private val channel = ManagedChannelBuilder.forAddress("sandbox.api.shamrock.wgtwo.com", 443).build()
private val stub = RoutingDestinationServiceGrpcKt.RoutingDestinationServiceCoroutineStub(channel)
fun main() = runBlocking {
val createOrUpdateDestinationRequest = createOrUpdateDestinationRequest {
destination = routingDestination {
id = randomUUID().toString()
name = "Some routing destination"
routingCode = "C1234"
}
}
println("createOrUpdateDestinationRequest:
$createOrUpdateDestinationRequest")
val createOrUpdateDestinationResponse = stub.createOrUpdateDestination(createOrUpdateDestinationRequest)
println("createOrUpdateDestinationResponse:
$createOrUpdateDestinationResponse")
val createOrUpdateDestinationRequestWithoutRoutingCode = createOrUpdateDestinationRequest {
destination = routingDestination {
id = randomUUID().toString()
name = "Some routing destination without routing code"
}
}
println("createOrUpdateDestinationRequestWithoutRoutingCode:
$createOrUpdateDestinationRequestWithoutRoutingCode")
val exception = assertFailsWith<StatusException>("exception is not a StatusException") {
stub.createOrUpdateDestination(createOrUpdateDestinationRequestWithoutRoutingCode)
}
assert(exception.status.code == Status.INVALID_ARGUMENT.code) {
"status code is not INVALID_ARGUMENT: ${exception.status.code}"
}
}