class App42::AppTab::BillService
AppTab
- Billing service. This service is used along with the Usage
service. It generates Bill
for a particular based on Usage
Scheme. For e.g. if user sid's bill has to be seen for May and 2012. This service will list all the charging transactions and calculate the bill for May and tell the total usage and price. The calculation is done based on the Price which is given during scheme creation, the unit of charging and corresponding usage. AppTab
currently just maintains the data and does calculation. How the Bill
is rendered and the interface with Payment Gateway is left with the App
developer.
Public Class Methods
this is a constructor that takes
@param apiKey @param secretKey @param baseURL
# File lib/appTab/BillService.rb, line 32 def initialize(api_key, secret_key, base_url) puts "BillService->initialize" @api_key = api_key @secret_key = secret_key @base_url = base_url @resource = "bill" @version = "1.0" end
Public Instance Methods
Get usage for Scheme based on Month and Year. This is useful to show the user the charging details of the User
for the Scheme
@param userName
- The user for which the charging information has to be fetched
@param usageName
- The name of the Scheme
@param billMonth
- The month name for which the usage has to be fetched e.g. BillMonth.JANUARY, BillMonth.DECEMBER
@param year
- The year for which the usage has to be fetched e.g. 2012, 2011
@returns All the charging transactions with the total usage and total price for that month
@throws App42Exception
# File lib/appTab/BillService.rb, line 181 def usage_bandwidth_by_month_and_year(userName, usageName, billMonth, year) puts "usageBandwidthByMonthAndYear Called " puts "Base url #{@base_url}" response = nil; billObj = nil; billObj = Bill.new util = Util.new util.throwExceptionIfNullOrBlank(userName, "UserName"); util.throwExceptionIfNullOrBlank(usageName, "UsageName"); util.throwExceptionIfNullOrBlank(billMonth, "billMonth"); util.throwExceptionIfNullOrBlank(year, "Year"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util.get_timestamp_utc, } query_params = params.clone bm = BillMonth.new() params.store("usageName", usageName); params.store("year", "" + (year.to_i).to_s); params.store("month", bm.enum(billMonth)); params.store("userName", userName); signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/bandwidth/#{usageName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}" response = connection.get(signature, resource_url, query_params) billObj = BillResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return billObj end
Get usage for Scheme based on Month and Year. This is useful to show the user the charging details of the User
for the Scheme
@param userName
- The user for which the charging information has to be fetched
@param usageName
- The name of the Scheme
@param billMonth
- The month name for which the usage has to be fetched e.g. BillMonth.JANUARY, BillMonth.DECEMBER
@param year
- The year for which the usage has to be fetched e.g. 2012, 2011
@returns All the charging transactions with the total usage and total price for that month
@throws App42Exception
# File lib/appTab/BillService.rb, line 358 def usage_feature_by_month_and_year(userName, usageName, billMonth, year) puts "usageFeatureByMonthAndYear Called " puts "Base url #{@base_url}" response = nil; billObj = nil; billObj = Bill.new util = Util.new util.throwExceptionIfNullOrBlank(userName, "UserName"); util.throwExceptionIfNullOrBlank(usageName, "UsageName"); util.throwExceptionIfNullOrBlank(billMonth, "billMonth"); util.throwExceptionIfNullOrBlank(year, "Year"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util.get_timestamp_utc, } query_params = params.clone bm = BillMonth.new() params.store("usageName", usageName); params.store("year", "" + (year.to_i).to_s); params.store("month", bm.enum(billMonth)); params.store("userName", userName); signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/feature/#{usageName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}" response = connection.get(signature, resource_url, query_params) billObj = BillResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return billObj end
Get usage for Scheme based on Month and Year. This is useful to show the user the charging details of the User
for the Scheme
@param userName
- The user for which the charging information has to be fetched
@param usageName
- The name of the Scheme
@param billMonth
- The month name for which the usage has to be fetched e.g. BillMonth.JANUARY, BillMonth.DECEMBER
@param year
- The year for which the usage has to be fetched e.g. 2012, 2011
@returns All the charging transactions with the total usage and total price for that month
@throws App42Exception
# File lib/appTab/BillService.rb, line 240 def usage_level_by_month_and_year(userName, usageName, billMonth, year) puts "usageLevelByMonthAndYear Called " puts "Base url #{@base_url}" response = nil; billObj = nil; billObj = Bill.new util = Util.new util.throwExceptionIfNullOrBlank(userName, "UserName"); util.throwExceptionIfNullOrBlank(usageName, "UsageName"); util.throwExceptionIfNullOrBlank(billMonth, "billMonth"); util.throwExceptionIfNullOrBlank(year, "Year"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util.get_timestamp_utc, } query_params = params.clone bm = BillMonth.new() params.store("usageName", usageName); params.store("year", "" + (year.to_i).to_s); params.store("month", bm.enum(billMonth)); params.store("userName", userName); signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/level/#{usageName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}" response = connection.get(signature, resource_url, query_params) billObj = BillResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return billObj end
Get usage for Scheme based on Month and Year. This is useful to show the user the charging details of the User
for the Scheme
@param userName
- The user for which the charging information has to be fetched
@param licenseName
- The name of the License
@param billMonth
- The month name for which the usage has to be fetched e.g. BillMonth.JANUARY, BillMonth.DECEMBER
@param year
- The year for which the usage has to be fetched e.g. 2012, 2011
@returns All the charging transactions with the total usage and total price for that month
@throws App42Exception
# File lib/appTab/BillService.rb, line 418 def usage_license_by_month_and_year(userName, licenseName, billMonth, year) puts "usageLicenseByMonthAndYear Called " puts "Base url #{@base_url}" response = nil; billObj = nil; billObj = Bill.new util = Util.new util.throwExceptionIfNullOrBlank(userName, "UserName"); util.throwExceptionIfNullOrBlank(licenseName, "LicenseName"); util.throwExceptionIfNullOrBlank(billMonth, "billMonth"); util.throwExceptionIfNullOrBlank(year, "Year"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util.get_timestamp_utc, } query_params = params.clone bm = BillMonth.new() params.store("licenseName", licenseName); params.store("year", "" + (year.to_i).to_s); params.store("month", bm.enum(billMonth)); params.store("userName", userName); signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/license/#{licenseName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}" response = connection.get(signature, resource_url, query_params) billObj = BillResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return billObj end
Get usage for Scheme based on Month and Year. This is useful to show the user the charging details of the User
for the Scheme
@param userName
- The user for which the charging information has to be fetched
@param usageName
- The name of the Scheme
@param billMonth
- The month name for which the usage has to be fetched e.g. BillMonth.JANUARY, BillMonth.DECEMBER
@param year
- The year for which the usage has to be fetched e.g. 2012, 2011
@returns All the charging transactions with the total usage and total price for that month
@throws App42Exception
# File lib/appTab/BillService.rb, line 299 def usage_one_time_by_month_and_year(userName, usageName, billMonth, year) puts "usageOneTimeByMonthAndYear Called " puts "Base url #{@base_url}" response = nil; billObj = nil; billObj = Bill.new util = Util.new util.throwExceptionIfNullOrBlank(userName, "UserName"); util.throwExceptionIfNullOrBlank(usageName, "UsageName"); util.throwExceptionIfNullOrBlank(billMonth, "billMonth"); util.throwExceptionIfNullOrBlank(year, "Year"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util.get_timestamp_utc, } query_params = params.clone bm = BillMonth.new() params.store("usageName", usageName); params.store("year", "" + (year.to_i).to_s); params.store("month", bm.enum(billMonth)); params.store("userName", userName); signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/oneTime/#{usageName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}" response = connection.get(signature, resource_url, query_params) billObj = BillResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return billObj end
Get usage for Scheme based on Month and Year. This is useful to show the user the charging details of the User
for the Scheme
@param userName
- The user for which the charging information has to be fetched
@param usageName
- The name of the Scheme
@param billMonth
- The month name for which the usage has to be fetched e.g. BillMonth.JANUARY, BillMonth.DECEMBER
@param year
- The year for which the usage has to be fetched e.g. 2012, 2011
@returns All the charging transactions with the total usage and total price for that month
@throws App42Exception
# File lib/appTab/BillService.rb, line 122 def usage_storage_by_month_and_year(userName, usageName, billMonth, year) puts "usageStorageByMonthAndYear Called " puts "Base url #{@base_url}" response = nil; billObj = nil; billObj = Bill.new util = Util.new util.throwExceptionIfNullOrBlank(userName, "UserName"); util.throwExceptionIfNullOrBlank(usageName, "UsageName"); util.throwExceptionIfNullOrBlank(billMonth, "billMonth"); util.throwExceptionIfNullOrBlank(year, "Year"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util.get_timestamp_utc, } query_params = params.clone bm = BillMonth.new() params.store("usageName", usageName); params.store("year", "" + (year.to_i).to_s); params.store("month", bm.enum(billMonth)); params.store("userName", userName); signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/storage/#{usageName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}" response = connection.get(signature, resource_url, query_params) billObj = BillResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return billObj end
Get usage for Scheme based on Month and Year. This is useful to show the user the charging details of the User
for the Scheme
@param userName
- The user for which the charging information has to be fetched
@param usageName
- The name of the Scheme
@param billMonth
- The month name for which the usage has to be fetched e.g. BillMonth.JANUARY, BillMonth.DECEMBER
@param year
- The year for which the usage has to be fetched e.g. 2012, 2011
@returns All the charging transactions with the total usage and total price for that month
@throws App42Exception
# File lib/appTab/BillService.rb, line 63 def usage_time_by_month_and_year(userName, usageName, billMonth, year) puts "usageTimeByMonthAndYear Called " puts "Base url #{@base_url}" response = nil; billObj = nil; billObj = Bill.new util = Util.new util.throwExceptionIfNullOrBlank(userName, "UserName"); util.throwExceptionIfNullOrBlank(usageName, "UsageName"); util.throwExceptionIfNullOrBlank(billMonth, "billMonth"); util.throwExceptionIfNullOrBlank(year, "Year"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util.get_timestamp_utc, } query_params = params.clone bm = BillMonth.new() params.store("usageName", usageName); params.store("year", "" + (year.to_i).to_s); params.store("month", bm.enum(billMonth)); params.store("userName", userName); signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/time/#{usageName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}" response = connection.get(signature, resource_url, query_params) billObj = BillResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return billObj end