AppTab is a pricing and billing tool for API users. You can generate month-wise payment bills based on the API calls, features and storage. Various payment schemes and packages can be defined here. You can also define a variety of discount offers to facilitate you App users based on the usage of features, storage and API calls.
In order to use the various functions available under a particular API, a developer will have to create an instance of ServiceAPI by passing the apiKey and the secretKey which has been received while creating an app.
ServiceAPI api = new ServiceAPI("<API_KEY>","<SECRET_KEY>");
After initialization, developer needs to call the buildXXXService method on ServiceAPI instance to get the instance of the particular API that you wish to build. For example, To build an instance of BillService, buildBillService() method needs to be called.
BillService billService = api.buildBillService()
Once the API instance has been retrieved, You are ready to use the functions available for that particular API.
The methods available under a particular API will return the user defined object (like bill in this case) as a response which will have the accessor / mutator to access the available properties for that object. You can get the response in the form of JSON as well. We have provided the JSON response with every function detail which can be retrieved by calling the toString() on the returned object.
String schemeName = "Scheme";
String packageName = "Basic";
String userName = "Nick";
int year = 2012;
Bill bill = billService.getAllUsageByMonth(schemeName,packageName,userName,BillMonth.DECEMBER,year); /* returns the Bill object. */
System.out.println("schemeName is " + = bill.getSchemeName());
System.out.println("packageName is " + = bill.getPackageName());
System.out.println("userName is " + = bill.getUserName());
System.out.println("Month is " + = bill.getMonth());
String jsonResponse = bill.toString(); /* returns the response in JSON format. */
The functions available under AppTab API can throw some exceptions in abnormal conditions. Example of the same has been given below.
E.g. If App developer is requesting for a which is not in database, the function will throw the Exception with message as "Not Found" and the appErrorCode as "4402" and the details as "Subscription with the userName into '<packageName>' does not exist".
String schemeName = "Scheme";
String packageName = "Basic";
String userName = "Nick";
int year = 2012;
try
{
Bill bill = billService.getAllUsageByMonth(schemeName, packageName, userName, BillMonth.DECEMBER, year);
}
catch( App42Exception ex )
{
int appErrorCode = ex.getAppErrorCode();
int httpErrorCode = ex.getHttpErrorCode();
if(appErrorCode == 4402)
{
// Handle here for Not Found (Subscription with the userName into '<packageName>' does not exist".)
}
else if(appErrorCode == 1401)
{
// handle here for Client is not authorized
}
else if(appErrorCode == 1500)
{
// handle here for Internal Server Error
}
String jsonText = ex.getMessage(); /* returns the Exception text in JSON format. (as shown below)*/
}
{
"app42Fault": {
"httpErrorCode": 400,
"appErrorCode": 4402,
"message": "Not Found",
"details": "Subscription with user name 'Nick' into packageName 'Basic' does not Exists."
}
}
Below are the HTTP Error Codes and their description, the function under the AppTab API can throw.
/* 1400 - BAD REQUEST - The Request parameters are invalid 1401 - UNAUTHORIZED - Client is not authorized 1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again */
Below are the Application Error Codes and their description, the function under the AppTab API can throw.
/* Scheme 4100 - BAD REQUEST - The Request parameters are invalid. Scheme by name '<schemeName>' already Exists. 4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4102 - BAD REQUEST - The Request parameters are invalid. Package by the name '<packageName>' for the Scheme '<schemeName>' already Exists. 4103 - BAD REQUEST - The request parameters are invalid. Storage by the unit can be either 'KB', 'MB', 'GB' or 'TB'. 4104 - BAD REQUEST - The request parameters are invalid. Storage by the name '<storageName>' already exists. 4105 - BAD REQUEST - The request parameters are invalid. Bandwidth by the unit can be either 'KB', 'MB', 'GB' or 'TB'. 4106 - BAD REQUEST - The request parameters are invalid. Bandwidth by the name '<bandwidthName>' already exists. 4107 - BAD REQUEST - The request parameters are invalid. Feature by the name '<featureName>' already exists. 4108 - NOT FOUND - Storage by the name '<storageName>' does not exists. 4109 - BAD REQUEST - The request parameters are invalid. Storage with currency '<currency>' should be same as package currency '<currency>'. 4110 - BAD REQUEST - The request parameters are invalid. Storage by the name '<storageName>' with Package '<packageName>' in scheme '<schemeName>' already added. 4111 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. 4112 - NOT FOUND - Bandwidth by the name '<bandwidthInName>'does not exists. 4113 - BAD REQUEST - The Request parameters are invalid.Bandwidth with currency '<currency>' should be same as package currency '<currency>'. 4114 - BAD REQUEST - The request parameters are invalid. Bandwidth by the name '<bandwidthInName>' with Package '<packageName>' in scheme '<schemeName>' already added. 4115 - NOT FOUND - Feature by the name '<featureName>' does not exist exists. 4116 - BAD REQUEST - The request parameters are invalid.Feature with currency '<currency>' should be same as package currency '<currency>'. 4117 - NOT FOUND - Packages for the Scheme '<schemeName>' does not Exists. 4118 - NOT FOUND - Storage by the name '<storageName>' with Package '<packageName>' in scheme '<schemeName>' does not exist. 4119 - NOT FOUND - Bandwidth by the name '<bandwidthName>' with Package '<packageName>' in scheme '<schemeName>' does not exist. 4120 - NOT FOUND - Schemes does not exists. Charge 4300 - BAD REQUEST - The request parameters are invalid. Storage by the name '<name>' already exists. 4301 - BAD REQUEST - The request parameters are invalid. Unit can be either 'KB', 'MB', 'GB' or 'TB'. 4302 - BAD REQUEST - The request parameters are invalid. Bandwidth by the name '<name>' already exists. 4303 - BAD REQUEST - The request parameters are invalid. Feature by the name '<name>' already exists. 4304 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4305 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists 4306 - NOT FOUND - Subscription with user name '<userName>' in to package '<packageName>' does not Exists. Subscribe 4200 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists 4201 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. 4202 - BAD REQUEST - The Request parameters are invalid. Subscription for the Service '<serviceName>'already Exists. Please Upgrade your package. 4203 - BAD REQUEST - The Request parameters are invalid. Subscription for the Service '<serviceName>' where Scheme is '<schemeName>' and Package '<packageName>' already Exists. 4204 - NOT FOUND - Subscription for User by the name '<userName>' does not Exists Bill 4400 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4401 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. 4402 - NOT FOUND - Subscription with user name '<userName>' in to packageName '<packageName>' does not Exists. 4403 - NOT FOUND - There were no transactions for the user '<userName>' for the Year'<year>' and Month '<month>'. 4404 - BAD REQUEST - The request parameters are invalid. Year should be 2011 or later. Discount 4500 - BAD REQUEST - The request parameters are invalid. Discount by name '<name>' already exists. 4501 - BAD REQUEST - The request parameters are invalid. Start date '<date>' should be less than End date '<date>'. 4502 - NOT FOUND - Discounts does not exist. 4503 - NOT FOUND - Discount by the name '<discountName>' do not exist. 4504 - NOT FOUND - Discount with promo code '<promocode>' do not exist. */
Various functions available under AppTab API has been explained below.
Create schemes that enable API users to create various packages
Parameters:
Returns:
Response: SchemeData Object
Exception:
/* 4100 - BAD REQUEST - The Request parameters are invalid. Scheme by name '<schemeName>' already Exists. */
String schemeName = "Scheme";
String description = "Created Scheme";
SchemeData schemeData = schemeService.createScheme(schemeName, description); /* returns the SchemeData object. */
System.out.println("schemeName is " + schemeData.getName());
System.out.println("description is " + schemeData.getDescription());
String jsonResponse = schemeData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"schemes": {
"scheme": {
"name": "Scheme",
"description": "Created Scheme"
}
}
}
}
}
View specific scheme details.
Parameters:
Returns:
Response: SchemeData Object
Exception:
/* 4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. */
String schemeName = "Scheme";
SchemeData schemeData = schemeService.getSchemeByName(schemeName); /* returns the SchemeData object. */
System.out.println("schemeName is " + schemeData.getName());
System.out.println("description is " + schemeData.getDescription());
String jsonResponse = schemeData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"schemes": {
"scheme": {
"name": "Scheme",
"description": "Created Scheme"
}
}
}
}
}
View details of all existing schemes.
Parameters:
Returns:
Response: ArrayList<SchemeData> Object
Exception:
/* 4120 - NOT FOUND - Schemes does not exists. */
ArrayList<SchemeData> schemeList = schemeService.getAllSchemes(); /* returns the list of SchemeData objects. */
for(SchemeData schemeData : schemeList)
{
System.out.println("schemeName is " + schemeData.getName());
System.out.println("Description is " + schemeData.getDescription());
}
String jsonResponse = schemeList.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"schemes": {
"scheme": [
{
"name": "Scheme",
"description": "Created Scheme"
},
{
"name": "Schemes",
"description": "Created Scheme"
}
]
}
}
}
}
Define the storage details and applicable charges
Parameters:
Returns:
Response: Charge Object
Exception:
/* 4301 - BAD REQUEST - The request parameters are invalid. Unit can be either 'KB', 'MB', 'GB' or 'TB'. 4300 - BAD REQUEST - The request parameters are invalid. Storage by the name '<name>' already exists. */
String storageName = "Storage Name";
BigDecimal storageSpace = new BigDecimal(1000);
BigDecimal storagePrice = new BigDecimal(100);
String description = "Created Storage";
Charge charge = chargeService.createStorageCharge(storageName,storageSpace,StorageUnit.MB,storagePrice,Currency.USD,description); /* returns the Charge object. */
Charge.Storage storage = charge.getStorage();
System.out.println("Name is " + storage.getName());
System.out.println("StorageSpace is " + storage.getSpace());
System.out.println("Unit is " + storage.getUnit());
System.out.println("Price is " + storage.getPrice());
System.out.println("Currency is " + storage.getCurrency());
String jsonResponse = charge.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"appTab": {
"usages": {
"usage": {
"storage": {
"name": "Storage Name",
"space": 1000,
"unit": "MB",
"price": 100,
"currency": "USD",
"state": "ACTIVE",
"description": "Created Storage"
}
}
}
}
}
}
}
Define the bandwidth and specify the applicable charges.
Parameters:
Returns:
Response: Charge Object
Exception:
/* 3724 - BAD REQUEST - The request parameters are invalid. Unit can be either 'KB', 'MB', 'GB' or 'TB'. 4302 - BAD REQUEST - The request parameters are invalid. Bandwidth by the name '<name>' already exists. */
String bandwidthName = "Bandwidth Name";
BigDecimal bandwidthUsage = new BigDecimal(1000);
BigDecimal bandwidthPrice = new BigDecimal(100);
String description = "Created Bandwidth";
Charge charge = chargeService.createBandwidthCharge(bandwidthName,bandwidthUsage,BandwidthUnit.MB,bandwidthPrice,Currency.USD,description); /* returns the Charge object. */
Charge.Bandwidth bandwidth = charge.getBandwidth();
System.out.println("Name is " + bandwidth.getName());
System.out.println("Bandwidth Usage is " + bandwidth.getBandwidth());
System.out.println("Unit is " + bandwidth.getUnit());
System.out.println("Price is " + bandwidth.getPrice());
System.out.println("Currency is " + bandwidth.getCurrency());
String jsonResponse = charge.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"appTab": {
"usages": {
"usage": {
"bandwidth": {
"name": "Bandwidth Name",
"bandwidth": 1000,
"unit": "MB",
"price": 100,
"currency": "USD",
"state": "ACTIVE",
"description": "Created Banwidth"
}
}
}
}
}
}
}
Define charges applicable on each feature in the package.
Parameters:
Returns:
Response: Charge Object
Exception:
/* 4303 - BAD REQUEST - The request parameters are invalid. Feature by the name '<name>' already exists. */
String featureName = "Feature Name";
BigDecimal featurePrice = new BigDecimal(100);
String description = "Created Feature";
Charge charge = chargeService.createFeatureCharge(featureName,featurePrice,Currency.USD,description); /* returns the Charge object. */
Charge.Feature feature = charge.getFeature();
System.out.println("Name is " + feature.getName());
System.out.println("Price is " + feature.getPrice());
System.out.println("Currency is " + feature.getCurrency());
String jsonResponse = charge.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"appTab": {
"usages": {
"usage": {
"feature": {
"name": "Feature Name",
"price": 100,
"currency": "USD",
"state": "ACTIVE",
"description": "Created Feature"
}
}
}
}
}
}
}
Define customizable packages with pricing.
Parameters:
Returns:
Response: SchemeData Object
Exception:
/* 4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4102 - BAD REQUEST - The Request parameters are invalid. Package by the name '<packageName>' for the Scheme '<schemeName>' already Exists. */
String schemeName = "Scheme";
String packageName = "Basic";
SchemeData.PackageData pkgData = new SchemeData().new PackageData();
pkgData.setName(packageName);
pkgData.setCurrency("USD");
pkgData.setDescription("created package");
pkgData.setDuration(30);
pkgData.setPrice(new BigDecimal(100));
SchemeData schemeData = schemeService.createPackage(schemeName, pkgData); /* returns the SchemeData object. */
ArrayList<SchemeData.PackageData> packageList = schemeData.getPackageData();
for(SchemeData.PackageData pkData : packageList)
{
System.out.println("Name is " + pkData.getName());
System.out.println("Price is " + pkData.getPrice());
System.out.println("Currency is " + pkData.getCurrency());
}
String jsonResponse = schemeData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"schemes": {
"scheme": {
"name": "Scheme",
"description": "Created Scheme",
"packages": {
"packageItem": {
"name": "Basic",
"duration": 30,
"price": 100,
"currency": "USD",
"description": "Created package"
}
}
}
}
}
}
}
Create packages with bandwidth, features and storage usage pricing plans
Parameters:
Returns:
Response: SchemeData Object
Exception:
/* 4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4102 - BAD REQUEST - The Request parameters are invalid. Package by the name '<packageName>' for the Scheme '<schemeName>' already Exists. 4103 - BAD REQUEST - The request parameters are invalid. Storage by the unit can be either 'KB', 'MB', 'GB' or 'TB'. 4104 - BAD REQUEST - The request parameters are invalid. Storage by the name '<storageName>' already exists. 4105 - BAD REQUEST - The request parameters are invalid. Bandwidth by the unit can be either 'KB', 'MB', 'GB' or 'TB'. 4106 - BAD REQUEST - The request parameters are invalid. Bandwidth by the name '<bandwidthName>' already exists. 4107 - BAD REQUEST - The request parameters are invalid. Feature by the name '<featureName>' already exists. */
String schemeName = "Scheme";
String packageName = "Basic";
String storageName = "Storage Name";
String bandwidthName = "Bandwidth Name";
String featureName = "Feature Name";
SchemeData.PackageData pkgData = new SchemeData().new PackageData();
pkgData.setName(packageName);
pkgData.setCurrency("USD");
pkgData.setDescription("Created package");
pkgData.setDuration(30);
SchemeData.PackageData.Bandwidth bandwidth = pkgData.new Bandwidth();
bandwidth.setUnit("KB");
bandwidth.setName(bandwidthName);
bandwidth.setBandwidth(new BigDecimal(100));
bandwidth.setPrice(new BigDecimal(200));
bandwidth.setDescription("Created Bandwidth");
SchemeData.PackageData.Storage storage = pkgData.new Storage();
storage.setPrice(new BigDecimal(500));
storage.setName(storageName);
storage.setUnit("KB");
storage.setSpace(new BigDecimal(100));
storage.setDescription("Created Strorage");
SchemeData.PackageData.Feature feature = pkgData.new Feature();
feature.setPrice(new BigDecimal(1000));
feature.setName(featureName);
feature.setDescription("Created Feature");
pkgData.setBandwidth(bandwidth);
pkgData.setStorage(storage);
pkgData.setFeature(feature);
SchemeData schemeData = schemeService.createPackageWithUsage(schemeName, pkgData); /* returns the SchemeData object. */
ArrayList<SchemeData.PackageData> packageList = schemeData.getPackageData();
for(SchemeData.PackageData pkData : packageList)
{
System.out.println("Name is " + pkData.getName());
System.out.println("Price is " + pkData.getPrice());
System.out.println("Currency is " + pkData.getCurrency());
}
String jsonResponse = schemeData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"schemes": {
"scheme": {
"name": "Scheme",
"description": "Created Scheme",
"packages": {
"packageItem": {
"name": "Basic",
"price": 1700,
"duration": 30,
"currency": "USD",
"description": "Created Package",
"bandwidth": {
"name": "Bandwidth Name",
"price": 200,
"bandwidth": 100,
"unit": "KB",
"description": "Created bandwidth"
},
"features": {
"feature": {
"price": 1000,
"description": "Created Feature",
"name": "Feature Name"
}
},
"storage": {
"name": "Storage Name",
"price": 500,
"space": 100,
"unit": "KB",
"description": "Created Strorage"
}
}
}
}
}
}
}
}
Add storage and its pricing details in existing customizable package.
Parameters:
Returns:
Response: SchemeData Object
Exception:
/* 4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4108 - NOT FOUND - Storage by the name '<storageName>' does not exists. 4109 - BAD REQUEST - The request parameters are invalid. Storage with currency '<currency>' should be same as package currency '<currency>'. 4110 - BAD REQUEST - The request parameters are invalid. Storage by the name '<storageName>' with Package '<packageName>' in scheme '<schemeName>' already added. 4111 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. */
String schemeName = "Scheme";
String packageName = "Basic";
String storageName = "Storage Name";
SchemeData schemeData = schemeService.addStorageInToPackage(schemeName, packageName, storageName); /* returns the SchemeData object. */
ArrayList<SchemeData.PackageData> packageList = schemeData.getPackageData();
for(SchemeData.PackageData pkData : packageList)
{
System.out.println("Name is " + pkData.getName());
System.out.println("Price is " + pkData.getPrice());
System.out.println("Storage Name is " + pkData.getStorage().getName());
System.out.println("Storage Price is " + pkData.getStorage().getPrice());
}
String jsonResponse = schemeData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"schemes": {
"scheme": {
"name": "Created Scheme",
"description": "Created Scheme",
"packages": {
"packageItem": {
"name": "Basic",
"price": 100,
"duration": 500,
"currency": "USD",
"description": "Created package",
"storage": {
"name": "Storage Name",
"price": 100,
"space": 100,
"unit": "KB",
"description": "Created Storage"
}
}
}
}
}
}
}
}
Add bandwidth and its respective pricing details in a package already created.
Parameters:
Returns:
Response: SchemeData Object
Exception:
/* 4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4111 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. 4112 - NOT FOUND - Bandwidth by the name '<bandwidthInName>'does not exists. 4113 - BAD REQUEST - The Request parameters are invalid.Bandwidth with currency '<currency>' should be same as package currency '<currency>'. 4114 - BAD REQUEST - The request parameters are invalid. Bandwidth by the name '<bandwidthInName>' with Package '<packageName>' in scheme '<schemeName>' already added. */
String schemeName = "Scheme";
String packageName = "Basic";
String bandwidthName = "Bandwidth Name";
SchemeData schemeData = schemeService.addBandwidthInToPackage(schemeName, packageName, bandwidthName); /* returns the SchemeData object. */
ArrayList<SchemeData.PackageData> packageList = schemeData.getPackageData();
for(SchemeData.PackageData pkData : packageList)
{
System.out.println("Name is " + pkData.getName());
System.out.println("Price is " + pkData.getPrice());
System.out.println("Bandwidth Name is " + pkData.getBandwidth().getName());
System.out.println("Bandwidth Price is " + pkData.getBandwidth().getPrice());
}
String jsonResponse = schemeData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"schemes": {
"scheme": {
"name": "Scheme",
"description": "Created Scheme",
"packages": {
"packageItem": {
"name": "Basic",
"price": 100,
"duration": 500,
"currency": "USD",
"description": "Created package",
"bandwidth": {
"name": "Bandwidth Name",
"price": 100,
"bandwidth": 1000,
"unit": "KB",
"description": "Created Bandwidth"
}
}
}
}
}
}
}
}
Define what features would be included in the package with its pricing.
Parameters:
Returns:
Response: SchemeData Object
Exception:
/* 4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4111 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. 4115 - NOT FOUND - Feature by the name '<featureName>' does not exist exists. 4116 - BAD REQUEST - The request parameters are invalid.Feature with currency '<currency>' should be same as package currency '<currency>'. */
String schemeName = "Scheme";
String packageName = "Basic";
String featureName = "Feature Name";
ArrayList<String> featureList = new ArrayList<String>();
featureList.add(featureName);
SchemeData schemeData = schemeService.addFeatureInToPackage(schemeName, packageName, featureList); /* returns the SchemeData object. */
ArrayList<SchemeData.PackageData> packageList = schemeData.getPackageData();
for(SchemeData.PackageData pkData : packageList)
{
System.out.println("Name is " + pkData.getName());
System.out.println("Price is " + pkData.getPrice());
System.out.println("Feature Name is " + pkData.getFeature().getName());
System.out.println("Feature Price is " + pkData.getFeature().getPrice());
}
String jsonResponse = schemeData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"schemes": {
"scheme": {
"name": "Scheme",
"description": "Created Scheme",
"packages": {
"packageItem": {
"name": "Basic",
"price": 200,
"duration": 500,
"currency": "USD",
"description": "Created package",
"features": {
"feature": [
{
"price": 100,
"description": "Created Feature",
"name": "Feature Name"
},
{
"price": 100,
"description": "Created Feature",
"name": "Feature Charge"
}
]
}
}
}
}
}
}
}
}
Define the storage limit granted for a specific package
Parameters:
Returns:
Response: SchemeData Object
Exception:
/* 4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4108 - NOT FOUND - Storage by the name '<storageName>' does not exists. 4111 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. 4118 - NOT FOUND - Storage by the name '<storageName>' with Package '<packageName>' in scheme '<schemeName>' does not exist. */
String schemeName = "Scheme";
String packageName = "Basic";
String storageName = "Storage Name";
BigDecimal price = new BigDecimal(100);
BigDecimal space = new BigDecimal(100000);
SchemeData schemeData = schemeService.addLimitToStorage(schemeName, packageName, storageName,price,StorageUnit.KB,space); /* returns the SchemeData object. */
ArrayList<SchemeData.PackageData> packageList = schemeData.getPackageData();
for(SchemeData.PackageData pkData : packageList)
{
System.out.println("Name is " + pkData.getName());
System.out.println("Price is " + pkData.getPrice());
System.out.println("Name is " + pkData.getStorage().getName());
System.out.println("Space is " + pkData.getStorage().getLimit().getSpace());
System.out.println("Price is " + pkData.getStorage().getLimit().getPrice());
}
String jsonResponse = schemeData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"schemes": {
"scheme": {
"name": "Scheme",
"description": "Created scheme",
"packages": {
"packageItem": {
"name": "Basic",
"price": 100,
"duration": 500,
"currency": "USD",
"description": "Created package",
"storage": {
"name": "storageName1356130191428",
"price": 100,
"space": 100,
"unit": "KB",
"description": "Created Storage",
"limit": {
"price": 100,
"space": 100000,
"unit": "KB"
}
}
}
}
}
}
}
}
}
Specify the limit for bandwidth specific to a package.
Parameters:
Returns:
Response: SchemeData Object
Exception:
/* 4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4111 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. 4112 - NOT FOUND - Bandwidth by the name '<bandwidthInName>'does not exists. 4119 - NOT FOUND - Bandwidth by the name '<bandwidthName>' with Package '<packageName>' in scheme '<schemeName>' does not exist. */
String schemeName = "Scheme";
String packageName = "Basic";
String bandwidthName = "Bandwidth Name";
BigDecimal price = new BigDecimal(100);
BigDecimal bandwidth = new BigDecimal(100000);
SchemeData schemeData = schemeService.addLimitToBandwidth(schemeName, packageName, bandwidthName,price,BandwidthUnit.KB,bandwidth); /* returns the SchemeData object. */
ArrayList<SchemeData.PackageData> packageList = schemeData.getPackageData();
for(SchemeData.PackageData pkData : packageList)
{
System.out.println("Name is " + pkData.getName());
System.out.println("Price is " + pkData.getPrice());
System.out.println("Name is " + pkData.getBandwidth().getName());
System.out.println("Bandwidth is " + pkData.getBandwidth().getLimit().getBandwidth());
System.out.println("Price is " + pkData.getBandwidth().getLimit().getPrice());
}
String jsonResponse = schemeData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"schemes": {
"scheme": {
"name": "Scheme",
"description": "Created Scheme",
"packages": {
"packageItem": {
"name": "Basic",
"price": 100,
"duration": 500,
"currency": "USD",
"description": "Created package",
"bandwidth": {
"name": "bandwidthName1356130334166",
"price": 100,
"bandwidth": 10,
"unit": "MB",
"description": "Created Banwidth",
"limit": {
"price": 1000,
"bandwidth": 100000000,
"unit": "TB"
}
}
}
}
}
}
}
}
}
Watch out the package details and description for a particular package.
Parameters:
Returns:
Response: SchemeData Object
Exception:
/* 4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4111 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. */
String schemeName = "Scheme";
String packageName = "Basic";
SchemeData schemeData = schemeService.getPackageByPackageName(schemeName, packageName); /* returns the SchemeData object. */
System.out.println("Scheme Name is " + schemeData.getName());
ArrayList<SchemeData.PackageData> packageList = schemeData.getPackageData();
for(SchemeData.PackageData pkData : packageList)
{
System.out.println("Name is " + pkData.getName());
System.out.println("Price is " + pkData.getPrice());
}
String jsonResponse = schemeData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"schemes": {
"scheme": {
"name": "Scheme",
"description": "Created scheme",
"packages": {
"packageItem": {
"name": "Basic",
"duration": 500,
"price": 500,
"currency": "USD",
"description": "created package"
}
}
}
}
}
}
}
View all package details and description of it components in a scheme.
Parameters:
Returns:
Response: SchemeData Object
Exception:
/* 4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4117 - NOT FOUND - Packages for the Scheme '<schemeName>' does not Exists. */
String schemeName = "Scheme";
SchemeData schemeData = schemeService.getAllPackages(schemeName); /* returns the list of SchemeData objects. */
System.out.println("Scheme Name is " + schemeData.getName());
ArrayList<SchemeData.PackageData> packageList = schemeData.getPackageData();
for(SchemeData.PackageData pkgData : packageList)
{
System.out.println("Name is " + pkgData.getName());
System.out.println("Price is " + pkgData.getPrice());
}
String jsonResponse = schemeData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"schemes": {
"scheme": {
"name": "Scheme",
"description": "Created scheme",
"packages": {
"packageItem": [
{
"name": "Basic",
"price": 500,
"duration": 30,
"currency": "USD",
"description": "Created package"
},
{
"name": "Pro",
"price": 5000,
"duration": 30,
"currency": "USD",
"description": "Created package"
}
]
}
}
}
}
}
}
Login and subscribe to our package pricing and details plans. Register with a user name and to avail the subscription, complete the validation process
Parameters:
Returns:
Response: Subscribe Object
Exception:
/* 4200 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists 4201 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. 4202 - BAD REQUEST - The Request parameters are invalid. Subscription for the Service '<serviceName>'already Exists. Please Upgrade your package. 4203 - BAD REQUEST - The Request parameters are invalid. Subscription for the Service '<serviceName>' where Scheme is '<schemeName>' and Package '<packageName>' already Exists. */
String schemeName = "Scheme";
String packageName = "Basic";
String userName = "Nick";
Subscribe subscribe = subscribeService.subscribe(schemeName,packageName,userName); /* returns the Subscribe object. */
System.out.println("User Name is " + subscribe.getUserName());
System.out.println("Scheme Name is " + subscribe.getSchemeData().getName());
System.out.println("Package Name is " + subscribe.getSchemeData().getPackageData().getName());
System.out.println("Package Price is " + subscribe.getSchemeData().getPackageData().getPrice());
String jsonResponse = subscribe.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"subscriptions": {
"subscribe": {
"userName": "Nick",
"expiry": "2054-08-22T04:57:09.000Z",
"scheme": {
"name": "Scheme",
"description": "Created Scheme",
"packages": {
"packageItem": {
"name": "Premium",
"duration": 500,
"price": 30,
"currency": "USD",
"description": "Created Package"
}
}
}
}
}
}
}
}
View user wise subscription summary with all details
Parameters:
Returns:
Response: Subscribe Object
Exception:
/* 4201 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. 4204 - NOT FOUND - Subscription for User by the name '<userName>' does not Exists */
String userName = "Nick";
Subscribe subscribe = subscribeService.getSusbscriptionsByUserName(userName); /* returns the Subscribe object. */
System.out.println("User Name is " + subscribe.getUserName());
System.out.println("Scheme Name is " + subscribe.getSchemeData().getName());
System.out.println("Package Name is " + subscribe.getSchemeData().getPackageData().getName());
System.out.println("Package Price is " + subscribe.getSchemeData().getPackageData().getPrice());
String jsonResponse = subscribe.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"subscriptions": {
"subscribe": {
"userName": "Nick",
"expiry": "2054-08-22T04:58:02.000Z",
"scheme": {
"name": "Scheme",
"description": "Created Scheme",
"packages": {
"packageItem": {
"name": "Premium",
"duration": 500,
"price": 30,
"currency": "USD",
"description": "Created Package"
}
}
}
}
}
}
}
}
Check and Validate a package usage under this module before you plan a pricing for it.
Parameters:
Returns:
Response: Charge Object
Exception:
/* 4304 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4305 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists 4306 - NOT FOUND - Subscription with user name '<userName>' in to package '<packageName>' does not Exists. */
String schemeName = "Scheme";
String packageName = "Basic";
String featureName = "Feature";
String userName = "Nick";
BigDecimal storageSpace = new BigDecimal(100);
Charge charge = chargeService.validatePackageUsage(schemeName,packageName,featureName,userName,storageSpace,StorageUnit.MB); /* returns the Charge object. */
System.out.println("IsValid is " + charge.getIsValid());
System.out.println("Message is " + charge.getMessage());
String jsonResponse = charge.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"appTab": {
"usages": {
"usage": {
"isValid": true,
"message": "User is valid for this Usage ."
}
}
}
}
}
}
Define the package pricing to be charged in this module
Parameters:
Returns:
Response: Charge Object
Exception:
/* 4304 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4305 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists 4306 - NOT FOUND - Subscription with user name '<userName>' in to package '<packageName>' does not Exists. 4303 - BAD REQUEST - The request parameters are invalid. Unit can be only one of these options 'KB', 'MB', 'GB' and 'TB'. */
String schemeName = "Scheme";
String packageName = "Basic";
String userName = "Nick";
BigDecimal storageSpace = new BigDecimal(100);
Charge charge = chargeService.chargePackage(schemeName,packageName,userName,storageSpace,StorageUnit.MB,ChargeType.ADD); /* returns the Charge object. */
System.out.println("Charge is " + charge.getCharge());
String jsonResponse = charge.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"appTab": {
"usages": {
"usage": {
"charge": true
}
}
}
}
}
}
Generate bills as per the package use month and year wise.
Parameters:
Returns:
Response: Bill Object
Exception:
/* 4400 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4401 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. 4402 - NOT FOUND - Subscription with user name '<userName>' in to packageName '<packageName>' does not Exists. 4403 - NOT FOUND - There were no transactions for the user '<userName>' for the Year'<year>' and Month '<month>'. 4404 - BAD REQUEST - The request parameters are invalid. Year should be 2011 or later. */
String schemeName = "Scheme";
String packageName = "Basic";
String userName = "Nick";
int year = 2012;
Bill bill = billService.packageUsageByMonthAndYear(schemeName,packageName,userName,BillMonth.DECEMBER,year); /* returns the Bill object. */
System.out.println("User Name is " + bill.getUserName());
System.out.println("BillMonth is " + bill.getMonth());
System.out.println("Year is " + bill.getYear());
System.out.println("Scheme Name is " + bill.getSchemeData().getName());
System.out.println("Package Name is " + bill.getSchemeData().getPackageData().getName());
System.out.println("Price is " + bill.getSchemeData().getPackageData().getPrice());
String jsonResponse = bill.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"bills": {
"bill": {
"userName": "Nick",
"month": "DECEMBER",
"year": "2012",
"schemes": {
"scheme": {
"schemeName": "Scheme",
"description": "Created Scheme",
"packages": {
"packageItem": {
"packageName": "Premium",
"price": 400,
"duration": 500,
"currency": "USD",
"description": "Created package",
"storage": {
"storageName": "Storage",
"space": 1000,
"unit": "TB",
"price": 100,
"currency": "USD",
"description": "Created Storage",
"overLimit": {
"space": 1000,
"price": 100,
"unit": "TB"
}
},
"bandwidth": {
"bandwidthName": "Bandwidth",
"bandwidth": 10,
"price": 100,
"unit": "TB",
"description": "Created Banwidth",
"overLimit": {
"bandwidth": 1000,
"price": 1000,
"unit": "TB"
}
},
"features": {
"feature": [
{
"name": "Feature",
"price": 100,
"description": "Created Feature"
},
{
"name": "Features",
"price": 100,
"description": "Created Feature"
}
]
},
"usage": {
"storage": {
"space": 9.313225746154784e-9,
"unit": "TB",
"price": 100
},
"bandwidth": {
"bandwidth": 1,
"unit": "TB",
"price": 100
},
"features": {
"feature": [
{
"name": "Feature",
"price": 100
},
{
"name": "Features",
"price": 100
}
]
},
"totalCost": 400,
"currency": "USD"
}
}
}
}
}
}
}
}
}
}
Fetch All the usage bills by month.
Parameters:
Returns:
Response: Bill Object
Exception:
/* 4400 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists. 4401 - NOT FOUND - Package by the name '<packageName>' for the Scheme '<schemeName>' does not Exists. 4402 - NOT FOUND - Subscription with user name '<userName>' in to packageName '<packageName>' does not Exists. 4403 - NOT FOUND - There were no transactions for the user '<userName>' for the Year'<year>' and Month '<month>'. 4404 - BAD REQUEST - The request parameters are invalid. Year should be 2011 or later. */
String schemeName = "Scheme";
String packageName = "Basic";
String userName = "Nick";
int year = 2012;
Bill bill = billService.getAllUsageByMonth(schemeName,packageName,userName,BillMonth.DECEMBER,year); /* returns the Bill object. */
System.out.println("User Name is " + bill.getUserName());
System.out.println("BillMonth is " + bill.getMonth());
ArrayList<Bill.Usage> usageList = bill.getUsage();
for(Bill.Usage usage : usageList)
{
System.out.println("Space is " + usage.getSpace());
System.out.println("Bandwidth is " + usage.getBandwidth());
System.out.println("Type is " + usage.getType());
}
String jsonResponse = bill.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"bills": {
"bill": {
"userName": "Nick",
"month": "DECEMBER",
"year": "2012",
"schemeName": "Scheme",
"packageName": "Basic",
"usages": {
"usage": [
{
"date": "2012-12-21T23:36:20.000Z",
"space": 58.59375,
"unit": "MB",
"bandwidth": 6,
"type": "ADD"
},
{
"date": "2012-12-21T23:38:14.000Z",
"space": 9.765625,
"unit": "MB",
"bandwidth": 1,
"type": "REMOVE"
}
]
}
}
}
}
}
}
Create a discount scheme and specify the name and amount of discounts offered.
Parameters:
Returns:
Response: DiscountData Object
Exception:
/* 4500 - BAD REQUEST - The request parameters are invalid. Discount by name '<name>' already exists. 4501 - BAD REQUEST - The request parameters are invalid. Start date '<date>' should be less than End date '<date>'. */
String discountName = "AppTab";
String description = "Created Discount";
DiscountData.Discount discount = new DiscountData().new Discount();
discount.setPercentage(new BigDecimal(10));
discount.setStartDate(new Date(new Date().getTime()));
discount.setUsage(new BigDecimal(1000));
discount.setEndDate(new Date(new Date().getTime() + 3600 * 3600 * 1000));
DiscountData discountData = discountService.createDiscount(discountName,DiscountType.STORAGETYPE,discount,description); /* returns the DiscountData object. */
System.out.println("Discount Name is " + discountData.getName());
System.out.println("Description is " + discountData.getDescription());
System.out.println("Usage is " + discountData.getDiscount().getUsage());
System.out.println("Percentage is " + discountData.getDiscount().getPercentage());
String jsonResponse = discountData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"discounts": {
"discount": {
"name": "AppTab",
"description": "Created Discount",
"type": "STORAGETYPE",
"promoCode": "xxxxxx",
"discountDetails": {
"startDate": "2012-12-22T00:54:09.000Z",
"endDate": "2012-12-22T21:45:47.000Z",
"percentage": "10",
"usage": 1000
}
}
}
}
}
}
View a complete list of all the discount schemes created and offered with relevant details
Parameters:
Returns:
Response: ArrayList<DiscountData> Object
Exception:
/* 4502 - NOT FOUND - Discounts does not exist. */
ArrayList<DiscountData> discountDataList = discountService.getAllDiscount(); /* returns the list of DiscountData objects. */
for(DiscountData discountData : discountDataList)
{
System.out.println("Discount Name is " + discountData.getName());
System.out.println("Discount Usage is " + discountData.getDiscount().getUsage());
System.out.println("Discount Percentage is " + discountData.getDiscount().getPercentage());
}
String jsonResponse = discountDataList.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"discounts": {
"discount": [
{
"name": "AppTab,
"description": "Created Discount",
"type": "STORAGETYPE",
"promoCode": "xxxxxx",
"discountDetails": {
"startDate": "2012-12-22T00:55:48.000Z",
"endDate": "2012-12-22T21:47:26.000Z",
"percentage": "10.12",
"usage": 10
}
},
{
"name": "App_Tab",
"description": "Created Discount",
"type": "BANDWIDTHTYPE",
"promoCode": "xxxxxx",
"discountDetails": {
"startDate": "2012-12-22T00:55:50.000Z",
"endDate": "2012-12-22T21:47:28.000Z",
"percentage": "10.12",
"usage": 10
}
}
]
}
}
}
}
Get information about a specific discount with details such as name, amount etc.
Parameters:
Returns:
Response: DiscountData Object
Exception:
/* 4503 - NOT FOUND - Discount by the name '<discountName>' do not exist. */
String discountName = "AppTab";
DiscountData discountData = discountService.getDiscountByName(discountName); /* returns the DiscountData object. */
System.out.println("Discount Name is " + discountData.getName());
System.out.println("Description is " + discountData.getDescription());
System.out.println("Usage is " + discountData.getDiscount().getUsage());
System.out.println("Percentage is " + discountData.getDiscount().getPercentage());
String jsonResponse = discountData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"discounts": {
"discount": {
"name": "AppTab",
"description": "Created Discount",
"type": "STORAGETYPE",
"promoCode": "xxxxxx",
"discountDetails": {
"startDate": "2012-12-22T00:54:09.000Z",
"endDate": "2012-12-22T21:45:47.000Z",
"percentage": "10",
"usage": 1000
}
}
}
}
}
}
View a summary of discount offered as per the promo code campaign.
Parameters:
Returns:
Response: DiscountData Object
Exception:
/* 4504 - NOT FOUND - Discount with promo code '<promocode>' do not exist. */
String promoCode = "xxxxxx";
DiscountData discountData = discountService.getDiscountByPromoCode(promoCode); /* returns the DiscountData object. */
System.out.println("Discount Name is " + discountData.getName());
System.out.println("Description is " + discountData.getDescription());
System.out.println("Usage is " + discountData.getDiscount().getUsage());
System.out.println("Percentage is " + discountData.getDiscount().getPercentage());
String jsonResponse = discountData.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"discounts": {
"discount": {
"name": "AppTab",
"description": "Created Discount",
"type": "STORAGETYPE",
"promoCode": "xxxxxx",
"discountDetails": {
"startDate": "2012-12-22T00:54:09.000Z",
"endDate": "2012-12-22T21:45:47.000Z",
"percentage": "10",
"usage": 1000
}
}
}
}
}
}
Remove a discount scheme once it’s obsolete and is not applicable any more.
Parameters:
Returns:
Response: App42Response Object
Exception:
/* 4503 - NOT FOUND - Discount by the name '<discountName>' do not exist. */
String discountName = "App_Tab"; App42Response response = discounService.deleteDiscountByName(discountName); /* returns the App42Response object. */ boolean success = response.isResponseSuccess(); String jsonResponse = response.toString(); /* returns the response in JSON format. (as shown below)*/
{
"app42": {
"response": {
"success": true,
"discounts": {
"discount": {
"name": "App_Tab",
"description": "Created Discount",
"type": "BANDWIDTHTYPE",
"promoCode": "xxxxxx",
"discountDetails": {
"startDate": "2012-12-22T00:55:50.000Z",
"endDate": "2012-12-22T21:47:28.000Z",
"percentage": "10.12",
"usage": 10
}
}
}
}
}
}