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,41 @@
1
+ # -----------------------------------------------------------------------
2
+ # Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
3
+ # -----------------------------------------------------------------------
4
+
5
+ require 'App42Response.rb'
6
+
7
+ #
8
+ #
9
+ # This Email object is the value object which contains the properties of Email.
10
+ #
11
+ #
12
+
13
+ module App42
14
+ module AppTab
15
+ class Test < App42Response
16
+ attr_accessor :name, :description, :promoCode, :discountList, :discountDetails
17
+
18
+ @name
19
+ @description
20
+ @promoCode
21
+ @discountDetails
22
+ @discountList = Array.new()
23
+ end
24
+
25
+ class Discount
26
+ attr_accessor :percentage, :usage, :startDate, :endDate
27
+ @percentage
28
+ @usage
29
+ @startDate
30
+ @endDate
31
+ #
32
+ # This is a constructor that takes no parameter
33
+ #
34
+ #
35
+ def initialize(dis)
36
+ dis.discountDetails = (self)
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,49 @@
1
+ require 'App42Response.rb'
2
+
3
+ module App42
4
+ module AppTab
5
+ #
6
+ # An enum that contains the Time Unit to be mentioned in the Bill.
7
+ #
8
+ class TimeUnit < App42Response
9
+ unless (const_defined?(:SECONDS))
10
+ SECONDS = "SECONDS"
11
+ end
12
+ unless (const_defined?(:MINUTES))
13
+ MINUTES = "MINUTES"
14
+ end
15
+ unless (const_defined?(:HOURS))
16
+ HOURS = "HOURS"
17
+ end
18
+
19
+ #
20
+ # Sets the value of the TimeUnit.
21
+ #
22
+ # @param string
23
+ # - the string of TimeUnit
24
+ #
25
+ def enum(string)
26
+ return TimeUnit.const_get(string)
27
+ end
28
+
29
+ #
30
+ # Returns the value of the TimeUnit.
31
+ #
32
+ # @return the value of TimeUnit.
33
+ #
34
+
35
+ def isAvailable(string)
36
+ if(string == "SECONDS")
37
+ return "SECONDS"
38
+ elsif(string == "MINUTES")
39
+ return "MINUTES"
40
+ elsif(string == "HOURS")
41
+ return "HOURS";
42
+ else
43
+ return nil
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,206 @@
1
+ require 'App42Response.rb'
2
+
3
+ module App42
4
+ module AppTab
5
+ #
6
+ #
7
+ # This Usage object is the value object which contains the properties of Usage
8
+ # along with the setter & getter for those properties.
9
+ #
10
+ #
11
+ class Usage < App42Response
12
+ attr_accessor :levelList, :oneTimeList, :featureList, :bandwidthList, :storageList, :timeList, :customList
13
+ @levelList = Array.new
14
+ @oneTimeList = Array.new
15
+ @featureList = Array.new
16
+ @bandwidthList = Array.new
17
+ @storageList = Array.new
18
+ @timeList = Array.new
19
+ # @customList = Array.new
20
+ end
21
+
22
+ class Level
23
+ attr_accessor :name, :price, :currency, :state, :description, :user
24
+ @name
25
+ @price
26
+ @currency
27
+ @state
28
+ @description
29
+ @user
30
+ #
31
+ # This is a constructor that takes no parameter
32
+ #
33
+ def initialize(usage)
34
+ usage.levelList.push(self)
35
+ end
36
+
37
+ #
38
+ # Returns the Usage Response in JSON format.
39
+ #
40
+ # @return the response in JSON format.
41
+ #
42
+
43
+ def to_s
44
+ return "Name : #{@name}" + "Price : #{@price}" + "Currency : #{@currency}" + "State : #{@state}" + "Description : #{@description}";
45
+ end
46
+
47
+ end
48
+
49
+ class OneTime
50
+ attr_accessor :name, :price, :currency, :state,:description,:user
51
+ @name
52
+ @price
53
+ @currency
54
+ @state
55
+ @description
56
+ @user
57
+ #
58
+ # This is a constructor that takes no parameter
59
+ #
60
+ def initialize(usage)
61
+ usage.oneTimeList.push(self)
62
+ end
63
+
64
+ #
65
+ # Returns the Usage Response in JSON format.
66
+ #
67
+ # @return the response in JSON format.
68
+ #
69
+
70
+ def to_s
71
+ return "Name : #{@name}" + "Price : #{@price}" + "Currency : #{@currency}" + "State : #{@state}" + "Description : #{@description}";
72
+ end
73
+
74
+ end
75
+
76
+ class Feature
77
+ attr_accessor :name, :price, :currency, :state,:description,:user
78
+ @name
79
+ @price
80
+ @currency
81
+ @state
82
+ @description
83
+ @user
84
+ #
85
+ # This is a constructor that takes no parameter
86
+ #
87
+ def initialize(usage)
88
+ usage.featureList.push(self)
89
+ end
90
+
91
+ #
92
+ # Returns the Usage Response in JSON format.
93
+ #
94
+ # @return the response in JSON format.
95
+ #
96
+
97
+ def to_s
98
+ return "Name : #{@name}" + "Price : #{@price}" + "Currency : #{@currency}" + "State : #{@state}" + "Description : #{@description}";
99
+ end
100
+
101
+ end
102
+
103
+ class Bandwidth
104
+ attr_accessor :name, :bandwidth, :unit, :price, :currency, :state,:description,:user
105
+ @name
106
+ @bandwidth
107
+ @unit
108
+ @price
109
+ @currency
110
+ @state
111
+ @description
112
+ @user
113
+ #
114
+ # This is a constructor that takes no parameter
115
+ #
116
+ def initialize(usage)
117
+ usage.bandwidthList.push(self)
118
+ end
119
+
120
+ #
121
+ # Returns the Usage Response in JSON format.
122
+ #
123
+ # @return the response in JSON format.
124
+ #
125
+
126
+ def to_s
127
+ return "Name : #{@name}" + "Price : #{@price}" + "Currency : #{@currency}" + "State : #{@state}" + "Description : #{@description}";
128
+ end
129
+
130
+ end
131
+
132
+ class Storage
133
+ attr_accessor :name, :space, :unit, :price, :currency, :state,:description,:user
134
+ @name
135
+ @space
136
+ @unit
137
+ @price
138
+ @currency
139
+ @state
140
+ @description
141
+ @user
142
+ #
143
+ # This is a constructor that takes no parameter
144
+ #
145
+ def initialize(usage)
146
+ usage.storageList.push(self)
147
+ end
148
+
149
+ #
150
+ # Returns the Usage Response in JSON format.
151
+ #
152
+ # @return the response in JSON format.
153
+ #
154
+
155
+ def to_s
156
+ return "Name : #{@name}" + "Price : #{@price}" + "Currency : #{@currency}" + "State : #{@state}" + "Description : #{@description}";
157
+ end
158
+
159
+ end
160
+
161
+ class Time
162
+ attr_accessor :name, :time, :unit, :price, :currency, :state, :description, :user
163
+ @name
164
+ @time
165
+ @unit
166
+ @price
167
+ @currency
168
+ @state
169
+ @description
170
+ @user
171
+ #
172
+ # This is a constructor that takes no parameter
173
+ #
174
+ def initialize(usage)
175
+ usage.timeList.push(self)
176
+ end
177
+
178
+ #
179
+ # Returns the Usage Response in JSON format.
180
+ #
181
+ # @return the response in JSON format.
182
+ #
183
+
184
+ def to_s
185
+ return "Name : #{@name}" + "Price : #{@price}" + "Currency : #{@currency}" + "State : #{@state}" + "Description : #{@description}";
186
+ end
187
+
188
+ end
189
+
190
+ # class Custom
191
+ # attr_accessor :name, :type, :unit, :price, :currency, :state, :description, :user
192
+ # @name
193
+ # @type
194
+ # @unit
195
+ # @price
196
+ # @currency
197
+ # @state
198
+ # @description
199
+ # @user
200
+ # def initialize(usage)
201
+ # usage.customList.push(self)
202
+ # end
203
+ # end
204
+
205
+ end
206
+ end
@@ -0,0 +1,152 @@
1
+ require 'json/pure'
2
+ require 'App42ResponseBuilder.rb'
3
+ require 'appTab/Usage.rb'
4
+ require 'appTab/BandwidthUnit.rb'
5
+ require 'appTab/StorageUnit.rb'
6
+ require 'appTab/TimeUnit.rb'
7
+
8
+ module App42
9
+ module AppTab
10
+ #
11
+ #
12
+ # UsageResponseBuilder class converts the JSON response retrieved from the
13
+ # server to the value object i.e Usage
14
+ #
15
+ #
16
+ class UsageResponseBuilder < App42ResponseBuilder
17
+ #
18
+ # Converts the response in JSON format to the value object i.e Usage
19
+ #
20
+ # @param json
21
+ # - response in JSON format
22
+ #
23
+ # @return Usage object filled with json data
24
+ #
25
+ # @raise Exception
26
+ #
27
+ def buildResponse(json)
28
+ appTabJSONObj = getServiceJSONObject("appTab", json);
29
+ usageJsonObj = appTabJSONObj.fetch("usages").fetch("usage");
30
+ usage = Usage.new
31
+ usage.strResponse = json
32
+ usage.isResponseSuccess = isResponseSuccess(json)
33
+ buildObjectFromJSONTree(usage, usageJsonObj);
34
+
35
+ if usageJsonObj.key?("level")
36
+ levelList = Array.new
37
+ usage.levelList=(levelList)
38
+ if usageJsonObj.fetch("level").instance_of?(Hash)
39
+ levelJSONObj = usageJsonObj.fetch("level");
40
+ level = App42::AppTab::Level.new(usage)
41
+ buildObjectFromJSONTree(level, levelJSONObj);
42
+ else
43
+ levelJSONArray = usageJsonObj.fetch("level");
44
+ levelJSONArray.length.times do |i|
45
+ levelJSONObj = levelJSONArray.fetch(i);
46
+ level = App42::AppTab::Level.new(usage)
47
+ buildObjectFromJSONTree(level, levelJSONObj);
48
+ end
49
+ end
50
+
51
+ elsif usageJsonObj.key?("oneTime")
52
+ oneTimeList = Array.new
53
+ usage.oneTimeList=(oneTimeList)
54
+ if usageJsonObj.fetch("oneTime").instance_of?(Hash)
55
+ oneTimeJSONObj = usageJsonObj.fetch("oneTime");
56
+ oneTime = App42::AppTab::OneTime.new(usage)
57
+ buildObjectFromJSONTree(oneTime, oneTimeJSONObj);
58
+ else
59
+ oneTimeJSONArray = usageJsonObj.fetch("oneTime");
60
+ oneTimeJSONArray.length.times do |i|
61
+ oneTimeJSONObj = oneTimeJSONArray.fetch(i);
62
+ oneTime = App42::AppTab::OneTime.new(usage)
63
+ buildObjectFromJSONTree(oneTime, oneTimeJSONObj);
64
+ end
65
+ end
66
+
67
+ elsif usageJsonObj.key?("feature")
68
+ featureList = Array.new
69
+ usage.featureList=(featureList)
70
+ if usageJsonObj.fetch("feature").instance_of?(Hash)
71
+ featureJSONObj = usageJsonObj.fetch("feature");
72
+ feature = App42::AppTab::Feature.new(usage)
73
+ buildObjectFromJSONTree(feature, featureJSONObj);
74
+ else
75
+ featureJSONArray = usageJsonObj.fetch("feature");
76
+ featureJSONArray.length.times do |i|
77
+ featureJSONObj = featureJSONArray.fetch(i);
78
+ feature = App42::AppTab::Feature.new(usage)
79
+ buildObjectFromJSONTree(feature, featureJSONObj);
80
+ end
81
+ end
82
+
83
+ elsif usageJsonObj.key?("bandwidth")
84
+ bandwidthList = Array.new
85
+ usage.bandwidthList=(bandwidthList)
86
+ if usageJsonObj.fetch("bandwidth").instance_of?(Hash)
87
+ bandwidthJSONObj = usageJsonObj.fetch("bandwidth");
88
+ bandwidth = App42::AppTab::Bandwidth.new(usage)
89
+ buildObjectFromJSONTree(bandwidth, bandwidthJSONObj);
90
+ else
91
+ bandwidthJSONArray = usageJsonObj.fetch("bandwidth");
92
+ bandwidthJSONArray.length.times do |i|
93
+ bandwidthJSONObj = bandwidthJSONArray.fetch(i);
94
+ bandwidth = App42::AppTab::Bandwidth.new(usage)
95
+ buildObjectFromJSONTree(bandwidth, bandwidthJSONObj);
96
+ end
97
+ end
98
+
99
+ elsif usageJsonObj.key?("storage")
100
+ storageList = Array.new
101
+ usage.storageList=(storageList)
102
+ if usageJsonObj.fetch("storage").instance_of?(Hash)
103
+ storageJSONObj = usageJsonObj.fetch("storage");
104
+ storage = App42::AppTab::Storage.new(usage)
105
+ buildObjectFromJSONTree(storage, storageJSONObj);
106
+ else
107
+ storageJSONArray = usageJsonObj.fetch("storage");
108
+ storageJSONArray.length.times do |i|
109
+ storageJSONObj = storageJSONArray.fetch(i);
110
+ storage = App42::AppTab::Storage.new(usage)
111
+ buildObjectFromJSONTree(storage, storageJSONObj);
112
+ end
113
+ end
114
+
115
+ elsif usageJsonObj.key?("time")
116
+ timeList = Array.new
117
+ usage.timeList=(timeList)
118
+ if usageJsonObj.fetch("time").instance_of?(Hash)
119
+ timeJSONObj = usageJsonObj.fetch("time");
120
+ time = App42::AppTab::Time.new(usage)
121
+ buildObjectFromJSONTree(time, timeJSONObj);
122
+ else
123
+ timeJSONArray = usageJsonObj.fetch("time");
124
+ timeJSONArray.length.times do |i|
125
+ timeJSONObj = timeJSONArray.fetch(i);
126
+ time = App42::AppTab::Time.new(usage)
127
+ buildObjectFromJSONTree(time, timeJSONObj);
128
+ end
129
+ end
130
+
131
+ # elsif usageJsonObj.key?("custom")
132
+ # customList = Array.new
133
+ # usage.customList=(customList)
134
+ # if usageJsonObj.fetch("custom").instance_of?(Hash)
135
+ # customJSONObj = usageJsonObj.fetch("custom");
136
+ # custom = App42::Usage::Custom(usage)
137
+ # buildObjectFromJSONTree(custom, customJSONObj);
138
+ # else
139
+ # customJSONArray = usageJsonObj.fetch("custom");
140
+ # customJSONArray.length.times do |i|
141
+ # customJSONObj = customJSONArray.getJSONObject(i);
142
+ # custom = App42::Usage::Custom(usage)
143
+ # buildObjectFromJSONTree(custom, customJSONObj);
144
+ # end
145
+ # end
146
+ end
147
+ return usage;
148
+ end
149
+ end
150
+
151
+ end
152
+ end