App42_RUBY_SDK 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/.gitignore +18 -0
  2. data/App42_RUBY_SDK.gemspec +31 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +25 -0
  6. data/Rakefile +1 -0
  7. data/lib/App42BadParameterException.rb +31 -0
  8. data/lib/App42Exception.rb +39 -0
  9. data/lib/App42LimitException.rb +15 -0
  10. data/lib/App42NotFoundException.rb +15 -0
  11. data/lib/App42Response.rb +13 -0
  12. data/lib/App42ResponseBuilder.rb +64 -0
  13. data/lib/App42SecurityException.rb +15 -0
  14. data/lib/App42_RUBY_SDK.rb +236 -0
  15. data/lib/App42_RUBY_SDK/version.rb +3 -0
  16. data/lib/ServiceAPI.rb +246 -0
  17. data/lib/appTab/App.rb +105 -0
  18. data/lib/appTab/BandwidthUnit.rb +57 -0
  19. data/lib/appTab/Bill.rb +182 -0
  20. data/lib/appTab/BillMonth.rb +94 -0
  21. data/lib/appTab/BillResponseBuilder.rb +242 -0
  22. data/lib/appTab/BillService.rb +457 -0
  23. data/lib/appTab/Currency.rb +79 -0
  24. data/lib/appTab/DiscountResponseBuilder.rb +71 -0
  25. data/lib/appTab/DiscountService.rb +240 -0
  26. data/lib/appTab/DiscountType.rb +54 -0
  27. data/lib/appTab/License.rb +25 -0
  28. data/lib/appTab/LicenseResponseBuilder.rb +88 -0
  29. data/lib/appTab/LicenseService.rb +399 -0
  30. data/lib/appTab/PackageData.rb +83 -0
  31. data/lib/appTab/PackageResponseBuilder.rb +114 -0
  32. data/lib/appTab/PackageService.rb +506 -0
  33. data/lib/appTab/SchemeData.rb +11 -0
  34. data/lib/appTab/SchemeResponseBuilder.rb +70 -0
  35. data/lib/appTab/SchemeService.rb +151 -0
  36. data/lib/appTab/StorageUnit.rb +54 -0
  37. data/lib/appTab/SubscribeService.rb +180 -0
  38. data/lib/appTab/Test.rb +41 -0
  39. data/lib/appTab/TimeUnit.rb +49 -0
  40. data/lib/appTab/Usage.rb +206 -0
  41. data/lib/appTab/UsageResponseBuilder.rb +152 -0
  42. data/lib/appTab/UsageService.rb +1799 -0
  43. data/lib/connection/RESTConnection.rb +711 -0
  44. data/lib/email/Email.rb +51 -0
  45. data/lib/email/EmailMIME.rb +51 -0
  46. data/lib/email/EmailResponseBuilder.rb +76 -0
  47. data/lib/email/EmailService.rb +244 -0
  48. data/lib/gallery/Album.rb +56 -0
  49. data/lib/gallery/AlbumResponseBuilder.rb +168 -0
  50. data/lib/gallery/AlbumService.rb +337 -0
  51. data/lib/gallery/PhotoService.rb +591 -0
  52. data/lib/game/Game.rb +39 -0
  53. data/lib/game/GameResponseBuilder.rb +106 -0
  54. data/lib/game/GameService.rb +268 -0
  55. data/lib/game/Reward.rb +24 -0
  56. data/lib/game/RewardResponseBuilder.rb +85 -0
  57. data/lib/game/RewardService.rb +440 -0
  58. data/lib/game/ScoreBoardService.rb +433 -0
  59. data/lib/game/ScoreService.rb +157 -0
  60. data/lib/geo/Geo.rb +51 -0
  61. data/lib/geo/GeoPoint.rb +43 -0
  62. data/lib/geo/GeoResponseBuilder.rb +145 -0
  63. data/lib/geo/GeoService.rb +506 -0
  64. data/lib/imageProcessor/Image.rb +42 -0
  65. data/lib/imageProcessor/ImageProcessorResponseBuilder.rb +40 -0
  66. data/lib/imageProcessor/ImageProcessorService.rb +1054 -0
  67. data/lib/log/Log.rb +49 -0
  68. data/lib/log/LogResponseBuilder.rb +61 -0
  69. data/lib/log/LogService.rb +920 -0
  70. data/lib/message/Queue.rb +50 -0
  71. data/lib/message/QueueResponseBuilder.rb +64 -0
  72. data/lib/message/QueueService.rb +469 -0
  73. data/lib/push/DeviceType.rb +56 -0
  74. data/lib/push/PushNotification.rb +38 -0
  75. data/lib/push/PushNotificationResposneBuilder.rb +74 -0
  76. data/lib/push/PushNotificationService.rb +458 -0
  77. data/lib/recommend/PreferenceData.rb +25 -0
  78. data/lib/recommend/Recommender.rb +48 -0
  79. data/lib/recommend/RecommenderResponseBuilder.rb +70 -0
  80. data/lib/recommend/RecommenderService.rb +1092 -0
  81. data/lib/recommend/RecommenderSimilarity.rb +52 -0
  82. data/lib/review/Review.rb +38 -0
  83. data/lib/review/ReviewResponseBuilder.rb +76 -0
  84. data/lib/review/ReviewService.rb +590 -0
  85. data/lib/session/Session.rb +43 -0
  86. data/lib/session/SessionResponseBuilder.rb +70 -0
  87. data/lib/session/SessionService.rb +427 -0
  88. data/lib/shopping/Cart.rb +77 -0
  89. data/lib/shopping/CartResponseBuilder.rb +118 -0
  90. data/lib/shopping/CartService.rb +902 -0
  91. data/lib/shopping/Catalogue.rb +79 -0
  92. data/lib/shopping/CatalogueResponseBuilder.rb +170 -0
  93. data/lib/shopping/CatalogueService.rb +649 -0
  94. data/lib/shopping/ItemData.rb +29 -0
  95. data/lib/shopping/PaymentStatus.rb +60 -0
  96. data/lib/social/Social.rb +35 -0
  97. data/lib/social/SocialResponseBuilder.rb +38 -0
  98. data/lib/social/SocialService.rb +585 -0
  99. data/lib/storage/OrderByType.rb +29 -0
  100. data/lib/storage/Query.rb +39 -0
  101. data/lib/storage/QueryBuilder.rb +118 -0
  102. data/lib/storage/Storage.rb +45 -0
  103. data/lib/storage/StorageResponseBuilder.rb +86 -0
  104. data/lib/storage/StorageService.rb +775 -0
  105. data/lib/upload/Upload.rb +40 -0
  106. data/lib/upload/UploadFileType.rb +83 -0
  107. data/lib/upload/UploadResponseBuilder.rb +58 -0
  108. data/lib/upload/UploadService.rb +960 -0
  109. data/lib/user/User.rb +102 -0
  110. data/lib/user/UserResponseBuilder.rb +105 -0
  111. data/lib/user/UserService.rb +1253 -0
  112. data/lib/util/util.rb +250 -0
  113. metadata +134 -9
  114. checksums.yaml +0 -7
