App42_Ruby_API 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/App42_Ruby_API.gemspec +33 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/TODO.rb +3 -0
- data/lib/App42_Ruby_API.rb +232 -0
- data/lib/App42_Ruby_API/App42BadParameterException.rb +31 -0
- data/lib/App42_Ruby_API/App42Exception.rb +39 -0
- data/lib/App42_Ruby_API/App42LimitException.rb +15 -0
- data/lib/App42_Ruby_API/App42NotFoundException.rb +15 -0
- data/lib/App42_Ruby_API/App42Response.rb +13 -0
- data/lib/App42_Ruby_API/App42ResponseBuilder.rb +67 -0
- data/lib/App42_Ruby_API/App42SecurityException.rb +15 -0
- data/lib/App42_Ruby_API/version.rb +3 -0
- data/lib/connection/RESTConnection.rb +713 -0
- data/lib/email/Email.rb +51 -0
- data/lib/email/EmailMIME.rb +51 -0
- data/lib/email/EmailResponseBuilder.rb +76 -0
- data/lib/email/EmailService.rb +244 -0
- data/lib/gallery/Album.rb +56 -0
- data/lib/gallery/AlbumResponseBuilder.rb +168 -0
- data/lib/gallery/AlbumService.rb +337 -0
- data/lib/gallery/PhotoService.rb +591 -0
- data/lib/game/Game.rb +39 -0
- data/lib/game/GameResponseBuilder.rb +106 -0
- data/lib/game/GameService.rb +268 -0
- data/lib/game/Reward.rb +24 -0
- data/lib/game/RewardResponseBuilder.rb +85 -0
- data/lib/game/RewardService.rb +440 -0
- data/lib/game/ScoreBoardService.rb +433 -0
- data/lib/game/ScoreService.rb +157 -0
- data/lib/geo/Geo.rb +51 -0
- data/lib/geo/GeoPoint.rb +43 -0
- data/lib/geo/GeoResponseBuilder.rb +145 -0
- data/lib/geo/GeoService.rb +505 -0
- data/lib/imageProcessor/Image.rb +42 -0
- data/lib/imageProcessor/ImageProcessorResponseBuilder.rb +40 -0
- data/lib/imageProcessor/ImageProcessorService.rb +1054 -0
- data/lib/log/Log.rb +49 -0
- data/lib/log/LogResponseBuilder.rb +61 -0
- data/lib/log/LogService.rb +920 -0
- data/lib/message/Queue.rb +50 -0
- data/lib/message/QueueResponseBuilder.rb +64 -0
- data/lib/message/QueueService.rb +469 -0
- data/lib/push/DeviceType.rb +56 -0
- data/lib/push/PushNotification.rb +38 -0
- data/lib/push/PushNotificationResposneBuilder.rb +74 -0
- data/lib/push/PushNotificationService.rb +458 -0
- data/lib/recommend/PreferenceData.rb +25 -0
- data/lib/recommend/Recommender.rb +48 -0
- data/lib/recommend/RecommenderResponseBuilder.rb +70 -0
- data/lib/recommend/RecommenderService.rb +1092 -0
- data/lib/recommend/RecommenderSimilarity.rb +52 -0
- data/lib/review/Review.rb +38 -0
- data/lib/review/ReviewResponseBuilder.rb +76 -0
- data/lib/review/ReviewService.rb +590 -0
- data/lib/session/Session.rb +43 -0
- data/lib/session/SessionResponseBuilder.rb +70 -0
- data/lib/session/SessionService.rb +427 -0
- data/lib/shopping/Cart.rb +77 -0
- data/lib/shopping/CartResponseBuilder.rb +118 -0
- data/lib/shopping/CartService.rb +902 -0
- data/lib/shopping/Catalogue.rb +79 -0
- data/lib/shopping/CatalogueResponseBuilder.rb +170 -0
- data/lib/shopping/CatalogueService.rb +649 -0
- data/lib/shopping/ItemData.rb +29 -0
- data/lib/shopping/PaymentStatus.rb +60 -0
- data/lib/social/Social.rb +35 -0
- data/lib/social/SocialResponseBuilder.rb +38 -0
- data/lib/social/SocialService.rb +585 -0
- data/lib/storage/OrderByType.rb +29 -0
- data/lib/storage/Query.rb +39 -0
- data/lib/storage/QueryBuilder.rb +118 -0
- data/lib/storage/Storage.rb +45 -0
- data/lib/storage/StorageResponseBuilder.rb +86 -0
- data/lib/storage/StorageService.rb +775 -0
- data/lib/upload/Upload.rb +40 -0
- data/lib/upload/UploadFileType.rb +83 -0
- data/lib/upload/UploadResponseBuilder.rb +58 -0
- data/lib/upload/UploadService.rb +960 -0
- data/lib/user/User.rb +102 -0
- data/lib/user/UserResponseBuilder.rb +105 -0
- data/lib/user/UserService.rb +1209 -0
- data/lib/util/util.rb +244 -0
- data/question.rb +79 -0
- metadata +204 -0
data/lib/email/Email.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# -----------------------------------------------------------------------
|
2
|
+
# Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
|
3
|
+
# -----------------------------------------------------------------------
|
4
|
+
|
5
|
+
require 'App42_Ruby_API/App42Response'
|
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 Email
|
15
|
+
class Email < App42Response
|
16
|
+
attr_accessor :from, :to, :subject, :body, :configList
|
17
|
+
@from
|
18
|
+
@to
|
19
|
+
@subject
|
20
|
+
@body
|
21
|
+
@configList = Array.new()
|
22
|
+
end
|
23
|
+
|
24
|
+
class Configuration
|
25
|
+
attr_accessor :emailId, :host, :port, :ssl
|
26
|
+
@emailId
|
27
|
+
@host
|
28
|
+
@port
|
29
|
+
@ssl
|
30
|
+
#
|
31
|
+
# This is a constructor that takes no parameter
|
32
|
+
#
|
33
|
+
#
|
34
|
+
def initialize(email)
|
35
|
+
email.configList.push(self)
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Returns the Cart Response in JSON format.
|
40
|
+
#
|
41
|
+
# @return the response in JSON format.
|
42
|
+
#
|
43
|
+
#
|
44
|
+
|
45
|
+
def to_s
|
46
|
+
return "Email : #{@emailId}" + "Host : #{@host}" + "port : #{@port}" + "ssl : #{@ssl}";
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# -----------------------------------------------------------------------
|
2
|
+
# Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
|
3
|
+
# -----------------------------------------------------------------------
|
4
|
+
|
5
|
+
require 'email/Email'
|
6
|
+
|
7
|
+
#
|
8
|
+
# An enum that contains 2 types of the EmailMIME either text/plain or
|
9
|
+
# text/html.
|
10
|
+
#
|
11
|
+
|
12
|
+
module App42
|
13
|
+
module Email
|
14
|
+
class EmailMIME < App42Response
|
15
|
+
unless (const_defined?(:PLAIN_TEXT_MIME_TYPE))
|
16
|
+
PLAIN_TEXT_MIME_TYPE = "text/plain"
|
17
|
+
end
|
18
|
+
unless (const_defined?(:HTML_TEXT_MIME_TYPE))
|
19
|
+
HTML_TEXT_MIME_TYPE = "text/html"
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Sets the value of the EmailMIME. text/plain or text/html.
|
24
|
+
#
|
25
|
+
# @param string
|
26
|
+
# - the string of EmailMIME either text/plain or text/html.
|
27
|
+
#
|
28
|
+
def enum(string)
|
29
|
+
return EmailMIME.const_get(string)
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Returns the value of the EmailMIME. text/plain or text/html.
|
34
|
+
#
|
35
|
+
# @return the value of EmailMIME.
|
36
|
+
#
|
37
|
+
#
|
38
|
+
|
39
|
+
def isAvailable(string)
|
40
|
+
if(string == "text/plain")
|
41
|
+
return "PLAIN_TEXT_MIME_TYPE"
|
42
|
+
elsif(string == "text/html")
|
43
|
+
return "HTML_TEXT_MIME_TYPE";
|
44
|
+
else
|
45
|
+
return nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# -----------------------------------------------------------------------
|
2
|
+
# Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
|
3
|
+
# -----------------------------------------------------------------------
|
4
|
+
|
5
|
+
require 'json/pure'
|
6
|
+
require 'App42_Ruby_API/App42ResponseBuilder'
|
7
|
+
require 'email/Email'
|
8
|
+
|
9
|
+
module App42
|
10
|
+
module Email
|
11
|
+
|
12
|
+
#
|
13
|
+
# EmailResponseBuilder class converts the JSON response retrieved from the
|
14
|
+
# server to the value object i.e Email
|
15
|
+
#
|
16
|
+
class EmailResponseBuilder < App42ResponseBuilder
|
17
|
+
|
18
|
+
#
|
19
|
+
# Converts the response in JSON format to the value object i.e Email
|
20
|
+
#
|
21
|
+
# @param json
|
22
|
+
# - response in JSON format
|
23
|
+
#
|
24
|
+
# @return Email object filled with json data
|
25
|
+
#
|
26
|
+
def buildResponse(json)
|
27
|
+
emailObj = Email.new()
|
28
|
+
|
29
|
+
configList = Array.new
|
30
|
+
emailObj.configList=(configList)
|
31
|
+
emailObj.strResponse=json
|
32
|
+
jsonObj = JSON.parse(json)
|
33
|
+
|
34
|
+
jsonObjApp42 = jsonObj["app42"]
|
35
|
+
jsonObjResponse = jsonObjApp42["response"]
|
36
|
+
|
37
|
+
emailObj.isResponseSuccess=(jsonObjResponse.fetch("success"))
|
38
|
+
jsonObjEmail = jsonObjResponse["email"]
|
39
|
+
|
40
|
+
buildObjectFromJSONTree(emailObj, jsonObjEmail);
|
41
|
+
|
42
|
+
if jsonObjEmail.has_key?("configurations") == false
|
43
|
+
return emailObj
|
44
|
+
end
|
45
|
+
|
46
|
+
jsonEmailConfig = jsonObjEmail["configurations"]
|
47
|
+
|
48
|
+
if jsonEmailConfig.has_key?("config") == false
|
49
|
+
return emailObj
|
50
|
+
end
|
51
|
+
|
52
|
+
if jsonEmailConfig["config"].instance_of?(Hash)
|
53
|
+
# Only One attribute is there
|
54
|
+
|
55
|
+
jsonObjConfig = jsonEmailConfig["config"]
|
56
|
+
configItem = App42::Email::Configuration.new(emailObj)
|
57
|
+
|
58
|
+
buildObjectFromJSONTree(configItem, jsonObjConfig);
|
59
|
+
else
|
60
|
+
|
61
|
+
# There is an Array of attribute
|
62
|
+
jsonObjConfigArray = jsonEmailConfig["config"]
|
63
|
+
jsonObjConfigArray.length.times do |i|
|
64
|
+
# Get Individual Attribute Node and set it into Object
|
65
|
+
|
66
|
+
jsonObjConfig = jsonObjConfigArray[i]
|
67
|
+
configItem = App42::Email::Configuration.new(emailObj)
|
68
|
+
buildObjectFromJSONTree(configItem, jsonObjConfig);
|
69
|
+
end
|
70
|
+
end
|
71
|
+
return emailObj
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,244 @@
|
|
1
|
+
# -----------------------------------------------------------------------
|
2
|
+
# Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
|
3
|
+
# -----------------------------------------------------------------------
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'connection/RESTConnection'
|
7
|
+
require 'util/util'
|
8
|
+
require 'json/pure'
|
9
|
+
require 'App42_Ruby_API/App42Response'
|
10
|
+
require 'email/EmailResponseBuilder'
|
11
|
+
require 'email/Email'
|
12
|
+
|
13
|
+
module App42
|
14
|
+
module Email
|
15
|
+
#
|
16
|
+
# This Service is used to send Emails. This service can be used by app to send mail to one or multiple recipients.
|
17
|
+
#
|
18
|
+
# @see Email
|
19
|
+
#
|
20
|
+
class EmailService
|
21
|
+
#
|
22
|
+
# this is a constructor that takes
|
23
|
+
#
|
24
|
+
# @param apiKey
|
25
|
+
# @param secretKey
|
26
|
+
# @param baseURL
|
27
|
+
#
|
28
|
+
def initialize(api_key, secret_key, base_url)
|
29
|
+
puts "EmailService->initialize"
|
30
|
+
@api_key = api_key
|
31
|
+
@secret_key = secret_key
|
32
|
+
@base_url = base_url
|
33
|
+
@resource = "email"
|
34
|
+
@version = "1.0"
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Creates Email Configuration using which in future the App developer can send mail
|
39
|
+
#
|
40
|
+
# @param emailHost
|
41
|
+
# - Email Host to be used for sending mail
|
42
|
+
# @param emailPort
|
43
|
+
# - Email Port to be used for sending mail
|
44
|
+
# @param mailId
|
45
|
+
# - Email id to be used for sending mail
|
46
|
+
# @param emailPassword
|
47
|
+
# - Email Password to be used for sending mail
|
48
|
+
# @param isSSL
|
49
|
+
# - Should be send using SSL or not
|
50
|
+
#
|
51
|
+
# @return Email object containing the email configuration which has been created
|
52
|
+
#
|
53
|
+
# @raise App42Exception
|
54
|
+
#
|
55
|
+
|
56
|
+
def create_mail_configuration(emailHost, emailPort, mailId, emailPassword, isSSL)
|
57
|
+
puts "create Mail Configuration Called "
|
58
|
+
puts "Base url #{@base_url}"
|
59
|
+
response = nil;
|
60
|
+
emailObj = nil;
|
61
|
+
emailObj = Email.new
|
62
|
+
util = Util.new
|
63
|
+
util.throwExceptionIfNullOrBlank(emailHost, "Host");
|
64
|
+
util.throwExceptionIfNullOrBlank(emailPort, "Port");
|
65
|
+
util.throwExceptionIfNullOrBlank(mailId, "Email Id");
|
66
|
+
util.throwExceptionIfNullOrBlank(emailPassword, "Password");
|
67
|
+
util.throwExceptionIfNullOrBlank(isSSL, "isSSL");
|
68
|
+
begin
|
69
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
70
|
+
body = {'app42' => {"email"=> {
|
71
|
+
"host" => emailHost,
|
72
|
+
"port" => emailPort,
|
73
|
+
"emailId" => mailId,
|
74
|
+
"password" => emailPassword,
|
75
|
+
"ssl" => isSSL
|
76
|
+
}}}.to_json
|
77
|
+
puts "Body #{body}"
|
78
|
+
query_params = Hash.new
|
79
|
+
params = {
|
80
|
+
'apiKey'=> @api_key,
|
81
|
+
'version' => @version,
|
82
|
+
'timeStamp' => util.get_timestamp_utc,
|
83
|
+
}
|
84
|
+
query_params = params.clone
|
85
|
+
params.store("body", body)
|
86
|
+
signature = util.sign(@secret_key, params)
|
87
|
+
resource_url = "#{@version}/#{@resource}/configuration"
|
88
|
+
response = connection.post(signature, resource_url, query_params, body)
|
89
|
+
email = EmailResponseBuilder.new
|
90
|
+
emailObj = email.buildResponse(response)
|
91
|
+
rescue App42Exception =>e
|
92
|
+
raise e
|
93
|
+
rescue Exception => e
|
94
|
+
raise App42Exception.new(e)
|
95
|
+
end
|
96
|
+
return emailObj
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# Removes email configuration for the given email id. Note: In future the developer
|
101
|
+
# wont be able to send mails through this id
|
102
|
+
#
|
103
|
+
# @param emailId
|
104
|
+
# - The email id for which the configuration has to be removed
|
105
|
+
#
|
106
|
+
# @return Email object containing the email id which has been removed
|
107
|
+
#
|
108
|
+
# @raise App42Exception
|
109
|
+
#
|
110
|
+
|
111
|
+
def remove_email_configuration(emailId)
|
112
|
+
puts "Delete Email config Called "
|
113
|
+
puts "Base url #{@base_url}"
|
114
|
+
response = nil;
|
115
|
+
responseObj = App42Response.new();
|
116
|
+
util = Util.new
|
117
|
+
util.throwExceptionIfNullOrBlank(emailId, "Email Id");
|
118
|
+
begin
|
119
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
120
|
+
query_params = Hash.new
|
121
|
+
params = {
|
122
|
+
'apiKey'=> @api_key,
|
123
|
+
'version' => @version,
|
124
|
+
'timeStamp' => util.get_timestamp_utc,
|
125
|
+
}
|
126
|
+
query_params = params.clone
|
127
|
+
params.store("emailId", emailId)
|
128
|
+
signature = util.sign(@secret_key, params)
|
129
|
+
resource_url = "#{@version}/#{@resource}/configuration/#{emailId}"
|
130
|
+
response = connection.delete(signature, resource_url, query_params)
|
131
|
+
responseObj.strResponse=(response)
|
132
|
+
responseObj.isResponseSuccess=(true)
|
133
|
+
rescue App42Exception =>e
|
134
|
+
raise e
|
135
|
+
rescue Exception => e
|
136
|
+
raise App42Exception.new(e)
|
137
|
+
end
|
138
|
+
return responseObj
|
139
|
+
end
|
140
|
+
|
141
|
+
#
|
142
|
+
# Gets all Email Configurations for the app
|
143
|
+
#
|
144
|
+
# @return Email object containing all Email Configurations
|
145
|
+
#
|
146
|
+
# @raise App42Exception
|
147
|
+
#
|
148
|
+
|
149
|
+
def get_email_configurations()
|
150
|
+
puts "getEmailConfigurations "
|
151
|
+
puts "Base url #{@base_url}"
|
152
|
+
response = nil;
|
153
|
+
emailObj = nil;
|
154
|
+
emailObj = Email.new
|
155
|
+
util = Util.new
|
156
|
+
begin
|
157
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
158
|
+
query_params = Hash.new
|
159
|
+
params = {
|
160
|
+
'apiKey'=> @api_key,
|
161
|
+
'version' => @version,
|
162
|
+
'timeStamp' => util.get_timestamp_utc,
|
163
|
+
}
|
164
|
+
query_params = params.clone
|
165
|
+
signature = util.sign(@secret_key, params)
|
166
|
+
resource_url = "#{@version}/#{@resource}/configuration"
|
167
|
+
response = connection.get(signature, resource_url, query_params)
|
168
|
+
emailObj = EmailResponseBuilder.new().buildResponse(response)
|
169
|
+
rescue App42Exception =>e
|
170
|
+
raise e
|
171
|
+
rescue Exception => e
|
172
|
+
raise App42Exception.new(e)
|
173
|
+
end
|
174
|
+
return emailObj
|
175
|
+
end
|
176
|
+
|
177
|
+
#
|
178
|
+
# Sends the Email to the specified recipient with the provided detail
|
179
|
+
#
|
180
|
+
# @param fromEmail
|
181
|
+
# - The Email Id using which the mail(s) has to be sent
|
182
|
+
# @param sendTo
|
183
|
+
# - The email ids to which the email has to be sent. Email can be sent to multiple email ids.
|
184
|
+
# Multiple email ids can be passed using comma as the seperator e.g. sid@shephertz.com, info@shephertz.com
|
185
|
+
# @param sendSubject
|
186
|
+
# - Subject of the Email which to be sent
|
187
|
+
# @param sendMsg
|
188
|
+
# - Email body which has to be sent
|
189
|
+
# @param emailMIME
|
190
|
+
# - MIME Type to be used for sending mail. EmailMIME available options are PLAIN_TEXT_MIME_TYPE or HTML_TEXT_MIME_TYPE
|
191
|
+
#
|
192
|
+
# @return Email object containing all the details used for sending mail
|
193
|
+
#
|
194
|
+
# @raise App42Exception
|
195
|
+
#
|
196
|
+
|
197
|
+
def send_mail(sendTo, sendSubject, sendMsg, fromEmail, emailMime)
|
198
|
+
puts "sendMail Called "
|
199
|
+
puts "Base url #{@base_url}"
|
200
|
+
response = nil;
|
201
|
+
emailObj = nil;
|
202
|
+
emailObj = Email.new
|
203
|
+
util = Util.new
|
204
|
+
util.throwExceptionIfNullOrBlank(sendTo, "Send To");
|
205
|
+
util.throwExceptionIfNullOrBlank(sendSubject, "Send Subject");
|
206
|
+
util.throwExceptionIfNullOrBlank(sendMsg, "Send Message");
|
207
|
+
util.throwExceptionIfNullOrBlank(fromEmail, "From Email");
|
208
|
+
util.throwExceptionIfNullOrBlank(emailMime, "emailMime");
|
209
|
+
begin
|
210
|
+
if (EmailMIME.new.isAvailable(emailMime) == nil)
|
211
|
+
raise App42NotFoundException.new("Email MIME #{emailMime} does not Exist ");
|
212
|
+
end
|
213
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
214
|
+
body = {'app42' => {"email"=> {
|
215
|
+
"to" => sendTo,
|
216
|
+
"subject" => sendSubject,
|
217
|
+
"msg" => sendMsg,
|
218
|
+
"emailId" => fromEmail,
|
219
|
+
"mimeType" => emailMime
|
220
|
+
}}}.to_json
|
221
|
+
puts "Body #{body}"
|
222
|
+
query_params = Hash.new
|
223
|
+
params = {
|
224
|
+
'apiKey'=> @api_key,
|
225
|
+
'version' => @version,
|
226
|
+
'timeStamp' => util.get_timestamp_utc,
|
227
|
+
}
|
228
|
+
query_params = params.clone
|
229
|
+
params.store("body", body)
|
230
|
+
signature = util.sign(@secret_key, params)
|
231
|
+
resource_url = "#{@version}/#{@resource}"
|
232
|
+
response = connection.post(signature, resource_url, query_params, body)
|
233
|
+
emailObj = EmailResponseBuilder.new().buildResponse(response)
|
234
|
+
rescue App42Exception =>e
|
235
|
+
raise e
|
236
|
+
rescue Exception => e
|
237
|
+
raise App42Exception.new(e)
|
238
|
+
end
|
239
|
+
return emailObj
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# -----------------------------------------------------------------------
|
2
|
+
# Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
|
3
|
+
# -----------------------------------------------------------------------
|
4
|
+
|
5
|
+
require 'App42_Ruby_API/App42Response'
|
6
|
+
|
7
|
+
#
|
8
|
+
#
|
9
|
+
# This Album object is the value object which contains the properties of Album.
|
10
|
+
#
|
11
|
+
#
|
12
|
+
|
13
|
+
module App42
|
14
|
+
module Gallery
|
15
|
+
class Album < App42Response
|
16
|
+
attr_accessor :userName, :name,:description, :photoList
|
17
|
+
|
18
|
+
@userName
|
19
|
+
@name
|
20
|
+
@description
|
21
|
+
@photoList = Array.new()
|
22
|
+
end
|
23
|
+
|
24
|
+
class Photo
|
25
|
+
attr_accessor :name, :description, :url, :thumbNailTinyUrl, :tinyUrl, :tagList, :thumbNailUrl
|
26
|
+
|
27
|
+
@name
|
28
|
+
@description
|
29
|
+
@url
|
30
|
+
@thumbNailUrl
|
31
|
+
@tagList = Array.new
|
32
|
+
@tinyUrl
|
33
|
+
@thumbNailTinyUrl
|
34
|
+
|
35
|
+
#
|
36
|
+
# This is a constructor that takes no parameter
|
37
|
+
#
|
38
|
+
#
|
39
|
+
def initialize(album)
|
40
|
+
album.photoList.push(self)
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Returns the Album Response in JSON format.
|
45
|
+
#
|
46
|
+
# @return the response in JSON format.
|
47
|
+
#
|
48
|
+
#
|
49
|
+
|
50
|
+
def to_s
|
51
|
+
return "name : #{@name}" + "description : #{@description}" + "url : #{@url}" + "tinyUrl : #{@tinyUrl}" + "thumbNailUrl : #{@thumbNailUrl}" + "thumbNailTinyUrl : #{@thumbNailTinyUrl}" + "tagList : #{@tagList }"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|