How to Create Routing Destination

Warning: Beta software This API is in beta stage and may be subject to change. Therefore, we do not recommend using this in production.

Interested in this feature? Please reach out to mobility-services-developer@cisco.com

CreateOrUpdateRoutingDestination is a method that allows you to create or update a routing destination.

This method is part of the Number Portability API and belongs to the RoutingDestinatinService.

Prerequisites

  1. An OAuth 2.0 client
  2. A client access token

Required Scope

No scope is required to create routing destinations, but number portability lookups will only work with products having the number_portability:provide scope.

Code Dependencies

curl -sL https://github.com/working-group-two/wgtwoapis/releases/latest/download/mobility.binpb --output mobility.binpb
<dependency>
  <groupId>com.wgtwo.api.v1.grpc</groupId>
  <artifactId>number_portability</artifactId>
  <version>1.10.1</version>
</dependency>

Code

The examples below demonstrate how to use the CreateOrUpdateRoutingDestination function.

You can test our APIs without authorization by targeting sandbox.api.shamrock.wgtwo.com instead of api.{region}.wgtwo.com and removing any authorization from the request/code sample.


#!/usr/bin/env bash
grpcurl \
  --protoset mobility.binpb \
  -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

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}"
    }
}

Example Results Success

{
  "destinationId": "0b3b37d9-06ea-4dcb-980a-d9684b63a2ae"
}
destination_id: "1e421375-02f6-49ab-85df-43568d72dc40"

Example Results Error

ERROR:
  Code: InvalidArgument
  Message: Missing routing code
Status code: INVALID_ARGUMENT
Status description: Missing routing code

Read More