Mobile Order API
Documentation
The documentation is for the latest version of SDK, currently 0.0.1
See release notes Release version
Getting started
Add the dependency
<dependencies> <dependency> <groupId>no.telenor.sdk</groupId> <artifactId>business-mobileorder-sdk</artifactId> <version>0.0.1</version> </dependency></dependencies>
implementation("no.telenor.sdk:business-mobileorder-sdk:0.0.1")
Start coding
Create a Java class ex. CustomMobileOrderSubscription to initiate MobileOrderSdk.
import no.telenor.sdk.business.MobileOrderSdk;
public class CustomMobileOrderSubscription {
private MobileOrderSdk mobileOrderSdk;
pubilc CustomMobileOrderSubscription(String clientId, String clientSecret, String username, String password) { mobileOrderSdk = new MobileOrderSdk() .setApiClientAndResourceOwnerCredentials(clientId, clientSecret, username, password); }
}
public class CustomMobileOrderSubscription{ MobileOrderSdk mobileOrderSdk;
public CustomMobileOrderSubscription(string clientId, string clientSecret, string username, string password) { mobileOrderSdk = new MobileOrderSdk() .SetApiClientAndResourceOwnerCredentials(clientId, clientSecret, username, password); }
}
Create a method
Create a method that can run a sdk method from initiated mobileOrderSdk instance.
/* This method will return the organization object. And shall execute the Organization api with endpoint
Get all organizations get .../organizations/v1/organizations Get all organizations that are available for the current user. Use the 'pageSize' and 'page' parameters to adjust the number of organizations to return. The response has HTTP headers 'X-total-count' and 'X-count' which contain the total number of organizations found, and the number of organizations returned in the response.
https://developer.telenor.no/consumer/applications/46ceb292-d73a-4e59-a5e0-2bd28808f098/documentation/prod#get-/organizations/v1/organizations*/public void getOrganizations() throws ApiException { try { List<OrganizationsV1Organization> organizations = mobileOrderSdk.organizationsV1Api().getOrganizations(null, null, null); organizations.forEach(System.out::println); } catch (ApiRuntimeException e) { System.out.println(e.getErrorResponse()); }}
/*This method will return the organization object. And shall execute the Organization api with endpoint
Get all organizations get .../organizations/v1/organizations Get all organizations that are available for the current user. Use the 'pageSize' and 'page' parameters to adjust the number of organizations to return. The response has HTTP headers 'X-total-count' and 'X-count' which contain the total number of organizations found, and the number of organizations returned in the response.
https://developer.telenor.no/consumer/applications/46ceb292-d73a-4e59-a5e0-2bd28808f098/documentation/prod#get-/organizations/v1/organizations*/public void GetOrganizations(){ try { List<OrganizationsV1Organization> organizations = mobileOrderSdk.OrganizationsV1Api().GetOrganizations(null, null, null); organizations.ForEach(Console.WriteLine); } catch (ApiRuntimeException e) { Console.WriteLine(e.ErrorResponse); }}
Create a main method to test the call from getOrganizations().
public void main(String[] args){ String clientId = ""; String clientSecret = ""; String username = ""; String password = "";
CustomMobileOrderSubscription order = CustomMobileOrderSubscription.getInstance(clientId, clientSecret, username, password); order.getOrganizations();
}
public static void Main(string[] args){ string clientId = ""; string clientSecret = ""; string username = ""; string password = "";
CustomMobileOrderSubscription order = CustomMobileOrderSubscription.GetInstance(clientId, clientSecret, username, password); order.GetOrganizations();
}
This will respond a list of data object with object content.
Ex.
class OrganizationsV1Organization { orgNumber: "organizationNumber" name: "Organization Name" }
EXAMPLES
Create a new subscription order.
/*Create a new subscription orderpost .../corporate-mobile-subscriptions/v2/ordersGeneric resource for sending orders for new or existing subscriptions. The payload must be a JSON object that has a 'type' field, and a set of extra fields depending on the order type.
https://developer.telenor.no/consumer/applications/46ceb292-d73a-4e59-a5e0-2bd28808f098/documentation/prod#post-/corporate-mobile-subscriptions/v2/orders*/
/*** order subscription for personal user with new sim*/public CorporateMobileSubscriptionsV2OrderResponse orderNewSubscriptionWithNewSimCardOrder() throws ApiException {
List<AddOnProductId> addOnProductIds = new ArrayList<>(); addOnProductIds.add(new AddOnProductId().productId("665"));
Address address = new Address(); address.setStreetName("Møllerveien"); address.setStreetNumber("26"); address.setPostalCode("7052"); address.setPostalPlace("Trondheim");
CustomAddress customAddress = new CustomAddress(); customAddress.setFirstName("John"); customAddress.setLastName("Doe"); customAddress.setAddress(address);
SubscriptionOrderPersonalUserNewSim subscriptionOrderPersonalUserNewSim = new SubscriptionOrderPersonalUserNewSim(); subscriptionOrderPersonalUserNewSim.setType(SubscriptionOrderPersonalUserNewSim.TypeEnum.SUBSCRIPTION_PERSONAL_USER_NEW_SIM); subscriptionOrderPersonalUserNewSim.setSubscriptionTypeId("77037"); subscriptionOrderPersonalUserNewSim.accountId("7563837"); subscriptionOrderPersonalUserNewSim.setAddOnProducts(addOnProductIds); subscriptionOrderPersonalUserNewSim.setSimCardForm(SubscriptionOrderPersonalUserNewSim.SimCardFormEnum.DEFAULT); subscriptionOrderPersonalUserNewSim.setCustomAddress(customAddress);
PersonalUser personalUser = new PersonalUser(); LookupPerson person = new LookupPerson(); person.setFirstName("John"); person.setLastName("Doe"); person.birthDate("1973-11-20");
personalUser.setPerson(person); personalUser.setPostalCode("7052");
subscriptionOrderPersonalUserNewSim.setPersonalUser(personalUser);
Order requestOrder = new Order(subscriptionOrderPersonalUserNewSim); return mobileOrderSdk.mobileSubscriptionsV2Api().orderCorporateMobileSubscriptionsV2(requestOrder);
}
/* * if Account is needed */public Account getAccount(String orgno) throws ApiException { //fetch available accounts and select account to use. List<Account> accounts = mobileOrderSdk.accountsV2Api().getAccounts(Arrays.asList(orgno), null, null, null, null, null, null, null); Account account = accounts.stream().findFirst().orElseThrow( () -> new IllegalStateException("No account found for orgno: " + orgno) );
return account;}
/* * if SubscriptionType is needed */public SubscriptionTypeDetails getSubscriptionType(String orgno) throws ApiException { //SubscriptionType are also needed. List<SubscriptionTypeDetails> subscriptionTypes = mobileOrderSdk.mobileSubscriptionsV2Api().getSubscriptionTypes(orgno, null, null, null, null); SubscriptionTypeDetails subscriptionTypeDetails = subscriptionTypes.stream().findFirst().orElseThrow( () -> new IllegalStateException("No subscription type found for orgno: " + orgno) );
return subscriptionTypeDetails;}
/* Create a new subscription order post .../corporate-mobile-subscriptions/v2/orders Generic resource for sending orders for new or existing subscriptions. The payload must be a JSON object that has a 'type' field, and a set of extra fields depending on the order type.
https://developer.telenor.no/consumer/applications/46ceb292-d73a-4e59-a5e0-2bd28808f098/documentation/prod#post-/corporate-mobile-subscriptions/v2/orders*/
/** Input of account and subscriptionType*/public CorporateMobileSubscriptionsV2OrderResponse ValidateNewSubscriptionWithNewSimCardOrder(){ List<AddOnProductId> addOnProductIds = new List<AddOnProductId>(); addOnProductIds.Add(new AddOnProductId().ProductId("665"));
Address address = new Address { StreetName = "Dr. Sandsveg", StreetNumber = "26", PostalCode = "7052", PostalPlace = "Trondheim" };
CustomAddress customAddress = new CustomAddress { FirstName = "John Andre", LastName = "Tran", Address = address };
SubscriptionOrderPersonalUserNewSim subscriptionOrderPersonalUserNewSim = new SubscriptionOrderPersonalUserNewSim { Type = SubscriptionOrderPersonalUserNewSim.TypeEnum.SUBSCRIPTION_PERSONAL_USER_NEW_SIM, SubscriptionTypeId = "77037", AccountId = "7563837", AddOnProducts = addOnProductIds, SimCardForm = SubscriptionOrderPersonalUserNewSim.SimCardFormEnum.DEFAULT, CustomAddress = customAddress };
PersonalUser personalUser = new PersonalUser(); LookupPerson person = new LookupPerson { FirstName = "Erik", LastName = "Thrane" }; person.BirthDate("1993-10-10");
personalUser.Person = person; personalUser.PostalCode = "7092";
subscriptionOrderPersonalUserNewSim.PersonalUser = personalUser;
Order requestOrder = new Order(subscriptionOrderPersonalUserNewSim); CorporateMobileSubscriptionsV2OrderResponse orderResponse = mobileOrderSdk.MobileSubscriptionsV2Api().OrderCorporateMobileSubscriptionsV2(requestOrder); if (!orderValidated.Success) { foreach (var errorItem in orderValidated.ErrorItems) { Console.WriteLine(errorItem); } } else { Console.WriteLine("Order validated successfully"); }}
using System;using System.Collections.Generic;using System.Linq;
public class YourClassName{ /* * if Account is needed */ public Account GetAccount(string orgno) { //fetch available accounts and select account to use. List<Account> accounts = mobileOrderSdk.AccountsV2Api().GetAccounts(new List<string> { orgno }, null, null, null, null, null, null, null); Account account = accounts.FirstOrDefault() ?? throw new InvalidOperationException("No account found for orgno: " + orgno);
return account; }
/* * if SubscriptionType is needed */ public SubscriptionTypeDetails GetSubscriptionType(string orgno) { //SubscriptionType are also needed. List<SubscriptionTypeDetails> subscriptionTypes = mobileOrderSdk.MobileSubscriptionsV2Api().GetSubscriptionTypes(orgno, null, null, null, null); SubscriptionTypeDetails subscriptionTypeDetails = subscriptionTypes.FirstOrDefault() ?? throw new InvalidOperationException("No subscription type found for orgno: " + orgno);
return subscriptionTypeDetails; }}
Create porting subscription order.
/*Create a new subscription orderpost .../corporate-mobile-subscriptions/v2/ordersGeneric resource for sending orders for new or existing subscriptions. The payload must be a JSON object that has a 'type' field, and a set of extra fields depending on the order type.
https://developer.telenor.no/consumer/applications/46ceb292-d73a-4e59-a5e0-2bd28808f098/documentation/prod#post-/corporate-mobile-subscriptions/v2/orders*/
/*** Input of account and subscriptionType*/public CorporateMobileSubscriptionsV2OrderResponse createNewSubscriptionPortingNumberPersonal(Account account, SubscriptionTypeDetails subscriptionTypeDetails) throws ApiException { try { List<AddOnProductId> addOnProductIds = new ArrayList<>(); addOnProductIds.add(new AddOnProductId().productId("665"));
PortingOrderPersonalUserActivateSim portingOrderPersonalUserActivateSim = new PortingOrderPersonalUserActivateSim(); portingOrderPersonalUserActivateSim.setType(PortingOrderPersonalUserActivateSim.TypeEnum.PORT_NUMBER_PERSONAL_USER_ACTIVATE_SIM); portingOrderPersonalUserActivateSim.setSubscriptionTypeId(subscriptionTypeDetails.getId().toString()); portingOrderPersonalUserActivateSim.setAccountId(account.getId());
portingOrderPersonalUserActivateSim.setAddOnProducts(addOnProductIds); portingOrderPersonalUserActivateSim.setUserReference1( "482930/OLA NORDMANN"); portingOrderPersonalUserActivateSim.setUserReference2("SERVICE DESK"); portingOrderPersonalUserActivateSim.setUserReference3("OLA NORDMANN"); portingOrderPersonalUserActivateSim.setIccId(iccId); portingOrderPersonalUserActivateSim.setMsisdn(msisdn);
setPersonalUser(portingOrderPersonalUserActivateSim); setCurrentOwner(portingOrderPersonalUserActivateSim);
portingOrderPersonalUserActivateSim.setNewOwnerConsentMsisdn(msisdn); portingOrderPersonalUserActivateSim.setPortDate("04.01.2025"); portingOrderPersonalUserActivateSim.setRegisteredBy("Per Nordmann");
//Create request order object. Order requestOrder = new Order(portingOrderPersonalUserActivateSim);
//Executing order call return mobileOrderSdk.mobileSubscriptionsV2Api().orderCorporateMobileSubscriptionsV2(requestOrder);
} catch (ApiRuntimeException e) { throw e; }}
private void setPersonalUser(PortingOrderPersonalUserActivateSim portingOrderPersonalUserActivateSim) { LookupPerson person1 = new LookupPerson(); person1.setFirstName("John"); person1.setMiddleName("Joe"); person1.setLastName("Doe"); person1.birthDate("01.08.2000");
PersonalUser personUser = new PersonalUser(); personUser.setPerson(person1); portingOrderPersonalUserActivateSim.setPersonalUser(personUser);}
private void setCurrentOwner(PortingOrderPersonalUserActivateSim portingOrderPersonalUserActivateSim) { CurrentOwner currentOwner = new CurrentOwner(); LookupPerson person = new LookupPerson(); person.setFirstName("John"); person.setMiddleName("Joe"); person.setLastName("Doe"); person.birthDate("01.08.2000");
PersonalOwner personalOwner = new PersonalOwner().person(person); personalOwner.setPostalCode("0022"); personalOwner.setSocialSecurityNumber("12345678910");
currentOwner.setPersonalOwner(personalOwner);
OrganizationalOwner organizationalOwner = new OrganizationalOwner(); organizationalOwner.setOrgNumber(orgno); organizationalOwner.setConsentMsisdn(msisdn);
currentOwner.setOrganizationalOwner(organizationalOwner);
portingOrderPersonalUserActivateSim.setCurrentOwner(currentOwner);}
/*Create a new subscription orderpost .../corporate-mobile-subscriptions/v2/ordersGeneric resource for sending orders for new or existing subscriptions. The payload must be a JSON object that has a 'type' field, and a set of extra fields depending on the order type.
https://developer.telenor.no/consumer/applications/46ceb292-d73a-4e59-a5e0-2bd28808f098/documentation/prod#post-/corporate-mobile-subscriptions/v2/orders*/
/*** Input of account and subscriptionType*/public CorporateMobileSubscriptionsV2OrderResponse CreateNewSubscriptionPortingNumberPersonal(Account account, SubscriptionTypeDetails subscriptionTypeDetails){ try { List<AddOnProductId> addOnProductIds = new List<AddOnProductId>(); addOnProductIds.Add(new AddOnProductId().ProductId("665"));
PortingOrderPersonalUserActivateSim portingOrderPersonalUserActivateSim = new PortingOrderPersonalUserActivateSim(); portingOrderPersonalUserActivateSim.SetType(PortingOrderPersonalUserActivateSim.TypeEnum.PORT_NUMBER_PERSONAL_USER_ACTIVATE_SIM); portingOrderPersonalUserActivateSim.SetSubscriptionTypeId(subscriptionTypeDetails.GetId().ToString()); portingOrderPersonalUserActivateSim.SetAccountId(account.GetId());
portingOrderPersonalUserActivateSim.SetAddOnProducts(addOnProductIds); portingOrderPersonalUserActivateSim.SetUserReference1("482930/OLA NORDMANN"); portingOrderPersonalUserActivateSim.SetUserReference2("SERVICE DESK"); portingOrderPersonalUserActivateSim.SetUserReference3("OLA NORDMANN"); portingOrderPersonalUserActivateSim.SetIccId(iccId); portingOrderPersonalUserActivateSim.SetMsisdn(msisdn);
SetPersonalUser(portingOrderPersonalUserActivateSim); SetCurrentOwner(portingOrderPersonalUserActivateSim);
portingOrderPersonalUserActivateSim.SetNewOwnerConsentMsisdn(msisdn); portingOrderPersonalUserActivateSim.SetPortDate("04.01.2025"); portingOrderPersonalUserActivateSim.SetRegisteredBy("Per Nordmann");
//Create request order object. Order requestOrder = new Order(portingOrderPersonalUserActivateSim);
//Executing order call return mobileOrderSdk.MobileSubscriptionsV2Api().OrderCorporateMobileSubscriptionsV2(requestOrder); } catch (ApiRuntimeException e) { throw e; }}
private void SetPersonalUser(PortingOrderPersonalUserActivateSim portingOrderPersonalUserActivateSim){ LookupPerson person1 = new LookupPerson(); person1.SetFirstName("John"); person1.SetMiddleName("Joe"); person1.SetLastName("Doe"); person1.BirthDate("01.08.2000");
PersonalUser personUser = new PersonalUser(); personUser.SetPerson(person1); portingOrderPersonalUserActivateSim.SetPersonalUser(personUser);}
private void SetCurrentOwner(PortingOrderPersonalUserActivateSim portingOrderPersonalUserActivateSim) { CurrentOwner currentOwner = new CurrentOwner(); LookupPerson person = new LookupPerson(); person.FirstName = "John"; person.MiddleName = "Joe"; person.LastName = "Doe"; person.BirthDate = "01.08.2000";
PersonalOwner personalOwner = new PersonalOwner { Person = person }; personalOwner.PostalCode = "0022"; personalOwner.SocialSecurityNumber = "12345678910";
currentOwner.PersonalOwner = personalOwner;
OrganizationalOwner organizationalOwner = new OrganizationalOwner(); organizationalOwner.OrgNumber = orgno; organizationalOwner.ConsentMsisdn = msisdn;
currentOwner.OrganizationalOwner = organizationalOwner;
portingOrderPersonalUserActivateSim.CurrentOwner = currentOwner;}
Create transfer number subscription order.
/*Create a new subscription orderpost .../corporate-mobile-subscriptions/v2/ordersGeneric resource for sending orders for new or existing subscriptions. The payload must be a JSON object that has a 'type' field, and a set of extra fields depending on the order type.
https://developer.telenor.no/consumer/applications/46ceb292-d73a-4e59-a5e0-2bd28808f098/documentation/prod#post-/corporate-mobile-subscriptions/v2/orders*//*** Input of subscriptionType*/public CorporateMobileSubscriptionsV2OrderResponse createNewSubscriptionTransferOrder(CustomMobileOrderSubscription order, SubscriptionTypeDetails subscriptionTypeDetails) throws ApiException {
List<AddOnProductId> addOnProductIds = new ArrayList<>(); addOnProductIds.add(new AddOnProductId().productId("665")); //exampleProduct
TransferOrderPersonalOwner transferPersonalOwner = new TransferOrderPersonalOwner(); transferPersonalOwner.setType(TransferOrderPersonalOwner.TypeEnum.TRANSFER_NUMBER_PERSONAL_OWNER); transferPersonalOwner.setSubscriptionTypeId(subscriptionTypeDetails.getId().toString()); transferPersonalOwner.setMsisdn(msisdn); transferPersonalOwner.setSubscriptionId(0); transferPersonalOwner.setCurrentOwnerConsentMsisdn("4790943254"); transferPersonalOwner.setRegisteredBy("Per Nordmann"); transferPersonalOwner.orderProcessingDate( "2025-01-85T12:00+01:00");
Order requestOrder = new Order(transferPersonalOwner);
return mobileOrderSdk.mobileSubscriptionsV2Api().orderCorporateMobileSubscriptionsV2(requestOrder);}
Create remove a subscription order.
public CorporateMobileSubscriptionsV2OrderResponse createRemoveSubscriptionOrder(CustomMobileOrderSubscription subscriptionOrder) throws ApiException { try { DeleteSubscriptionOrder order = new DeleteSubscriptionOrder();
order.setType(DeleteSubscriptionOrder.TypeEnum.REMOVE_SUBSCRIPTION); order.setMsisdn(msisdn); order.setSubscriptionId(0); order.setOrderProcessingDate("2021-02-25T12:00+01:00");
CorporateMobileSubscriptionsV2Order requestOrder = new CorporateMobileSubscriptionsV2Order(order); return mobileOrderSdk.mobileSubscriptionsV2Api().orderCorporateMobileSubscriptionsV2(requestOrder);
} catch (ApiRuntimeException e) { System.out.println(e.getErrorResponse()); throw e; }}
HTTP Handlers
By using SDK for calling Rest API, it may throw an ApiRuntimeException at runtime. This exception contains an ErrorResponse object containing following fields.
- resourceId --- Api name
- httpMessage --- HttpMessage
- requestId --- RequestRefId. UUID
- httpStatus --- HttpCode
- description --- Message for this error
- errorCode --- Internal errorCode
Exception
public AccountDetails getAccount() throws ApiException { String accountNo = "34"; try { return mobileOrderSdk.accountsV2Api().getAccount(accountNo); } catch (ApiRuntimeException e) {
System.out.println("HttpCode: " + e.getCode()); System.out.println("Reason : " + e.getMessage());
System.out.println(); System.out.println("ErrorResponse object: " + e.getErrorResponse());
System.out.println(); System.out.println("PrintStackTrace: "); e.printStackTrace();
throw e; }}
public AccountDetails GetAccount(){ string accountNo = "34"; try{ return subscription.AccountsV2Api().GetAccount(accountNo); }catch (ApiRuntimeException e) { Console.WriteLine("HttpCode: " + e.Code); Console.WriteLine("Reason : " + e.Message);
Console.WriteLine(); Console.WriteLine("ErrorResponse object: " + e.ErrorResponse);
Console.WriteLine(); Console.WriteLine("PrintStackTrace: "); e.PrintStackTrace();
throw; }}
Responded exception values:
HttpCode: 404Reason : Not Found
ErrorResponse object: class ErrorResponse { resourceId: corporate-accounts-v2 httpMessage: Not Found requestId: c85bb5d0-39fa-4657-88f3-1371bccdf17a httpStatus: 404 description: Account not found errorCode: 404004}
PrintStackTrace:responses.exceptions.no.telenor.sdk.business.ApiRuntimeException: Not Found at responses.exceptions.no.telenor.sdk.business..CommonResponseHandling.toClient(CommonResponseHandling.java:29) at responses.exceptions.no.telenor.sdk.business..RestActionHandlingFactory.toClient(RestActionHandlingFactory.java:44) at no.telenor.sdk.business.TelenorApiClient.invokeAPI(TelenorApiClient.java:146) at api.client.order.mobile.no.telenor.sdk.business.CorporateAccountsV2Api.getAccountWithHttpInfo(CorporateAccountsV2Api.java:224) at api.client.order.mobile.no.telenor.sdk.business.CorporateAccountsV2Api.getAccount(CorporateAccountsV2Api.java:188) at examples.no.telenor.sdk.CustomMobileOrderSubscription.getAccount(CustomMobileOrderSubscription.java:47) at no.telenor.sdk.Main.main(Main.java:46)
Picture below shows what exception e contains, when exception has been thrown.

Release version
20250314 - 0.0.1: Contains only MobileOrder