App42 Cloud API

Java and Groovy cloud SDK

AppTab

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.



Scheme - With AppTab’s scheme and package service, you can create various payment schemes and offer different packages that may include various combinations of features, API calls and storage. App users can avail any of the offered packages for the pricing and billing options.



Charge - Metering service in AppTab allows you to define the payment charges for individual features, API calls and storage used. Based on the usage of storage features and API calls, bills would be generated for subscribed App users.

Subscribe - You can allow your App users to opt for any defined packages and schemes. For the same, App users can subscribe for a specific package and the same subscribed plan will be applicable for that user to generate the bills.

Bill - Billing service auto-generates the payment bills for subscribed users based on usage of storage, features and API calls. These bills can be generated month wise.

Discount - AppTab allows you to define various discount offers for your App users. You can specify the start and end date of such discounts, the percentage of discount and the other details of discount such as name, description and components based on which the discount is offered. For instance, there may be a promotional discount that can be availed by App users on entering the promo codes.

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.

public SchemeData createScheme(String schemeName, String description) throws App42Exception

Create schemes that enable API users to create various packages

Parameters:

schemeName - Name of the scheme you want to be create
description - Description of the scheme

Returns:

The SchemeData Object

Response: SchemeData Object

Exception:

The method throws the following exception with the error code.
/*
4100 - BAD REQUEST - The Request parameters are invalid. Scheme by name '<schemeName>' already Exists.
*/ 		 
For more details click Exception
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"
                }
            }
        }
    }
}	
public SchemeData getSchemeByName(String schemeName) throws App42Exception

View specific scheme details.

Parameters:

schemeName - Name of the scheme to be retrieve

Returns:

The SchemeData Object

Response: SchemeData Object

Exception:

The method throws the following exception with the error code.
/*
4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists.
*/ 		 
For more details click Exception
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"
                }
            }
        }
    }
} 
public ArrayList<SchemeData> getAllSchemes() throws App42Exception

View details of all existing schemes.

Parameters:

N/A

Returns:

List that contains all scheme object

Response: ArrayList<SchemeData> Object

Exception:

The method throws the following exception with the error code.
/*
4120 - NOT FOUND - Schemes does not exists. 
*/   
For more details click Exception
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"
                    }
                ]
            }
        }
    }
}  
public Charge createStorageCharge(String storageName,BigDecimal storageSpace, StorageUnit storageUnit,BigDecimal storagePrice, Currency storageCurrency, String description) throws App42Exception

Define the storage details and applicable charges

Parameters:

storageName - The name of the storage
storageSpace - Storage space for the scheme
storageUnit - Storage units to be used for the scheme
storagePrice - The price of the scheme
storageCurrency - Currency to be used for that scheme
description - Description of the scheme

Returns:

The Created Charge Object

Response: Charge Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/   
For more details click Exception
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"
                        }
                    }
                }
            }
        }
    }
} 
public Charge createBandwidthCharge(String bandwidthName, BigDecimal bandwidthUsage, BandwidthUnit bandWidthUnit, BigDecimal bandwidthPrice, Currency bandwidthCurrency, String description) throws App42Exception

Define the bandwidth and specify the applicable charges.

Parameters:

bandwidthName - Name of the bandwidth
bandwidthUsage - Bandwidth usage for the scheme
bandWidthUnit - Unit of Bandwidth for the scheme
bandwidthPrice - The price of the level scheme
bandwidthCurrency - Currency to be used for the scheme
description - Description of the scheme

Returns:

The Created Charge Object

Response: Charge Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/   
For more details click Exception
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"
                        }
                    }
                }
            }
        }
    }
} 
public Charge createFeatureCharge(String featureName, BigDecimal featurePrice, Currency featureCurrency,String featureDescription) throws App42Exception

Define charges applicable on each feature in the package.

Parameters:

featureName - The name of feature for the package
featurePrice - The price of feature for the package
featureCurrency - Currency to be used for the package
featureDescription - Description of the feature

Returns:

The Created Charge Object

Response: Charge Object

Exception:

The method throws the following exception with the error code.
/*
4303 - BAD REQUEST - The request parameters are invalid. Feature by the name '<name>' already exists.
*/	 
For more details click Exception
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"
                        }
                    }
                }
            }
        }
    }
}
public SchemeData createPackage(String schemeName , PackageData pkgData) throws App42Exception

Define customizable packages with pricing.

Parameters:

schemeName - Name of the scheme for which you want to create package
pkgData - Details of the package like name, duration, price, currency, description.

Returns:

The created SchemeData object

Response: SchemeData Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/	 
For more details click Exception
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"
                        }
                    }
                }
            }
        }
    }
}		
public SchemeData createPackageWithUsage(String schemeName, PackageData pkgData) throws App42Exception

Create packages with bandwidth, features and storage usage pricing plans

Parameters:

schemeName - Name of the scheme for which you want to create a package
pkgData - pkgData contails the details of package

Returns:

The Created SchemeData Object