@@ -0,0 +1,94 @@
1
+ require 'App42Response.rb'
2
+
3
+ module App42
4
+ module AppTab
5
+ #
6
+ # An enum that contains the months to be mentioned in the Bill.
7
+ #
8
+ class BillMonth < App42Response
9
+ unless (const_defined?(:JANUARY))
10
+ JANUARY = "JANUARY"
11
+ end
12
+ unless (const_defined?(:FEBRURAY))
13
+ FEBRURAY = "FEBRURAY"
14
+ end
15
+ unless (const_defined?(:MARCH))
16
+ MARCH = "MARCH"
17
+ end
18
+ unless (const_defined?(:APRIL))
19
+ APRIL = "APRIL"
20
+ end
21
+ unless (const_defined?(:MAY))
22
+ MAY = "MAY"
23
+ end
24
+ unless (const_defined?(:JUNE))
25
+ JUNE = "JUNE"
26
+ end
27
+ unless (const_defined?(:JULY))
28
+ JULY = "JULY"
29
+ end
30
+ unless (const_defined?(:AUGUST))
31
+ AUGUST = "AUGUST"
32
+ end
33
+ unless (const_defined?(:SEPTEMBER))
34
+ SEPTEMBER = "SEPTEMBER"
35
+ end
36
+ unless (const_defined?(:OCTOBER))
37
+ OCTOBER = "OCTOBER"
38
+ end
39
+ unless (const_defined?(:NOVEMBER))
40
+ NOVEMBER = "NOVEMBER"
41
+ end
42
+ unless (const_defined?(:DECEMBER))
43
+ DECEMBER = "DECEMBER"
44
+ end
45
+
46
+ #
47
+ # Sets the value of the BillMonth.
48
+ #
49
+ # @param string
50
+ # - the string of BillMonth
51
+ #
52
+ def enum(string)
53
+ return BillMonth.const_get(string)
54
+ end
55
+
56
+ #
57
+ # Returns the value of the BillMonth.
58
+ #
59
+ # @return the value of BillMonth.
60
+ #
61
+
62
+ def isAvailable(string)
63
+ if(string == "JANUARY")
64
+ return "JANUARY"
65
+ elsif(string == "FEBRURARY")
66
+ return "FEBRURARY"
67
+ elsif(string == "MARCH")
68
+ return "MARCH"
69
+ elsif(string == "APRIL")
70
+ return "APRIL"
71
+ elsif(string == "MAY")
72
+ return "MAY"
73
+ elsif(string == "JUNE")
74
+ return "JUNE"
75
+ elsif(string == "JULY")
76
+ return "JULY"
77
+ elsif(string == "AUGUST")
78
+ return "AUGUST"
79
+ elsif(string == "SEPTEMBER")
80
+ return "SEPTEMBER"
81
+ elsif(string == "OCTOBER")
82
+ return "OCTOBER"
83
+ elsif(string == "NOVEMBER")
84
+ return "NOVEMBER"
85
+ elsif(string == "DECEMBER")
86
+ return "DECEMBER";
87
+ else
88
+ return nil
89
+ end
90
+ end
91
+
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,242 @@
1
+ require 'json/pure'
2
+ require 'App42ResponseBuilder.rb'
3
+ require 'appTab/Bill.rb'
4
+ require 'appTab/BillMonth.rb'
5
+
6
+ module App42
7
+ module AppTab
8
+ #
9
+ #
10
+ # BillResponseBuilder class converts the JSON response retrieved from the
11
+ # server to the value object i.e Bill
12
+ #
13
+ #
14
+ class BillResponseBuilder < App42ResponseBuilder
15
+ #
16
+ # Converts the response in JSON format to the value object i.e Bill
17
+ #
18
+ # @param json
19
+ # - response in JSON format
20
+ #
21
+ # @return Bill object filled with json data
22
+ #
23
+ # @throws Exception
24
+ #
25
+ def buildResponse(json)
26
+ billsJsonObj = getServiceJSONObject("bills", json);
27
+ billJsonObj = billsJsonObj.fetch("bill");
28
+ bill = buildBillObject(billJsonObj);
29
+ bill.strResponse = json
30
+ bill.isResponseSuccess = isResponseSuccess(json)
31
+ return bill
32
+ end
33
+
34
+ #
35
+ # Converts the Bill JSON object to the value object i.e Bill
36
+ #
37
+ # @param billJSONObj
38
+ # - Bill data as JSONObject
39
+ #
40
+ # @return Bill object filled with json data
41
+ #
42
+
43
+ def buildBillObject(billJSONObj)
44
+ bill = Bill.new
45
+ buildObjectFromJSONTree(bill, billJSONObj)
46
+
47
+ if billJSONObj.key?("storageTransaction")
48
+ storageTransJson = billJSONObj["storageTransaction"]
49
+ storageTrans = StorageTransaction.new()
50
+ transactionList = Array.new
51
+ storageTrans.transactionList=(transactionList)
52
+ buildObjectFromJSONTree(storageTrans, storageTransJson)
53
+
54
+ if storageTransJson.key?("transactions") && storageTransJson["transactions"].key?("transaction")
55
+
56
+ if storageTransJson["transactions"].fetch("transaction").instance_of?(Hash)
57
+ transactionJsonObj = storageTransJson.fetch("transactions").fetch("transaction");
58
+ transaction = App42::AppTab::TransactionStor.new(storageTrans)
59
+ buildObjectFromJSONTree(transaction, transactionJsonObj)
60
+
61
+ else
62
+
63
+ transactionJsonArray = storageTransJson.fetch("transactions").fetch("transaction");
64
+
65
+ transactionJsonArray.length.times do |i|
66
+ transactionJsonObj = userJSONArray[i]
67
+ transaction = App42::AppTab::TransactionStor.new(storageTrans)
68
+ buildObjectFromJSONTree(transaction, transactionJsonObj);
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ if billJSONObj.key?("timeTransaction")
75
+ storageTransJson = billJSONObj.fetch("timeTransaction");
76
+ timeTrans = TimeTransaction.new()
77
+ transactionList = Array.new
78
+ timeTrans.transactionList=(transactionList)
79
+ buildObjectFromJSONTree(timeTrans,storageTransJson);
80
+
81
+ if storageTransJson.key?("transactions") && storageTransJson.fetch("transactions").key?("transaction")
82
+
83
+ if storageTransJson.fetch("transactions").fetch("transaction").instance_of?(Hash)
84
+ transactionJsonObj = storageTransJson.fetch("transactions").fetch("transaction");
85
+ transaction = App42::AppTab::TransactionTim.new(timeTrans)
86
+ buildObjectFromJSONTree(transaction, transactionJsonObj);
87
+
88
+ else
89
+
90
+ transactionJsonArray = storageTransJson.fetch("transactions").fetch("transaction");
91
+
92
+ transactionJsonArray.length.times do |i|
93
+ transactionJsonObj = transactionJsonArray.fetch(i);
94
+ transaction = App42::AppTab::TransactionTim.new(timeTrans)
95
+ buildObjectFromJSONTree(transaction, transactionJsonObj);
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+ if billJSONObj.key?("bandWidthTransaction")
102
+ storageTransJson = billJSONObj.fetch("bandWidthTransaction");
103
+ bwTrans = BandwidthTransaction.new()
104
+ transactionList = Array.new
105
+ bwTrans.transactionList=(transactionList)
106
+ buildObjectFromJSONTree(bwTrans,storageTransJson);
107
+
108
+ if storageTransJson.key?("transactions") && storageTransJson.fetch("transactions").key?("transaction")
109
+
110
+ if storageTransJson.fetch("transactions").fetch("transaction").instance_of?(Hash)
111
+
112
+ transactionJsonObj = storageTransJson.fetch("transactions").fetch("transaction");
113
+ transaction = App42::AppTab::TransactionBand.new(bwTrans)
114
+ buildObjectFromJSONTree(transaction, transactionJsonObj);
115
+
116
+ else
117
+
118
+ transactionJsonArray = storageTransJson.fetch("transactions").fetch("transaction");
119
+
120
+ transactionJsonArray.length.times do |i|
121
+ transactionJsonObj = transactionJsonArray.fetch(i);
122
+ transaction = App42::AppTab::TransactionBand.new(bwTrans)
123
+ buildObjectFromJSONTree(transaction, transactionJsonObj);
124
+ end
125
+ end
126
+ end
127
+ end
128
+
129
+ if billJSONObj.key?("levelTransaction")
130
+ storageTransJson = billJSONObj.fetch("levelTransaction");
131
+ levelTrans = LevelTransaction.new()
132
+ transactionList = Array.new
133
+ levelTrans.transactionList=(transactionList)
134
+ buildObjectFromJSONTree(levelTrans, storageTransJson);
135
+
136
+ if storageTransJson.key?("transactions") && storageTransJson.fetch("transactions").key?("transaction")
137
+
138
+ if storageTransJson.fetch("transactions").fetch("transaction").instance_of?(Hash)
139
+ transactionJsonObj = storageTransJson.fetch("transactions").fetch("transaction");
140
+ transaction = App42::AppTab::TransactionLev.new(levelTrans)
141
+ buildObjectFromJSONTree(transaction, transactionJsonObj);
142
+ else
143
+
144
+ transactionJsonArray = storageTransJson.fetch("transactions").fetch("transaction");
145
+ transactionJsonArray.length.times do |i|
146
+ transactionJsonObj = transactionJsonArray.fetch(i);
147
+ transaction = App42::AppTab::TransactionLev.new(levelTrans)
148
+ buildObjectFromJSONTree(transaction, transactionJsonObj);
149
+ end
150
+ end
151
+ end
152
+ end
153
+
154
+ if billJSONObj.key?("featureTransaction")
155
+ storageTransJson = billJSONObj.fetch("featureTransaction");
156
+ featureTrans = FeatureTransaction.new()
157
+ transactionList = Array.new
158
+ featureTrans.transactionList=(transactionList)
159
+ buildObjectFromJSONTree(featureTrans,storageTransJson);
160
+
161
+ if storageTransJson.key?("transactions") && storageTransJson.fetch("transactions").key?("transaction")
162
+
163
+ if storageTransJson.fetch("transactions").fetch("transaction").instance_of?(Hash)
164
+ transactionJsonObj = storageTransJson.fetch("transactions").fetch("transaction");
165
+ transaction = App42::AppTab::TransactionFeat.new(featureTrans)
166
+ buildObjectFromJSONTree(transaction, transactionJsonObj);
167
+
168
+ else
169
+
170
+ transactionJsonArray = storageTransJson.fetch("transactions").fetch("transaction");
171
+
172
+ transactionJsonArray.length.times do |i|
173
+ transactionJsonObj = transactionJsonArray.fetch(i);
174
+ transaction = App42::AppTab::TransactionFeat.new(featureTrans)
175
+ buildObjectFromJSONTree(transaction, transactionJsonObj);
176
+ end
177
+ end
178
+ end
179
+ end
180
+
181
+ if billJSONObj.key?("licenseTransaction")
182
+ storageTransJson = billJSONObj.fetch("licenseTransaction");
183
+ licenseTrans = LicenseTransaction.new()
184
+ transactionList = Array.new
185
+ licenseTrans.transactionList=(transactionList)
186
+ buildObjectFromJSONTree(licenseTrans, storageTransJson);
187
+
188
+ if storageTransJson.key?("transactions") && storageTransJson.fetch("transactions").key?("transaction")
189
+
190
+ if storageTransJson.fetch("transactions").fetch("transaction").instance_of?(Hash)
191
+
192
+ transactionJsonObj = storageTransJson.fetch("transactions").fetch("transaction");
193
+ transaction = App42::AppTab::TransactionLic.new(licenseTrans)
194
+ buildObjectFromJSONTree(transaction, transactionJsonObj);
195
+
196
+ else
197
+
198
+ transactionJsonArray = storageTransJson.fetch("transactions").fetch("transaction");
199
+
200
+ transactionJsonArray.length.times do |i|
201
+ transactionJsonObj = transactionJsonArray.fetch(i);
202
+ transaction = App42::AppTab::TransactionLic.new(licenseTrans)
203
+ buildObjectFromJSONTree(transaction, transactionJsonObj);
204
+ end
205
+ end
206
+ end
207
+ end
208
+
209
+ return bill;
210
+ end
211
+
212
+ #
213
+ # Converts the response in JSON format to the list of value objects i.e
214
+ # Bill
215
+ #
216
+ # @param json
217
+ # - response in JSON format
218
+ #
219
+ # @return List of Bill object filled with json data
220
+ #
221
+ #
222
+
223
+ def buildArrayResponse(json)
224
+ billsJSONObj = getServiceJSONObject("bill", json);
225
+ billJSONArray = billsJSONObj["bill"]
226
+ billList = Array.new()
227
+
228
+ billJSONArray.length.times do |i|
229
+ billJSONObject = billJSONArray[i]
230
+ bill = buildBillObject(billJSONObject);
231
+ bill.strResponse=json
232
+ bill.isResponseSuccess = isResponseSuccess(json)
233
+ billList.push(bill)
234
+ end
235
+
236
+ return billList
237
+ end
238
+
239
+ end
240
+ end
241
+ end
242
+
@@ -0,0 +1,457 @@
1
+ require 'connection/RESTConnection.rb'
2
+ require 'util/util.rb'
3
+ require 'json/pure'
4
+ require 'rubygems'
5
+ require 'App42Response.rb'
6
+ require 'appTab/BillResponseBuilder.rb'
7
+ require 'appTab/Bill.rb'
8
+ require 'appTab/BillMonth.rb'
9
+
10
+ module App42
11
+ module AppTab
12
+ #
13
+ # AppTab - Billing service. This service is used along with the Usage service. It generates
14
+ # Bill for a particular based on Usage Scheme. For e.g. if user sid's bill has to be seen
15
+ # for May and 2012. This service will list all the charging transactions and calculate the bill for May
16
+ # and tell the total usage and price. The calculation is done based on the Price which is given during
17
+ # scheme creation, the unit of charging and corresponding usage.
18
+ # AppTab currently just maintains the data and does calculation. How the Bill is rendered and the interface
19
+ # with Payment Gateway is left with the App developer.
20
+ #
21
+ # @see Usage
22
+ # @see Bill
23
+ #
24
+ class BillService
25
+ #
26
+ # this is a constructor that takes
27
+ #
28
+ # @param apiKey
29
+ # @param secretKey
30
+ # @param baseURL
31
+ #
32
+ def initialize(api_key, secret_key, base_url)
33
+ puts "BillService->initialize"
34
+ @api_key = api_key
35
+ @secret_key = secret_key
36
+ @base_url = base_url
37
+ @resource = "bill"
38
+ @version = "1.0"
39
+ end
40
+
41
+ #
42
+ # Get usage for Scheme based on Month and Year. This is useful to show the
43
+ # user the charging details of the User for the Scheme
44
+ #
45
+ # @param userName
46
+ # - The user for which the charging information has to be
47
+ # fetched
48
+ # @param usageName
49
+ # - The name of the Scheme
50
+ # @param billMonth
51
+ # - The month name for which the usage has to be fetched e.g.
52
+ # BillMonth.JANUARY, BillMonth.DECEMBER
53
+ # @param year
54
+ # - The year for which the usage has to be fetched e.g. 2012,
55
+ # 2011
56
+ #
57
+ # @returns All the charging transactions with the total usage and total
58
+ # price for that month
59
+ #
60
+ # @throws App42Exception
61
+ #
62
+
63
+ def usage_time_by_month_and_year(userName, usageName, billMonth, year)
64
+ puts "usageTimeByMonthAndYear Called "
65
+ puts "Base url #{@base_url}"
66
+ response = nil;
67
+ billObj = nil;
68
+ billObj = Bill.new
69
+ util = Util.new
70
+ util.throwExceptionIfNullOrBlank(userName, "UserName");
71
+ util.throwExceptionIfNullOrBlank(usageName, "UsageName");
72
+ util.throwExceptionIfNullOrBlank(billMonth, "billMonth");
73
+ util.throwExceptionIfNullOrBlank(year, "Year");
74
+ begin
75
+ connection = App42::Connection::RESTConnection.new(@base_url)
76
+ query_params = Hash.new
77
+ params = {
78
+ 'apiKey'=> @api_key,
79
+ 'version' => @version,
80
+ 'timeStamp' => util.get_timestamp_utc,
81
+ }
82
+ query_params = params.clone
83
+ bm = BillMonth.new()
84
+ params.store("usageName", usageName);
85
+ params.store("year", "" + (year.to_i).to_s);
86
+ params.store("month", bm.enum(billMonth));
87
+ params.store("userName", userName);
88
+ signature = util.sign(@secret_key, params)
89
+ resource_url = "#{@version}/#{@resource}/time/#{usageName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}"
90
+ response = connection.get(signature, resource_url, query_params)
91
+ billObj = BillResponseBuilder.new().buildResponse(response)
92
+ rescue App42Exception =>e
93
+ raise e
94
+ rescue Exception => e
95
+ raise App42Exception.new(e)
96
+ end
97
+ return billObj
98
+ end
99
+
100
+ #
101
+ # Get usage for Scheme based on Month and Year. This is useful to show the
102
+ # user the charging details of the User for the Scheme
103
+ #
104
+ # @param userName
105
+ # - The user for which the charging information has to be
106
+ # fetched
107
+ # @param usageName
108
+ # - The name of the Scheme
109
+ # @param billMonth
110
+ # - The month name for which the usage has to be fetched e.g.
111
+ # BillMonth.JANUARY, BillMonth.DECEMBER
112
+ # @param year
113
+ # - The year for which the usage has to be fetched e.g. 2012,
114
+ # 2011
115
+ #
116
+ # @returns All the charging transactions with the total usage and total
117
+ # price for that month
118
+ #
119
+ # @throws App42Exception
120
+ #
121
+
122
+ def usage_storage_by_month_and_year(userName, usageName, billMonth, year)
123
+ puts "usageStorageByMonthAndYear Called "
124
+ puts "Base url #{@base_url}"
125
+ response = nil;
126
+ billObj = nil;
127
+ billObj = Bill.new
128
+ util = Util.new
129
+ util.throwExceptionIfNullOrBlank(userName, "UserName");
130
+ util.throwExceptionIfNullOrBlank(usageName, "UsageName");
131
+ util.throwExceptionIfNullOrBlank(billMonth, "billMonth");
132
+ util.throwExceptionIfNullOrBlank(year, "Year");
133
+ begin
134
+ connection = App42::Connection::RESTConnection.new(@base_url)
135
+ query_params = Hash.new
136
+ params = {
137
+ 'apiKey'=> @api_key,
138
+ 'version' => @version,
139
+ 'timeStamp' => util.get_timestamp_utc,
140
+ }
141
+ query_params = params.clone
142
+ bm = BillMonth.new()
143
+ params.store("usageName", usageName);
144
+ params.store("year", "" + (year.to_i).to_s);
145
+ params.store("month", bm.enum(billMonth));
146
+ params.store("userName", userName);
147
+ signature = util.sign(@secret_key, params)
148
+ resource_url = "#{@version}/#{@resource}/storage/#{usageName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}"
149
+ response = connection.get(signature, resource_url, query_params)
150
+ billObj = BillResponseBuilder.new().buildResponse(response)
151
+ rescue App42Exception =>e
152
+ raise e
153
+ rescue Exception => e
154
+ raise App42Exception.new(e)
155
+ end
156
+ return billObj
157
+ end
158
+
159
+ #
160
+ # Get usage for Scheme based on Month and Year. This is useful to show the
161
+ # user the charging details of the User for the Scheme
162
+ #
163
+ # @param userName
164
+ # - The user for which the charging information has to be
165
+ # fetched
166
+ # @param usageName
167
+ # - The name of the Scheme
168
+ # @param billMonth
169
+ # - The month name for which the usage has to be fetched e.g.
170
+ # BillMonth.JANUARY, BillMonth.DECEMBER
171
+ # @param year
172
+ # - The year for which the usage has to be fetched e.g. 2012,
173
+ # 2011
174
+ #
175
+ # @returns All the charging transactions with the total usage and total
176
+ # price for that month
177
+ #
178
+ # @throws App42Exception
179
+ #
180
+
181
+ def usage_bandwidth_by_month_and_year(userName, usageName, billMonth, year)
182
+ puts "usageBandwidthByMonthAndYear Called "
183
+ puts "Base url #{@base_url}"
184
+ response = nil;
185
+ billObj = nil;
186
+ billObj = Bill.new
187
+ util = Util.new
188
+ util.throwExceptionIfNullOrBlank(userName, "UserName");
189
+ util.throwExceptionIfNullOrBlank(usageName, "UsageName");
190
+ util.throwExceptionIfNullOrBlank(billMonth, "billMonth");
191
+ util.throwExceptionIfNullOrBlank(year, "Year");
192
+ begin
193
+ connection = App42::Connection::RESTConnection.new(@base_url)
194
+ query_params = Hash.new
195
+ params = {
196
+ 'apiKey'=> @api_key,
197
+ 'version' => @version,
198
+ 'timeStamp' => util.get_timestamp_utc,
199
+ }
200
+ query_params = params.clone
201
+ bm = BillMonth.new()
202
+ params.store("usageName", usageName);
203
+ params.store("year", "" + (year.to_i).to_s);
204
+ params.store("month", bm.enum(billMonth));
205
+ params.store("userName", userName);
206
+ signature = util.sign(@secret_key, params)
207
+ resource_url = "#{@version}/#{@resource}/bandwidth/#{usageName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}"
208
+ response = connection.get(signature, resource_url, query_params)
209
+ billObj = BillResponseBuilder.new().buildResponse(response)
210
+ rescue App42Exception =>e
211
+ raise e
212
+ rescue Exception => e
213
+ raise App42Exception.new(e)
214
+ end
215
+ return billObj
216
+ end
217
+
218
+ #
219
+ # Get usage for Scheme based on Month and Year. This is useful to show the
220
+ # user the charging details of the User for the Scheme
221
+ #
222
+ # @param userName
223
+ # - The user for which the charging information has to be
224
+ # fetched
225
+ # @param usageName
226
+ # - The name of the Scheme
227
+ # @param billMonth
228
+ # - The month name for which the usage has to be fetched e.g.
229
+ # BillMonth.JANUARY, BillMonth.DECEMBER
230
+ # @param year
231
+ # - The year for which the usage has to be fetched e.g. 2012,
232
+ # 2011
233
+ #
234
+ # @returns All the charging transactions with the total usage and total
235
+ # price for that month
236
+ #
237
+ # @throws App42Exception
238
+ #
239
+
240
+ def usage_level_by_month_and_year(userName, usageName, billMonth, year)
241
+ puts "usageLevelByMonthAndYear Called "
242
+ puts "Base url #{@base_url}"
243
+ response = nil;
244
+ billObj = nil;
245
+ billObj = Bill.new
246
+ util = Util.new
247
+ util.throwExceptionIfNullOrBlank(userName, "UserName");
248
+ util.throwExceptionIfNullOrBlank(usageName, "UsageName");
249
+ util.throwExceptionIfNullOrBlank(billMonth, "billMonth");
250
+ util.throwExceptionIfNullOrBlank(year, "Year");
251
+ begin
252
+ connection = App42::Connection::RESTConnection.new(@base_url)
253
+ query_params = Hash.new
254
+ params = {
255
+ 'apiKey'=> @api_key,
256
+ 'version' => @version,
257
+ 'timeStamp' => util.get_timestamp_utc,
258
+ }
259
+ query_params = params.clone
260
+ bm = BillMonth.new()
261
+ params.store("usageName", usageName);
262
+ params.store("year", "" + (year.to_i).to_s);
263
+ params.store("month", bm.enum(billMonth));
264
+ params.store("userName", userName);
265
+ signature = util.sign(@secret_key, params)
266
+ resource_url = "#{@version}/#{@resource}/level/#{usageName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}"
267
+ response = connection.get(signature, resource_url, query_params)
268
+ billObj = BillResponseBuilder.new().buildResponse(response)
269
+ rescue App42Exception =>e
270
+ raise e
271
+ rescue Exception => e
272
+ raise App42Exception.new(e)
273
+ end
274
+ return billObj
275
+ end
276
+
277
+ #
278
+ # Get usage for Scheme based on Month and Year. This is useful to show the
279
+ # user the charging details of the User for the Scheme
280
+ #
281
+ # @param userName
282
+ # - The user for which the charging information has to be
283
+ # fetched
284
+ # @param usageName
285
+ # - The name of the Scheme
286
+ # @param billMonth
287
+ # - The month name for which the usage has to be fetched e.g.
288
+ # BillMonth.JANUARY, BillMonth.DECEMBER
289
+ # @param year
290
+ # - The year for which the usage has to be fetched e.g. 2012,
291
+ # 2011
292
+ #
293
+ # @returns All the charging transactions with the total usage and total
294
+ # price for that month
295
+ #
296
+ # @throws App42Exception
297
+ #
298
+
299
+ def usage_one_time_by_month_and_year(userName, usageName, billMonth, year)
300
+ puts "usageOneTimeByMonthAndYear Called "
301
+ puts "Base url #{@base_url}"
302
+ response = nil;
303
+ billObj = nil;
304
+ billObj = Bill.new
305
+ util = Util.new
306
+ util.throwExceptionIfNullOrBlank(userName, "UserName");
307
+ util.throwExceptionIfNullOrBlank(usageName, "UsageName");
308
+ util.throwExceptionIfNullOrBlank(billMonth, "billMonth");
309
+ util.throwExceptionIfNullOrBlank(year, "Year");
310
+ begin
311
+ connection = App42::Connection::RESTConnection.new(@base_url)
312
+ query_params = Hash.new
313
+ params = {
314
+ 'apiKey'=> @api_key,
315
+ 'version' => @version,
316
+ 'timeStamp' => util.get_timestamp_utc,
317
+ }
318
+ query_params = params.clone
319
+ bm = BillMonth.new()
320
+ params.store("usageName", usageName);
321
+ params.store("year", "" + (year.to_i).to_s);
322
+ params.store("month", bm.enum(billMonth));
323
+ params.store("userName", userName);
324
+ signature = util.sign(@secret_key, params)
325
+ resource_url = "#{@version}/#{@resource}/oneTime/#{usageName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}"
326
+ response = connection.get(signature, resource_url, query_params)
327
+ billObj = BillResponseBuilder.new().buildResponse(response)
328
+ rescue App42Exception =>e
329
+ raise e
330
+ rescue Exception => e
331
+ raise App42Exception.new(e)
332
+ end
333
+ return billObj
334
+ end
335
+
336
+ #
337
+ # Get usage for Scheme based on Month and Year. This is useful to show the
338
+ # user the charging details of the User for the Scheme
339
+ #
340
+ # @param userName
341
+ # - The user for which the charging information has to be
342
+ # fetched
343
+ # @param usageName
344
+ # - The name of the Scheme
345
+ # @param billMonth
346
+ # - The month name for which the usage has to be fetched e.g.
347
+ # BillMonth.JANUARY, BillMonth.DECEMBER
348
+ # @param year
349
+ # - The year for which the usage has to be fetched e.g. 2012,
350
+ # 2011
351
+ #
352
+ # @returns All the charging transactions with the total usage and total
353
+ # price for that month
354
+ #
355
+ # @throws App42Exception
356
+ #
357
+
358
+ def usage_feature_by_month_and_year(userName, usageName, billMonth, year)
359
+ puts "usageFeatureByMonthAndYear Called "
360
+ puts "Base url #{@base_url}"
361
+ response = nil;
362
+ billObj = nil;
363
+ billObj = Bill.new
364
+ util = Util.new
365
+ util.throwExceptionIfNullOrBlank(userName, "UserName");
366
+ util.throwExceptionIfNullOrBlank(usageName, "UsageName");
367
+ util.throwExceptionIfNullOrBlank(billMonth, "billMonth");
368
+ util.throwExceptionIfNullOrBlank(year, "Year");
369
+ begin
370
+ connection = App42::Connection::RESTConnection.new(@base_url)
371
+ query_params = Hash.new
372
+ params = {
373
+ 'apiKey'=> @api_key,
374
+ 'version' => @version,
375
+ 'timeStamp' => util.get_timestamp_utc,
376
+ }
377
+ query_params = params.clone
378
+ bm = BillMonth.new()
379
+ params.store("usageName", usageName);
380
+ params.store("year", "" + (year.to_i).to_s);
381
+ params.store("month", bm.enum(billMonth));
382
+ params.store("userName", userName);
383
+ signature = util.sign(@secret_key, params)
384
+ resource_url = "#{@version}/#{@resource}/feature/#{usageName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}"
385
+ response = connection.get(signature, resource_url, query_params)
386
+ billObj = BillResponseBuilder.new().buildResponse(response)
387
+ rescue App42Exception =>e
388
+ raise e
389
+ rescue Exception => e
390
+ raise App42Exception.new(e)
391
+ end
392
+ return billObj
393
+ end
394
+
395
+ #
396
+ # Get usage for Scheme based on Month and Year. This is useful to show the
397
+ # user the charging details of the User for the Scheme
398
+ #
399
+ # @param userName
400
+ # - The user for which the charging information has to be
401
+ # fetched
402
+ # @param licenseName
403
+ # - The name of the License
404
+ # @param billMonth
405
+ # - The month name for which the usage has to be fetched e.g.
406
+ # BillMonth.JANUARY, BillMonth.DECEMBER
407
+ # @param year
408
+ # - The year for which the usage has to be fetched e.g. 2012,
409
+ # 2011
410
+ #
411
+ # @returns All the charging transactions with the total usage and total
412
+ # price for that month
413
+ #
414
+ # @throws App42Exception
415
+ #
416
+ #
417
+
418
+ def usage_license_by_month_and_year(userName, licenseName, billMonth, year)
419
+ puts "usageLicenseByMonthAndYear Called "
420
+ puts "Base url #{@base_url}"
421
+ response = nil;
422
+ billObj = nil;
423
+ billObj = Bill.new
424
+ util = Util.new
425
+ util.throwExceptionIfNullOrBlank(userName, "UserName");
426
+ util.throwExceptionIfNullOrBlank(licenseName, "LicenseName");
427
+ util.throwExceptionIfNullOrBlank(billMonth, "billMonth");
428
+ util.throwExceptionIfNullOrBlank(year, "Year");
429
+ begin
430
+ connection = App42::Connection::RESTConnection.new(@base_url)
431
+ query_params = Hash.new
432
+ params = {
433
+ 'apiKey'=> @api_key,
434
+ 'version' => @version,
435
+ 'timeStamp' => util.get_timestamp_utc,
436
+ }
437
+ query_params = params.clone
438
+ bm = BillMonth.new()
439
+ params.store("licenseName", licenseName);
440
+ params.store("year", "" + (year.to_i).to_s);
441
+ params.store("month", bm.enum(billMonth));
442
+ params.store("userName", userName);
443
+ signature = util.sign(@secret_key, params)
444
+ resource_url = "#{@version}/#{@resource}/license/#{licenseName}/#{(year.to_i).to_s}/#{billMonth}/#{userName}"
445
+ response = connection.get(signature, resource_url, query_params)
446
+ billObj = BillResponseBuilder.new().buildResponse(response)
447
+ rescue App42Exception =>e
448
+ raise e
449
+ rescue Exception => e
450
+ raise App42Exception.new(e)
451
+ end
452
+ return billObj
453
+ end
454
+
455
+ end
456
+ end
457
+ end