Class: App42::AppTab::UsageService
- Inherits:
-
Object
- Object
- App42::AppTab::UsageService
- Defined in:
- lib/appTab/UsageService.rb
Overview
UsageService is part of AppTab which is a rating, metering, charging and billing engine.
This service allows app developers to specify the rate for a particular usage parameter. e.g. Level - Storage - space, Bandwidth, Time, Feature, Level of game, OneTime - Which can be used for one time charging e.g. charging for downloads and License for traditional license based charging.
It provides methods for first creating the scheme for charging which specifies the unit of charging and the associated price. Subsequently a chargeXXX call has to be made for charging. e.g. If an App developer wants to charge on Storage, He can use the method createStorageCharge and specify that for 10 KB/MB/GB TB the price is 10 USD. Once the scheme is created. The app developer can call the chargeStorage whenever storage is utilized. e.g. 5MB.
Using the Bill service the app developer can find out what is the monthly bill for a particular user based on his utilization. The bill is calculated based on scheme which is specified.
Instance Method Summary collapse
-
#charge_bandwidth(chargeUser, bandwidthName, bandwidth, usageBandWidth) ⇒ Object
Charge on a particular scheme.
-
#charge_feature(chargeUser, featureName) ⇒ Object
Charge on a particular scheme.
-
#charge_level(chargeUser, levelName) ⇒ Object
Charge on a particular scheme.
-
#charge_one_time(chargeUser, oneTimeName) ⇒ Object
Charge on a particular scheme.
-
#charge_storage(chargeUser, storageName, storageSpace, usageStorage) ⇒ Object
Charge on a particular scheme.
-
#charge_time(chargeUser, timeName, chargetime, usageTime) ⇒ Object
Charge on a particular scheme.
-
#create_bandwidth_charge(bandwidthName, bandwidthUsage, usageBandWidth, bandwidthPrice, bandwidthCurrency, bandwidthDescription) ⇒ Object
Creates the scheme for bandwidth based charging.
-
#create_feature_charge(featureName, featurePrice, featureCurrency, featureDescription) ⇒ Object
Creates the scheme for feature based charging.
-
#create_level_charge(levelName, levelPrice, levelCurrency, levelDescription) ⇒ Object
Creates the scheme for level based charging.
-
#create_one_time_charge(oneTimeName, oneTimePrice, oneTimeCurrency, oneTimeDescription) ⇒ Object
Creates the scheme for one time based charging.
-
#create_storage_charge(storageName, storageSpace, usageStorage, storagePrice, storageCurrency, storageDescription) ⇒ Object
Creates the scheme for storage based charging.
-
#create_time_charge(timeName, timeUsage, usageTime, timePrice, timeCurrency, timeDescription) ⇒ Object
Creates the scheme for time based charging.
-
#get_all_bandwidth_usage ⇒ Object
Returns all the schemes for this usage type.
-
#get_all_feature_usage ⇒ Object
Returns all the schemes for this usage type.
-
#get_all_level_usage ⇒ Object
Returns all the schemes for this usage type.
-
#get_all_one_time_usage ⇒ Object
Returns all the schemes for this usage type.
-
#get_all_storage_usage ⇒ Object
Returns all the schemes for this usage type.
-
#get_all_time_usage ⇒ Object
Returns all the schemes for this usage type.
-
#get_bandwidth(bandwidthName) ⇒ Object
Gets the information for the scheme.
-
#get_feature(featureName) ⇒ Object
Gets the information for the scheme.
-
#get_level(levelName) ⇒ Object
Gets the information for the scheme.
-
#get_one_time(oneTimeName) ⇒ Object
Gets the information for the scheme.
-
#get_storage(storageName) ⇒ Object
Gets the information for the scheme.
-
#get_time(timeName) ⇒ Object
Gets the information for the scheme based on timeName.
-
#initialize(api_key, secret_key, base_url) ⇒ UsageService
constructor
this is a constructor that takes.
-
#remove_bandwidth(bandwidthName) ⇒ Object
Remove a particular scheme.
-
#remove_custom(customName) ⇒ Object
Removes a particular scheme.
-
#remove_feature(featureName) ⇒ Object
Remove a particular scheme.
-
#remove_level(levelName) ⇒ Object
Remove a particular scheme.
-
#remove_one_time(oneTimeName) ⇒ Object
Removes a particular scheme.
-
#remove_storage(storageName) ⇒ Object
Remove a particular scheme.
-
#remove_time(timeName) ⇒ Object
Remove a particular scheme based on timeName.
Constructor Details
#initialize(api_key, secret_key, base_url) ⇒ UsageService
this is a constructor that takes
44 45 46 47 48 49 50 51 |
# File 'lib/appTab/UsageService.rb', line 44 def initialize(api_key, secret_key, base_url) puts "UsageService->initialize" @api_key = api_key @secret_key = secret_key @base_url = base_url @resource = "usage" @version = "1.0" end |
Instance Method Details
#charge_bandwidth(chargeUser, bandwidthName, bandwidth, usageBandWidth) ⇒ Object
Charge on a particular scheme. A Charging record is created whenever this method is called. Which is used for billing and usage behaviour analysis purpose.
1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 |
# File 'lib/appTab/UsageService.rb', line 1162 def charge_bandwidth(chargeUser, bandwidthName, bandwidth, usageBandWidth) puts "chargeBandwidth Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(chargeUser, "Uesr"); util.throwExceptionIfNullOrBlank(bandwidthName, "Name"); util.throwExceptionIfNullOrBlank(bandwidth, " BandWidth"); util.throwExceptionIfNullOrBlank(usageBandWidth, "usageBandWidth"); begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"appTab"=> {"usage"=>{"charge"=>{"bandwidth"=>{ "user" => chargeUser, "name" => bandwidthName, "bandwidth" => bandwidth, "unit" => usageBandWidth }}}}}}.to_json puts "Body #{body}" query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/charge/bandwidth" response = connection.post(signature, resource_url, query_params, body) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#charge_feature(chargeUser, featureName) ⇒ Object
Charge on a particular scheme. A Charging record is created whenever this method is called. Which is used for billing and usage behaviour analysis purpose.
1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 |
# File 'lib/appTab/UsageService.rb', line 1105 def charge_feature(chargeUser, featureName) puts "chargeFeature Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(chargeUser, "User"); util.throwExceptionIfNullOrBlank(featureName, "Name"); begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"appTab"=> {"usage"=>{"charge"=>{"feature"=>{ "user" => chargeUser, "name" => featureName }}}}}}.to_json puts "Body #{body}" query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/charge/feature" response = connection.post(signature, resource_url, query_params, body) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#charge_level(chargeUser, levelName) ⇒ Object
Charge on a particular scheme. A Charging record is created whenever this method is called. Which is used for billing and usage behaviour analysis purpose.
999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 |
# File 'lib/appTab/UsageService.rb', line 999 def charge_level(chargeUser, levelName) puts "create Time Charge Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(chargeUser, "User"); util.throwExceptionIfNullOrBlank(levelName, "Name"); begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"appTab"=> {"usage"=>{"charge"=>{"level"=>{ "name" => levelName, "user" => chargeUser }}}}}}.to_json puts "Body #{body}" query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/charge/level" response = connection.post(signature, resource_url, query_params, body) puts "------------ i am here #{response}" usageObj = UsageResponseBuilder.new().buildResponse(response) puts "------------ i am here also but error are killing me #{usageObj}" rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#charge_one_time(chargeUser, oneTimeName) ⇒ Object
Charge on a particular scheme. A Charging record is created whenever this method is called. Which is used for billing and usage behaviour analysis purpose.
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
# File 'lib/appTab/UsageService.rb', line 1052 def charge_one_time(chargeUser, oneTimeName) puts "chargeOneTimee Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(chargeUser, "User"); util.throwExceptionIfNullOrBlank(oneTimeName, "Name"); begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"appTab"=> {"usage"=>{"charge"=>{"oneTime"=>{ "user" => chargeUser, "name" => oneTimeName }}}}}}.to_json puts "Body #{body}" query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/charge/oneTime" response = connection.post(signature, resource_url, query_params, body) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#charge_storage(chargeUser, storageName, storageSpace, usageStorage) ⇒ Object
Charge on a particular scheme. A Charging record is created whenever this method is called. Which is used for billing and usage behaviour analysis purpose.
1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 |
# File 'lib/appTab/UsageService.rb', line 1223 def charge_storage(chargeUser, storageName, storageSpace, usageStorage) puts "charge Storage Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(chargeUser, "User"); util.throwExceptionIfNullOrBlank(storageName, "StorageName"); util.throwExceptionIfNullOrBlank(storageSpace, "Space"); util.throwExceptionIfNullOrBlank(usageStorage, "usageStorage"); begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"appTab"=> {"usage"=>{"charge"=>{"storage"=>{ "user" => chargeUser, "name" => storageName, "space" => storageSpace, "unit" => usageStorage }}}}}}.to_json puts "Body #{body}" query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/charge/storage" response = connection.post(signature, resource_url, query_params, body) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#charge_time(chargeUser, timeName, chargetime, usageTime) ⇒ Object
Charge on a particular scheme. A Charging record is created whenever this method is called. Which is used for billing and usage behaviour analysis purpose.
1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 |
# File 'lib/appTab/UsageService.rb', line 1284 def charge_time(chargeUser, timeName, chargetime, usageTime) puts "charge Time Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(chargeUser, "User"); util.throwExceptionIfNullOrBlank(timeName, "Name"); util.throwExceptionIfNullOrBlank(chargetime, "Time"); util.throwExceptionIfNullOrBlank(usageTime, "usageTime"); begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"appTab"=> {"usage"=>{"charge"=>{"time"=>{ "user" => chargeUser, "name" => timeName, "time" => chargetime, "unit" => usageTime }}}}}}.to_json puts "Body #{body}" query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/charge/time" response = connection.post(signature, resource_url, query_params, body) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#create_bandwidth_charge(bandwidthName, bandwidthUsage, usageBandWidth, bandwidthPrice, bandwidthCurrency, bandwidthDescription) ⇒ Object
Creates the scheme for bandwidth based charging. It is best suited for network based bandwidth usage.
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
# File 'lib/appTab/UsageService.rb', line 530 def create_bandwidth_charge(bandwidthName, bandwidthUsage, usageBandWidth, bandwidthPrice, bandwidthCurrency, bandwidthDescription) puts "create Bandwidth Charge Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(bandwidthName, "Name"); util.throwExceptionIfNullOrBlank(bandwidthUsage, "BandWidth"); util.throwExceptionIfNullOrBlank(usageBandWidth, "usageBandWidth"); util.throwExceptionIfNullOrBlank(bandwidthPrice, "Price"); util.throwExceptionIfNullOrBlank(bandwidthCurrency, "Currency"); util.throwExceptionIfNullOrBlank(bandwidthDescription, "Description"); begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"appTab"=> {"usage"=>{"bandwidth"=>{ "name" => bandwidthName, "price" => bandwidthPrice, "bandwidth" => bandwidthUsage, "unit" => usageBandWidth, "currency" => bandwidthCurrency, "description" => bandwidthDescription } }}}}.to_json puts "Body #{body}" query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/bandwidth" response = connection.post(signature, resource_url, query_params, body) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#create_feature_charge(featureName, featurePrice, featureCurrency, featureDescription) ⇒ Object
Creates the scheme for feature based charging. Feature based charging is suited for Software Applications. E.g. Within mobile, desktop, SaaS based charging based on features. One can charge based on number of features one uses.
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/appTab/UsageService.rb', line 374 def create_feature_charge(featureName, featurePrice, featureCurrency, featureDescription) puts "create Feature Charge Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(featureName, "Name"); util.throwExceptionIfNullOrBlank(featurePrice, "Price"); util.throwExceptionIfNullOrBlank(featureCurrency, "Currency"); util.throwExceptionIfNullOrBlank(featureDescription, "Description"); begin connection = App42::Connection::RESTConnection.new(@base_url) puts "Debug 1" util = Util.new body = {'app42' => {"appTab"=> {"usage"=>{"feature"=>{ "name" => featureName, "price" => featurePrice, "currency" => featureCurrency, "description" => featureDescription } }}}}.to_json puts "Body #{body}" query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/feature" response = connection.post(signature, resource_url, query_params, body) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#create_level_charge(levelName, levelPrice, levelCurrency, levelDescription) ⇒ Object
Creates the scheme for level based charging. Level based charging is suited for usage based charging.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/appTab/UsageService.rb', line 71 def create_level_charge(levelName, levelPrice, levelCurrency, levelDescription) puts "createLevelCharge Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(levelName, "Name"); util.throwExceptionIfNullOrBlank(levelPrice, "Price"); util.throwExceptionIfNullOrBlank(levelCurrency, "Currency"); util.throwExceptionIfNullOrBlank(levelDescription, "Description"); begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"appTab"=> {"usage"=>{"level"=>{ "name" => levelName, "price" => levelPrice, "currency" => levelCurrency, "description" => levelDescription }}}}}.to_json puts "Body #{body}" query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/level" response = connection.post(signature, resource_url, query_params, body) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#create_one_time_charge(oneTimeName, oneTimePrice, oneTimeCurrency, oneTimeDescription) ⇒ Object
Creates the scheme for one time based charging. One Time based charging is suited for downloads. e.g. app, Images, Music, Video, software etc. downloads.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/appTab/UsageService.rb', line 220 def create_one_time_charge(oneTimeName, oneTimePrice, oneTimeCurrency, oneTimeDescription) puts "create One Time Charge Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(oneTimeName, "Name"); util.throwExceptionIfNullOrBlank(oneTimePrice, "Price"); util.throwExceptionIfNullOrBlank(oneTimeCurrency, "Currency"); util.throwExceptionIfNullOrBlank(oneTimeDescription, "Description"); begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"appTab"=> {"usage"=>{"oneTime"=>{ "name" => oneTimeName, "price" => oneTimePrice, "currency" => oneTimeCurrency, "description" => oneTimeDescription }}}}}.to_json puts "Body #{body}" query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/oneTime" puts " =============resource_url================== #{resource_url}" response = connection.post(signature, resource_url, query_params, body) puts " =============response================== #{response}" usageObj = UsageResponseBuilder.new().buildResponse(response) puts " =============usageObj================== #{usageObj}" rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#create_storage_charge(storageName, storageSpace, usageStorage, storagePrice, storageCurrency, storageDescription) ⇒ Object
Creates the scheme for storage based charging. It is best suited for disk based storage usage. E.g. photo Storage, file Storage, RAM usage, Secondary Storage.
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 |
# File 'lib/appTab/UsageService.rb', line 689 def create_storage_charge(storageName, storageSpace, usageStorage, storagePrice, storageCurrency, storageDescription) puts "create Storage Charge Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(storageName, "Name"); util.throwExceptionIfNullOrBlank(storageSpace, "Space"); util.throwExceptionIfNullOrBlank(usageStorage, "usageStorage"); util.throwExceptionIfNullOrBlank(storagePrice, "Price"); util.throwExceptionIfNullOrBlank(storageCurrency, "Currency"); util.throwExceptionIfNullOrBlank(storageDescription, "Description"); begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"appTab"=> {"usage"=>{"storage"=>{ "name" => storageName, "price" => storagePrice, "space" => storageSpace, "unit" => usageStorage, "currency" => storageCurrency, "description" => storageDescription } }}}}.to_json puts "Body #{body}" query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/storage" response = connection.post(signature, resource_url, query_params, body) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#create_time_charge(timeName, timeUsage, usageTime, timePrice, timeCurrency, timeDescription) ⇒ Object
Creates the scheme for time based charging. It is best suited for applications which want to charge based on time usage or elapsed. E.g. How long one is listening to music or watching a video. How long the person is reading a online book or magazine etc.
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 |
# File 'lib/appTab/UsageService.rb', line 849 def create_time_charge(timeName, timeUsage, usageTime, timePrice, timeCurrency, timeDescription) puts "create Time Charge Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(timeName, "Name"); util.throwExceptionIfNullOrBlank(timeUsage, "Time"); util.throwExceptionIfNullOrBlank(usageTime, "usageTime"); util.throwExceptionIfNullOrBlank(timePrice, "Price"); util.throwExceptionIfNullOrBlank(timeCurrency, "Currency"); util.throwExceptionIfNullOrBlank(timeDescription, "Description"); begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"appTab"=> {"usage"=>{"time"=>{ "name" => timeName, "price" => timePrice, "time" => timeUsage, "unit" => usageTime, "currency" => timeCurrency, "description" => timeDescription }}}}}.to_json puts "Body #{body}" query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/time" response = connection.post(signature, resource_url, query_params, body) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#get_all_bandwidth_usage ⇒ Object
Returns all the schemes for this usage type. This can be used by the app developers to display their usage based pricing plan.
1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 |
# File 'lib/appTab/UsageService.rb', line 1442 def get_all_bandwidth_usage() puts "getAllBandwidthUsage " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/bandwidth" response = connection.get(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#get_all_feature_usage ⇒ Object
Returns all the schemes for this usage type. This can be used by the app developers to display their usage based pricing plan.
1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 |
# File 'lib/appTab/UsageService.rb', line 1405 def get_all_feature_usage() puts "getAllFeatureUsage " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/feature" response = connection.get(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#get_all_level_usage ⇒ Object
Returns all the schemes for this usage type. This can be used by the app developers to display their usage based pricing plan.
1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 |
# File 'lib/appTab/UsageService.rb', line 1333 def get_all_level_usage() puts "getAllLevelUsage " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/level" response = connection.get(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#get_all_one_time_usage ⇒ Object
Returns all the schemes for this usage type. This can be used by the app developers to display their usage based pricing plan.
1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 |
# File 'lib/appTab/UsageService.rb', line 1369 def get_all_one_time_usage() puts "getAllOneTimeUsage " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/oneTime" response = connection.get(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#get_all_storage_usage ⇒ Object
Returns all the schemes for this usage type. This can be used by the app developers to display their usage based pricing plan.
1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 |
# File 'lib/appTab/UsageService.rb', line 1478 def get_all_storage_usage() puts "getAllStorageUsage " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/storage" response = connection.get(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#get_all_time_usage ⇒ Object
Returns all the schemes for this usage type. This can be used by the app developers to display their usage based pricing plan.
1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 |
# File 'lib/appTab/UsageService.rb', line 1514 def get_all_time_usage() puts "getAllTimeUsage " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/time" response = connection.get(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#get_bandwidth(bandwidthName) ⇒ Object
Gets the information for the scheme. This method can be used by the app developers to show the pricing plans to their users.
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
# File 'lib/appTab/UsageService.rb', line 589 def get_bandwidth(bandwidthName) puts "featureName " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(bandwidthName, "BandWidthName"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", bandwidthName); puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/bandwidth/#{bandwidthName}" response = connection.get(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#get_feature(featureName) ⇒ Object
Gets the information for the scheme. This method can be used by the app developer to show his pricing plans to their users.
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
# File 'lib/appTab/UsageService.rb', line 431 def get_feature(featureName) puts "featureName " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(featureName, "Name"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", featureName); puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/feature/#{featureName}" response = connection.get(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#get_level(levelName) ⇒ Object
Gets the information for the scheme. This method can be used by the app developers to show the pricing plans to their users.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/appTab/UsageService.rb', line 124 def get_level(levelName) puts "getLicense " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(levelName, "Name"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", levelName); puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/level/#{levelName}" response = connection.get(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#get_one_time(oneTimeName) ⇒ Object
Gets the information for the scheme. This method can be used by the app developer to show the pricing plans to their users.
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/appTab/UsageService.rb', line 277 def get_one_time(oneTimeName) puts "getOneTime " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(oneTimeName, "Name"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", oneTimeName); puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/oneTime/#{oneTimeName}" response = connection.get(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#get_storage(storageName) ⇒ Object
Gets the information for the scheme. This method can be used by the App developer to show his pricing plans to their users.
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
# File 'lib/appTab/UsageService.rb', line 748 def get_storage(storageName) puts "featureName " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(storageName, "StorageName"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", storageName); puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/storage/#{storageName}" response = connection.get(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#get_time(timeName) ⇒ Object
Gets the information for the scheme based on timeName. This method can be used by the app developers to show his pricing plans to their users.
907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 |
# File 'lib/appTab/UsageService.rb', line 907 def get_time(timeName) puts "timeName " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(timeName, "timeName"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", timeName); puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/time/#{timeName}" response = connection.get(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#remove_bandwidth(bandwidthName) ⇒ Object
Remove a particular scheme. Note: A level is not physically deleted from the storage. Only the state is changed so that it is available to fetch older information.
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
# File 'lib/appTab/UsageService.rb', line 634 def remove_bandwidth(bandwidthName) puts "remove bandwidth Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(bandwidthName, "BandWidthName"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", bandwidthName) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/bandwidth/#{bandwidthName}" response = connection.delete(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#remove_custom(customName) ⇒ Object
Removes a particular scheme. Note: A Custom charge is not physically deleted from the storage. Only the state is changed so that it is available to fetch older information.
1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 |
# File 'lib/appTab/UsageService.rb', line 1667 def remove_custom(customName) puts "remove Custom Called " puts "Base url #{@base_url}" response = nil usageObj = Usage.new usageObj = nil util = Util.new util.throwExceptionIfNullOrBlank(customName, "Name"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", customName) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/custom/#{customName}" response = connection.delete(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#remove_feature(featureName) ⇒ Object
Remove a particular scheme. Note: A level is not physically deleted from the storage. Only the state is changed so that it is available to fetch older information.
-
The name of scheme which has to be removed
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/appTab/UsageService.rb', line 476 def remove_feature(featureName) puts "remove feature Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(featureName, "Name"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", featureName) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/feature/#{featureName}" response = connection.delete(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#remove_level(levelName) ⇒ Object
Remove a particular scheme. Note: A level is not physically deleted from the storage. Only the state is changed so that it is available to fetch older information.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/appTab/UsageService.rb', line 169 def remove_level(levelName) puts "remove Level Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(levelName, "levelName"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", levelName) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/level/#{levelName}" response = connection.delete(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#remove_one_time(oneTimeName) ⇒ Object
Removes a particular scheme. Note: A level is not physically deleted from the storage. Only the state is changed so that it is available to fetch older information.
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/appTab/UsageService.rb', line 322 def remove_one_time(oneTimeName) puts "remove OneTime Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(oneTimeName, "Name"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", oneTimeName) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/oneTime/#{oneTimeName}" response = connection.delete(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#remove_storage(storageName) ⇒ Object
Remove a particular scheme. Note: A level is not physically deleted from the storage. Only the state is changed so that it is available to fetch older information.
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 |
# File 'lib/appTab/UsageService.rb', line 793 def remove_storage(storageName) puts "remove feature Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(storageName, "StorageName"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", storageName) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/storage/#{storageName}" response = connection.delete(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |
#remove_time(timeName) ⇒ Object
Remove a particular scheme based on timeName. Note: A level is not physically deleted from the storage. Only the state is changed so that it is available to fetch older information.
-
The name of scheme
952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 |
# File 'lib/appTab/UsageService.rb', line 952 def remove_time(timeName) puts "remove time Called " puts "Base url #{@base_url}" response = nil usageObj = nil usageObj = Usage.new util = Util.new util.throwExceptionIfNullOrBlank(timeName, "timeName"); begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = Hash.new params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts params params.store("name", timeName) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/time/#{timeName}" response = connection.delete(signature, resource_url, query_params) usageObj = UsageResponseBuilder.new().buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usageObj end |