Response: SchemeData Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/	 
For more details click Exception
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"
                            }
                        }
                    }
                }
            }
        }
    }
}	
public SchemeData addStorageInToPackage(String schemeName, String packageName, String storageName) throws App42Exception

Add storage and its pricing details in existing customizable package.

Parameters:

schemeName - Name of the scheme in which you add package
packageName - Name of the package in which you wan't to add storage.
storageName - Name of the storage you wan't to add in package.

Returns:

The Created SchemeData object

Response: SchemeData Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/ 		 
For more details click Exception
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"
                            }
                        }
                    }
                }
            }
        }
    }
} 
public SchemeData addBandwidthInToPackage(String schemeName, String packageName, String bandwidthName) throws App42Exception

Add bandwidth and its respective pricing details in a package already created.

Parameters:

schemeName - Name of the scheme in which you add package
packageName - Name of the package in which you wan't to add storage.
bandwidthName - Name of the bandwidth you wan't to add in package

Returns:

The SchemeData object

Response: SchemeData Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/ 		 
For more details click Exception
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"
                            }
                        }
                    }
                }
            }
        }
    }
}	 
public SchemeData addFeatureInToPackage(String schemeName, String packageName, ArrayList<String> featureList) throws App42Exception

Define what features would be included in the package with its pricing.

Parameters:

schemeName - Name of the scheme in which you add package
packageName - Name of the package in which you wan't to add storage.
featureList - List of features Name you want't to add in package

Returns:

All issued licenses

Response: SchemeData Object

Exception:

The method throws the following exception with the error code.
/*
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>'.	 
*/	
For more details click Exception
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"
                                    }
                                ]
                            }
                        }
                    }
                }
            }
        }
    }
}  
public SchemeData addLimitToStorage(String schemeName, String packageName, String storageName, BigDecimal price, StorageUnit unit, BigDecimal space) throws App42Exception

Define the storage limit granted for a specific package

Parameters:

schemeName - Name of the scheme in which you add package
packageName - Name of the package in which you wan't to add storage.
storageName - Name of the storage in which uou want't to add limit
price - The price of overLimit of storage
unit - Unit of storage overLimit it may be KB, MB, GB or TB
space - The space for storage overLimit

Returns:

The SchemeData Object

Response: SchemeData Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/	
For more details click Exception
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"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}	
public SchemeData addLimitToBandwidth(String schemeName, String packageName, String bandwidthName, BigDecimal price, BandwidthUnit unit, BigDecimal bandwidth) throws App42Exception

Specify the limit for bandwidth specific to a package.

Parameters:

schemeName - Name of the scheme in which you add package
packageName - Name of the package in which you wan't to add bandwidth.
bandwidthName - Name of the bandwidth in which uou want't to add limit
price - The price of overLimit of bandwidth
unit - Unit of bandwidth overLimit it may be KB, MB, GB or TB
bandwidth - The bandwidth overLimit for package

Returns:

The SchemeData Object

Response: SchemeData Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/	
For more details click Exception
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"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}	
public SchemeData getPackageByPackageName(String schemeName, String packageName) throws App42Exception

Watch out the package details and description for a particular package.

Parameters:

schemeName - The name of the scheme for which you want't to fetch package
packageName - Fetch the details of package based on name

Returns:

The SchemeData Object

Response: SchemeData Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/	
For more details click Exception
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"
                        }
                    }
                }
            }
        }
    }
}	
public SchemeData getAllPackages(String schemeName) throws App42Exception

View all package details and description of it components in a scheme.

Parameters:

schemeName - Name of the scheme you wan't to retrieve

Returns:

The SchemeData Object

Response: SchemeData Object

Exception:

The method throws the following exception with the error code.
/*
4101 - NOT FOUND - Scheme by the name '<schemeName>' does not Exists.
4117 - NOT FOUND - Packages for the Scheme '<schemeName>' does not Exists.
*/	
For more details click Exception
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"
                            }
                        ]
                    }
                }
            }
        }
    }
}	
public Subscribe subscribe(String userName, String schemeName, String packageName, boolean renew) throws App42Exception

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:

userName - Name of user you wan't to subscribe for package
schemeName - Name of the scheme you wan't to subscribe
packageName - Name of the package you wan't to subscribe
renew -

Returns:

The Subscribe Object

Response: Subscribe Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/	
For more details click Exception
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"
                            }
                        }
                    }
                }
            }
        }
    }
}	
public Subscribe getSusbscriptionsByUserName(String userName) throws App42Exception

View user wise subscription summary with all details

Parameters:

userName - Name of the user for which you wan't retrieve

Returns:

The Subscribe Object

Response: Subscribe Object

Exception:

The method throws the following exception with the error code.
/*
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
*/	
For more details click Exception
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" } } } } } } } }
public Charge validatePackageUsage(String schemeName, String packageName, String featureName, String userName, BigDecimal storageSpace, StorageUnit storageUnit) throws App42Exception

Check and Validate a package usage under this module before you plan a pricing for it.

Parameters:

