How to Create Porting Records

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

CreatePortingRecords is a method that allows you to create one or more porting record for specific subscriber numbers.

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

Prerequisites

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

Required Scope

No scope is required to create porting records, 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 CreatePortingRecords 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 '
  {
      "records": [
          {
              "subscriberNumber": {
                "e164": "+46712345678"
              },
              "operatorCode": "A21",
              "routingCode": "006",
              "validFrom": "2024-04-01T00:00:00Z",
              "metadata": {
                "test_key": "test_value"
              }
          }
      ]
  }
  ' \
  sandbox.api.shamrock.wgtwo.com:443 \
  wgtwo.number_portability.v1.NumberPortabilityService/CreatePortingRecords

package com.example.numberPortability

import com.google.protobuf.Timestamp
import com.google.protobuf.util.Timestamps
import com.wgtwo.api.v1.common.e164
import com.wgtwo.api.v1.number_portability.NumberPortabilityServiceGrpcKt
import com.wgtwo.api.v1.number_portability.createPortingRecordsRequest
import com.wgtwo.api.v1.number_portability.portingRecord
import io.grpc.ManagedChannelBuilder
import io.grpc.Status
import io.grpc.StatusException
import kotlinx.coroutines.runBlocking
import java.util.Date
import kotlin.test.assertFailsWith

// private val channel = ManagedChannelBuilder.forAddress("sandbox.api.shamrock.wgtwo.com", 443).build()
private val channel = ManagedChannelBuilder.forAddress("localhost", 11111).usePlaintext().build()
private val stub = NumberPortabilityServiceGrpcKt.NumberPortabilityServiceCoroutineStub(channel)

fun main() = runBlocking {
    val createPortingRecordsRequest = createPortingRecordsRequest {
        records += portingRecord {
            subscriberNumber = e164 { e164 = "+46700000001" }
            validFrom = Timestamps.fromDate(Date())
            operatorCode = "A21"
            routingCode = "010"
            metadata.put("test_key", "test_value")
        }
        records += portingRecord {
            subscriberNumber = e164 { e164 = "+46700000002" }
            validFrom = Timestamps.fromDate(Date())
            operatorCode = "C39"
            routingCode = "005"
            metadata.putAll(mapOf("test_key1" to "test_value", "test_key2" to "test_value2"))
        }
        records += portingRecord {
            subscriberNumber = e164 { e164 = "+32012345678" }
            validFrom = Timestamps.parse("2021-06-01T00:00:00.000Z")
            destinationId = "1234"
        }
    }
    println("createPortingRecordsRequest:
$createPortingRecordsRequest")

    val createPortingRecordsResponse = stub.createPortingRecords(createPortingRecordsRequest)
    println("createPortingRecordsResponse:
$createPortingRecordsResponse")

    val createPortingRecordsRequestWithInvalidSubscriberNumber = createPortingRecordsRequest {
        records += portingRecord {
            subscriberNumber = e164 { e164 = "invalid" }
            validFrom = Timestamp.newBuilder().setSeconds(System.currentTimeMillis() / 1000).build()
            operatorCode = "A21"
            routingCode = "010"
        }
    }

    val exception = assertFailsWith<StatusException>("exception is not a StatusException") {
        stub.createPortingRecords(createPortingRecordsRequestWithInvalidSubscriberNumber)
    }

    assert(exception.status.code == Status.INVALID_ARGUMENT.code) {
        "status code is not INVALID_ARGUMENT: ${exception.status.code}"
    }
}

Example Results Success

{

}

Example Results Error

ERROR:
  Code: InvalidArgument
  Message: Invalid subscriber number
Status code: INVALID_ARGUMENT
Status description: Invalid subscriber number

Read More