schemeName - Name of scheme you wan't to validate
packageName - Name of package you wan't to validate
featureName - Name of feature you wan't to validate
userName - Name of user for which you wan't to validate for the package
storageSpace - StorageSpace of scheme you wan't to validate
storageUnit - Unit of storage you wan't to validate (it is either in KB, MB, GB Or TB

Returns:

The SchemeDate Object

Response: Charge Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/	
For more details click Exception
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 ."
                    }
                }
            }
        }
    }
}	
public Charge chargePackage(String schemeName, String packageName, String userName, BigDecimal storageSpace,StorageUnit storageUnit, ChargeType type) throws App42Exception

Define the package pricing to be charged in this module

Parameters:

schemeName - Name of scheme you wan't to charge
packageName - Name of package you wan't to charge
userName - Name of user for which you wan't to charge for the package
storageSpace - StorageSpace of scheme you wan't to charge
storageUnit - Unit of storage you wan't to charge (it is either in KB, MB, GB Or TB.
type - Type of package to be charge

Returns:

The Charge Object

Response: Charge Object

Exception:

The method throws the following exception with the error code.
/*
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'.
*/	
For more details click Exception
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
                    }
                }
            }
        }
    }
}	
public Bill packageUsageByMonthAndYear(String schemeName, String packageName, String userName, BillMonth billMonth, int year) throws App42Exception

Generate bills as per the package use month and year wise.

Parameters:

schemeName - The name of the scheme for which you wan't to retrieve the bill
packageName - The name of the package for which you wan't to retrieve the bill
userName - The user for which bill is generated
billMonth - The month name for which bill has to be fetched e.g. BillMonth.DECEMBER
year - The year for which usage has to be fetched e.g. 2012,2011

Returns:

The Charge information with total price for that month

Response: Bill Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/	
For more details click Exception
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"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}	 
public Bill getAllUsageByMonth(String schemeName, String packageName, String userName, BillMonth billMonth, int year) throws App42Exception

Fetch All the usage bills by month.

Parameters:

schemeName - The name of the scheme for which you wan't to retrieve the bill
packageName - The name of the package for which you wan't to retrieve the bill
userName - The user for which bill is generated
billMonth - The month name for which bill has to be fetched e.g. BillMonth.DECEMBER
year - The year for which usage has to be fetched e.g. 2012,2011

Returns:

Returns Scheme

Response: Bill Object

Exception:

The method throws the following exception with the error code.
/*
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.
*/	
For more details click Exception
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"
                            }
                        ]
                    }
                }
            }
        }
    }
} 
public DiscountData createDiscount(String discountName, DiscountType discountType, Discount discount, String description) throws App42Exception

Create a discount scheme and specify the name and amount of discounts offered.

Parameters:

discountName - The Name of the should be unique
discountType - Type of discount that you want't to create e.g. DiscountType.STORAGETYPE
discount - Discount contains the details of the discountPackage you create like discountPercent,discountUsage,startDate,endDate etc
description - The description of discount

Returns:

The Created DiscountData Object

Response: DiscountData Object

Exception:

The method throws the following exception with the error code.
/*
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>'.
*/	
For more details click Exception
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
                    }
                }
            }
        }
    }
}	
public ArrayList<DiscountData> getAllDiscount() throws App42Exception

View a complete list of all the discount schemes created and offered with relevant details

Parameters:

N/A

Returns:

Created Scheme

Response: ArrayList<DiscountData> Object

Exception:

The method throws the following exception with the error code.
/*
4502 - NOT FOUND - Discounts does not exist.
*/	
For more details click Exception
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
                        }
                    }
                ]
            }
        }
    }
}	
public DiscountData getDiscountByName(String discountName) throws App42Exception

Get information about a specific discount with details such as name, amount etc.

Parameters:

discountName - The name of discount you wan't to retrieve

Returns:

DiscountData Object

Response: DiscountData Object

Exception:

The method throws the following exception with the error code.
/*
4503 - NOT FOUND - Discount by the name '<discountName>' do not exist.
*/	
For more details click Exception
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
                    }
                }
            }
        }
    }
} 
public DiscountData getDiscountByPromoCode(String promoCode) throws App42Exception

View a summary of discount offered as per the promo code campaign.

Parameters:

promoCode - The promotion key for fecthing the discount

Returns:

DiscountData Object

Response: DiscountData Object

Exception:

The method throws the following exception with the error code.
/*
4504 - NOT FOUND - Discount with promo code '<promocode>' do not exist.
*/	
For more details click Exception
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
                    }
                }
            }
        }
    }
}	
public App42Response deleteDiscountByName(String discountName) throws App42Exception

Remove a discount scheme once it’s obsolete and is not applicable any more.

Parameters:

discountName - Discount name which should be unique

Returns:

App42Response Object

Response: App42Response Object

Exception:

The method throws the following exception with the error code.
/*
4503 - NOT FOUND - Discount by the name '<discountName>' do not exist.
*/	
For more details click Exception
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
                    }
                }
            }
        }
    }
}