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
@@ -0,0 +1,29 @@
|
|
1
|
+
# -----------------------------------------------------------------------
|
2
|
+
# Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
|
3
|
+
# -----------------------------------------------------------------------
|
4
|
+
|
5
|
+
require 'App42_Ruby_API/App42Response'
|
6
|
+
|
7
|
+
#
|
8
|
+
#
|
9
|
+
# This ItemData object is the value object which contains the properties of
|
10
|
+
# ItemData.
|
11
|
+
#
|
12
|
+
#
|
13
|
+
|
14
|
+
module App42
|
15
|
+
module Shopping
|
16
|
+
class ItemData < App42Response
|
17
|
+
|
18
|
+
attr_accessor :itemId, :name, :description, :image, :price
|
19
|
+
|
20
|
+
@ItemId
|
21
|
+
@name
|
22
|
+
@description
|
23
|
+
@image
|
24
|
+
@price
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# -----------------------------------------------------------------------
|
2
|
+
# Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
|
3
|
+
# -----------------------------------------------------------------------
|
4
|
+
|
5
|
+
require 'App42_Ruby_API/App42Response'
|
6
|
+
|
7
|
+
#
|
8
|
+
# An enum that contains 3 types of the Payment Status either DECLINED or
|
9
|
+
# AUTHORIZED or PENDING.
|
10
|
+
#
|
11
|
+
#
|
12
|
+
|
13
|
+
module App42
|
14
|
+
module Shopping
|
15
|
+
class PaymentStatus < App42Response
|
16
|
+
unless (const_defined?(:DECLINED))
|
17
|
+
DECLINED = "DECLINED"
|
18
|
+
end
|
19
|
+
unless (const_defined?(:AUTHORIZED))
|
20
|
+
AUTHORIZED = "AUTHORIZED"
|
21
|
+
end
|
22
|
+
unless (const_defined?(:PENDING))
|
23
|
+
PENDING = "PENDING"
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Sets the value of the PaymentStatus. DECLINED or AUTHORIZED or PENDING.
|
28
|
+
#
|
29
|
+
# @param string
|
30
|
+
# - the string of PaymentStatus either DECLINED or AUTHORIZED or
|
31
|
+
# PENDING.
|
32
|
+
#
|
33
|
+
#
|
34
|
+
def enum(string)
|
35
|
+
return PaymentStatus.const_get(string)
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Returns the value of the PaymentStatus. DECLINED or AUTHORIZED or
|
40
|
+
# PENDING.
|
41
|
+
#
|
42
|
+
# @return the value of PaymentStatus.
|
43
|
+
#
|
44
|
+
#
|
45
|
+
|
46
|
+
def isAvailable(string)
|
47
|
+
if(string == "DECLINED")
|
48
|
+
return "DECLINED"
|
49
|
+
elsif(string == "AUTHORIZED")
|
50
|
+
return "AUTHORIZED"
|
51
|
+
elsif(string == "PENDING")
|
52
|
+
return "PENDING";
|
53
|
+
else
|
54
|
+
return nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -----------------------------------------------------------------------
|
2
|
+
# Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
|
3
|
+
# -----------------------------------------------------------------------
|
4
|
+
|
5
|
+
require 'App42_Ruby_API/App42Response'
|
6
|
+
|
7
|
+
#
|
8
|
+
#
|
9
|
+
# This class Manage the response which comes from App42 server.
|
10
|
+
#
|
11
|
+
#
|
12
|
+
|
13
|
+
module App42
|
14
|
+
module Social
|
15
|
+
class Social < App42Response
|
16
|
+
|
17
|
+
attr_accessor :userName, :status, :facebookAppId, :facebookAppSecret, :facebookAccessToken, :twitterConsumerKey, :twitterConsumerSecret, :twitterAccessToken, :twitterAccessTokenSecret, :linkedinApiKey, :linkedinSecretKey, :linkedinAccessToken, :linkedinAccessTokenSecret
|
18
|
+
|
19
|
+
@userName
|
20
|
+
@status
|
21
|
+
@facebookAppId
|
22
|
+
@facebookAppSecret
|
23
|
+
@facebookAccessToken
|
24
|
+
@twitterConsumerKey
|
25
|
+
@twitterConsumerSecret
|
26
|
+
@twitterAccessToken
|
27
|
+
@twitterAccessTokenSecret
|
28
|
+
@linkedinApiKey
|
29
|
+
@linkedinSecretKey
|
30
|
+
@linkedinAccessToken
|
31
|
+
@linkedinAccessTokenSecret
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,38 @@
|
|
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 'social/Social'
|
8
|
+
|
9
|
+
module App42
|
10
|
+
module Social
|
11
|
+
|
12
|
+
#
|
13
|
+
#
|
14
|
+
# SocialResponseBuilder class converts the JSON response retrieved from the
|
15
|
+
# server to the value object i.e Social
|
16
|
+
#
|
17
|
+
#
|
18
|
+
class SocialResponseBuilder < App42ResponseBuilder
|
19
|
+
|
20
|
+
#
|
21
|
+
# Converts the response in JSON format to the value object i.e Social
|
22
|
+
#
|
23
|
+
# @param json
|
24
|
+
# - response in JSON format
|
25
|
+
#
|
26
|
+
# @return Social object filled with json data
|
27
|
+
#
|
28
|
+
def buildResponse(json)
|
29
|
+
fbJSONObject = getServiceJSONObject("social", json)
|
30
|
+
social = Social.new
|
31
|
+
buildObjectFromJSONTree(social, fbJSONObject);
|
32
|
+
social.strResponse=json
|
33
|
+
social.isResponseSuccess = isResponseSuccess(json)
|
34
|
+
return social
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,585 @@
|
|
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 'social/SocialResponseBuilder'
|
11
|
+
require 'social/Social'
|
12
|
+
|
13
|
+
module App42
|
14
|
+
module Social
|
15
|
+
#
|
16
|
+
# Connect to the User's multiple social accounts. Also used to update the
|
17
|
+
# status individually or all at once for the linked social accounts.
|
18
|
+
#
|
19
|
+
class SocialService
|
20
|
+
#
|
21
|
+
# this is a constructor that takes
|
22
|
+
#
|
23
|
+
# @param apiKey
|
24
|
+
# @param secretKey
|
25
|
+
# @param baseURL
|
26
|
+
#
|
27
|
+
def initialize(api_key, secret_key, base_url)
|
28
|
+
puts "Social Service->initialize"
|
29
|
+
@api_key = api_key
|
30
|
+
@secret_key = secret_key
|
31
|
+
@base_url = base_url
|
32
|
+
@resource = "social"
|
33
|
+
@version = "1.0"
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Links the User Facebook access credentials to the App User account.
|
38
|
+
|
39
|
+
# @param userName
|
40
|
+
# - Name of the user whose Facebook account to be linked
|
41
|
+
# @param appId
|
42
|
+
# - Facebook App Id
|
43
|
+
# @param appSecret
|
44
|
+
# - Facebook App Secret
|
45
|
+
# @param accessToken
|
46
|
+
# - Facebook Access Token that has been received after authorization
|
47
|
+
#
|
48
|
+
# @return The Social object
|
49
|
+
#
|
50
|
+
# @raise App42Exception
|
51
|
+
#
|
52
|
+
|
53
|
+
def link_user_facebook_account(userName, accessToken, appId, appSecret)
|
54
|
+
response = nil
|
55
|
+
socialObj = Social.new
|
56
|
+
socialObj = nil
|
57
|
+
util = Util.new
|
58
|
+
util.throwExceptionIfNullOrBlank(userName, "userName")
|
59
|
+
util.throwExceptionIfNullOrBlank(accessToken, "accessToken")
|
60
|
+
util.throwExceptionIfNullOrBlank(appId, "appId")
|
61
|
+
util.throwExceptionIfNullOrBlank(appSecret, "appSecret")
|
62
|
+
begin
|
63
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
64
|
+
body = {'app42' => {"social"=> {
|
65
|
+
"userName" => userName,
|
66
|
+
"accessToken" => accessToken,
|
67
|
+
"appId" => appId,
|
68
|
+
"appSecret" => appSecret
|
69
|
+
}}}.to_json
|
70
|
+
puts "Body #{body}"
|
71
|
+
query_params = Hash.new
|
72
|
+
params = {
|
73
|
+
'apiKey'=> @api_key,
|
74
|
+
'version' => @version,
|
75
|
+
'timeStamp' => util.get_timestamp_utc,
|
76
|
+
}
|
77
|
+
query_params = params.clone
|
78
|
+
params.store("body", body)
|
79
|
+
puts query_params
|
80
|
+
signature = util.sign(@secret_key, params)
|
81
|
+
resource_url = "#{@version}/#{@resource}/facebook/linkuser"
|
82
|
+
response = connection.post(signature, resource_url, query_params, body)
|
83
|
+
social = SocialResponseBuilder.new()
|
84
|
+
socialObj = social.buildResponse(response)
|
85
|
+
rescue App42Exception =>e
|
86
|
+
raise e
|
87
|
+
rescue Exception => e
|
88
|
+
raise App42Exception.new(e)
|
89
|
+
end
|
90
|
+
return socialObj
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# Links the User Facebook access credentials to the App User account.
|
95
|
+
#
|
96
|
+
# @param userName
|
97
|
+
# - Name of the user whose Facebook account to be linked
|
98
|
+
# @param accessToken
|
99
|
+
# - Facebook Access Token that has been received after authorization
|
100
|
+
#
|
101
|
+
# @return The Social object
|
102
|
+
#
|
103
|
+
# @raise App42Exception
|
104
|
+
#
|
105
|
+
|
106
|
+
def link_user_facebook_account_with_token(userName, accessToken)
|
107
|
+
response = nil
|
108
|
+
socialObj = Social.new
|
109
|
+
socialObj = nil
|
110
|
+
util = Util.new
|
111
|
+
util.throwExceptionIfNullOrBlank(userName, "userName")
|
112
|
+
util.throwExceptionIfNullOrBlank(accessToken, "accessToken")
|
113
|
+
begin
|
114
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
115
|
+
body = {'app42' => {"social"=> {
|
116
|
+
"userName" => userName,
|
117
|
+
"accessToken" => accessToken
|
118
|
+
}}}.to_json
|
119
|
+
puts "Body #{body}"
|
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("body", body)
|
128
|
+
puts query_params
|
129
|
+
signature = util.sign(@secret_key, params)
|
130
|
+
resource_url = "#{@version}/#{@resource}/facebook/linkuser/accesscredentials"
|
131
|
+
response = connection.post(signature, resource_url, query_params, body)
|
132
|
+
social = SocialResponseBuilder.new()
|
133
|
+
socialObj = social.buildResponse(response)
|
134
|
+
rescue App42Exception =>e
|
135
|
+
raise e
|
136
|
+
rescue Exception => e
|
137
|
+
raise App42Exception.new(e)
|
138
|
+
end
|
139
|
+
return socialObj
|
140
|
+
end
|
141
|
+
|
142
|
+
#
|
143
|
+
# Updates the Facebook status of the specified user.
|
144
|
+
#
|
145
|
+
# @param userName
|
146
|
+
# - Name of the user for whom the status needs to be updated
|
147
|
+
# @param status
|
148
|
+
# - status that has to be updated
|
149
|
+
#
|
150
|
+
# @return The Social object
|
151
|
+
#
|
152
|
+
# @raise App42Exception
|
153
|
+
#
|
154
|
+
|
155
|
+
def update_facebook_status(userName,status)
|
156
|
+
puts "update Status Called "
|
157
|
+
puts "Base url #{@base_url}"
|
158
|
+
response = nil;
|
159
|
+
socialObj = nil;
|
160
|
+
socialObj = Social.new
|
161
|
+
util = Util.new
|
162
|
+
util.throwExceptionIfNullOrBlank(userName, "userName");
|
163
|
+
util.throwExceptionIfNullOrBlank(status, "status");
|
164
|
+
begin
|
165
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
166
|
+
body = {'app42' => {"social"=> {
|
167
|
+
"userName" => userName,
|
168
|
+
"status" => status
|
169
|
+
}}}.to_json
|
170
|
+
puts "Body #{body}"
|
171
|
+
query_params = Hash.new
|
172
|
+
params = {
|
173
|
+
'apiKey'=> @api_key,
|
174
|
+
'version' => @version,
|
175
|
+
'timeStamp' => util.get_timestamp_utc,
|
176
|
+
}
|
177
|
+
query_params = params.clone
|
178
|
+
params.store("body", body)
|
179
|
+
puts query_params
|
180
|
+
signature = util.sign(@secret_key, params)
|
181
|
+
resource_url = "#{@version}/#{@resource}/facebook/updatestatus"
|
182
|
+
response = connection.post(signature, resource_url, query_params, body)
|
183
|
+
social = SocialResponseBuilder.new()
|
184
|
+
socialObj = social.buildResponse(response)
|
185
|
+
rescue App42Exception =>e
|
186
|
+
raise e
|
187
|
+
rescue Exception => e
|
188
|
+
raise App42Exception.new(e)
|
189
|
+
end
|
190
|
+
return socialObj
|
191
|
+
end
|
192
|
+
|
193
|
+
#
|
194
|
+
# Links the User Twitter access credentials to the App User account.
|
195
|
+
#
|
196
|
+
# @param userName
|
197
|
+
# - Name of the user whose Twitter account to be linked
|
198
|
+
# @param consumerKey
|
199
|
+
# - Twitter App Consumer Key
|
200
|
+
# @param consumerSecret
|
201
|
+
# - Twitter App Consumer Secret
|
202
|
+
# @param accessToken
|
203
|
+
# - Request Token retrieved from Twitter after authorizing the App
|
204
|
+
# @param accessTokenSecret
|
205
|
+
# - Request Token Secret retrieved from Twitter after authorizing the App
|
206
|
+
#
|
207
|
+
# @return the Social object
|
208
|
+
#
|
209
|
+
# @raise App42Exception
|
210
|
+
#
|
211
|
+
|
212
|
+
def link_user_twitter_account(userName, accessToken, accessTokenSecret, consumerKey, consumerSecret)
|
213
|
+
puts "linkUserTwitterAccount Called "
|
214
|
+
puts "Base url #{@base_url}"
|
215
|
+
response = nil
|
216
|
+
social = Social.new
|
217
|
+
social = nil
|
218
|
+
util = Util.new
|
219
|
+
util.throwExceptionIfNullOrBlank(userName, "userName")
|
220
|
+
util.throwExceptionIfNullOrBlank(accessToken, "accessToken")
|
221
|
+
util.throwExceptionIfNullOrBlank(accessTokenSecret, "accessTokenSecret")
|
222
|
+
util.throwExceptionIfNullOrBlank(consumerKey, "consumerKey")
|
223
|
+
util.throwExceptionIfNullOrBlank(consumerSecret, "consumerSecret")
|
224
|
+
begin
|
225
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
226
|
+
body = {'app42' => {"social"=> {
|
227
|
+
"userName" => userName,
|
228
|
+
"accessToken" => accessToken,
|
229
|
+
"accessTokenSecret" => accessTokenSecret,
|
230
|
+
"consumerKey" => consumerKey,
|
231
|
+
"consumerSecret" => consumerSecret
|
232
|
+
}}}.to_json
|
233
|
+
puts "Body #{body}"
|
234
|
+
query_params = Hash.new
|
235
|
+
params = {
|
236
|
+
'apiKey'=> @api_key,
|
237
|
+
'version' => @version,
|
238
|
+
'timeStamp' => util.get_timestamp_utc,
|
239
|
+
}
|
240
|
+
query_params = params.clone
|
241
|
+
params.store("body", body)
|
242
|
+
puts query_params
|
243
|
+
signature = util.sign(@secret_key, params)
|
244
|
+
resource_url = "#{@version}/#{@resource}/twitter/linkuser"
|
245
|
+
response = connection.post(signature, resource_url, query_params, body)
|
246
|
+
social = SocialResponseBuilder.new()
|
247
|
+
socialObj = social.buildResponse(response)
|
248
|
+
rescue App42Exception =>e
|
249
|
+
raise e
|
250
|
+
rescue Exception => e
|
251
|
+
raise App42Exception.new(e)
|
252
|
+
end
|
253
|
+
return socialObj
|
254
|
+
end
|
255
|
+
|
256
|
+
#
|
257
|
+
# Links the User Twitter access credentials to the App User account.
|
258
|
+
#
|
259
|
+
# @param userName
|
260
|
+
# - Name of the user whose Twitter account to be linked
|
261
|
+
# @param accessToken
|
262
|
+
# - Request Token retrieved from Twitter after authorizing the App
|
263
|
+
# @param accessTokenSecret
|
264
|
+
# - Request Token Secret retrieved from Twitter after authorizing the App
|
265
|
+
#
|
266
|
+
# @return the Social object
|
267
|
+
#
|
268
|
+
# @raise App42Exception
|
269
|
+
#
|
270
|
+
|
271
|
+
def link_user_twitter_account_with_token(userName, accessToken, accessTokenSecret)
|
272
|
+
puts "linkUserTwitterAccount Called "
|
273
|
+
puts "Base url #{@base_url}"
|
274
|
+
response = nil
|
275
|
+
social = Social.new
|
276
|
+
social = nil
|
277
|
+
util = Util.new
|
278
|
+
util.throwExceptionIfNullOrBlank(userName, "userName")
|
279
|
+
util.throwExceptionIfNullOrBlank(accessToken, "accessToken")
|
280
|
+
util.throwExceptionIfNullOrBlank(accessTokenSecret, "accessTokenSecret")
|
281
|
+
begin
|
282
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
283
|
+
body = {'app42' => {"social"=> {
|
284
|
+
"userName" => userName,
|
285
|
+
"accessToken" => accessToken,
|
286
|
+
"accessTokenSecret" => accessTokenSecret
|
287
|
+
}}}.to_json
|
288
|
+
puts "Body #{body}"
|
289
|
+
query_params = Hash.new
|
290
|
+
params = {
|
291
|
+
'apiKey'=> @api_key,
|
292
|
+
'version' => @version,
|
293
|
+
'timeStamp' => util.get_timestamp_utc,
|
294
|
+
}
|
295
|
+
query_params = params.clone
|
296
|
+
params.store("body", body)
|
297
|
+
puts query_params
|
298
|
+
signature = util.sign(@secret_key, params)
|
299
|
+
resource_url = "#{@version}/#{@resource}/twitter/linkuser/accesscredentials"
|
300
|
+
response = connection.post(signature, resource_url, query_params, body)
|
301
|
+
social = SocialResponseBuilder.new()
|
302
|
+
socialObj = social.buildResponse(response)
|
303
|
+
rescue App42Exception =>e
|
304
|
+
raise e
|
305
|
+
rescue Exception => e
|
306
|
+
raise App42Exception.new(e)
|
307
|
+
end
|
308
|
+
return socialObj
|
309
|
+
end
|
310
|
+
|
311
|
+
#
|
312
|
+
# Updates the Twitter status of the specified user.
|
313
|
+
#
|
314
|
+
# @param userName
|
315
|
+
# - Name of the user for whom the status needs to be updated
|
316
|
+
# @param status
|
317
|
+
# - status that has to be updated
|
318
|
+
#
|
319
|
+
# @return The Social object
|
320
|
+
#
|
321
|
+
# @raise App42Exception
|
322
|
+
#
|
323
|
+
|
324
|
+
def update_twitter_status(userName,status)
|
325
|
+
puts "updateStatus Called "
|
326
|
+
puts "Base url #{@base_url}"
|
327
|
+
response = nil;
|
328
|
+
socialObj = Social.new
|
329
|
+
socialObj = nil;
|
330
|
+
util = Util.new
|
331
|
+
util.throwExceptionIfNullOrBlank(userName, "userName");
|
332
|
+
util.throwExceptionIfNullOrBlank(status, "status");
|
333
|
+
begin
|
334
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
335
|
+
body = {'app42' => {"social"=> {
|
336
|
+
"userName" => userName,
|
337
|
+
"status" => status
|
338
|
+
}}}.to_json
|
339
|
+
puts "Body #{body}"
|
340
|
+
query_params = Hash.new
|
341
|
+
params = {
|
342
|
+
'apiKey'=> @api_key,
|
343
|
+
'version' => @version,
|
344
|
+
'timeStamp' => util.get_timestamp_utc,
|
345
|
+
}
|
346
|
+
query_params = params.clone
|
347
|
+
params.store("body", body)
|
348
|
+
puts query_params
|
349
|
+
signature = util.sign(@secret_key, params)
|
350
|
+
resource_url = "#{@version}/#{@resource}/twitter/updatestatus"
|
351
|
+
response = connection.post(signature, resource_url, query_params, body)
|
352
|
+
social = SocialResponseBuilder.new()
|
353
|
+
socialObj = social.buildResponse(response)
|
354
|
+
rescue App42Exception =>e
|
355
|
+
raise e
|
356
|
+
rescue Exception => e
|
357
|
+
raise App42Exception.new(e)
|
358
|
+
end
|
359
|
+
return socialObj
|
360
|
+
end
|
361
|
+
|
362
|
+
#
|
363
|
+
# Links the User LinkedIn access credentials to the App User account.
|
364
|
+
#
|
365
|
+
# @param userName
|
366
|
+
# - Name of the user whose LinkedIn account to be linked
|
367
|
+
# @param apiKey
|
368
|
+
# - LinkedIn App API Key
|
369
|
+
# @param secretKey
|
370
|
+
# - LinkedIn App Secret Key
|
371
|
+
# @param accessToken
|
372
|
+
# - LinkedIn Access Token that has been received after authorization
|
373
|
+
# @param accessTokenSecret
|
374
|
+
# - LinkedIn Access Token Secret that has been received after authorization
|
375
|
+
#
|
376
|
+
# @return The Social object
|
377
|
+
#
|
378
|
+
# @raise App42Exception
|
379
|
+
#
|
380
|
+
|
381
|
+
def link_user_linkedIn_account(userName, accessToken, accessTokenSecret, apiKey, secretKey)
|
382
|
+
puts "linkUserLinkedInAccount Called "
|
383
|
+
puts "Base url #{@base_url}"
|
384
|
+
response = nil
|
385
|
+
social = Social.new
|
386
|
+
social = nil
|
387
|
+
util = Util.new
|
388
|
+
util.throwExceptionIfNullOrBlank(userName, "userName")
|
389
|
+
util.throwExceptionIfNullOrBlank(accessToken, "accessToken")
|
390
|
+
util.throwExceptionIfNullOrBlank(accessTokenSecret, "accessTokenSecret")
|
391
|
+
util.throwExceptionIfNullOrBlank(apiKey, "apiKey")
|
392
|
+
util.throwExceptionIfNullOrBlank(secretKey, "secretKey")
|
393
|
+
begin
|
394
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
395
|
+
body = {'app42' => {"social"=> {
|
396
|
+
"userName" => userName,
|
397
|
+
"accessToken" => accessToken,
|
398
|
+
"accessTokenSecret" => accessTokenSecret,
|
399
|
+
"apiKey" => apiKey,
|
400
|
+
"secretKey" => secretKey
|
401
|
+
}}}.to_json
|
402
|
+
puts "Body #{body}"
|
403
|
+
query_params = Hash.new
|
404
|
+
params = {
|
405
|
+
'apiKey'=> @api_key,
|
406
|
+
'version' => @version,
|
407
|
+
'timeStamp' => util.get_timestamp_utc,
|
408
|
+
}
|
409
|
+
query_params = params.clone
|
410
|
+
params.store("body", body)
|
411
|
+
puts query_params
|
412
|
+
signature = util.sign(@secret_key, params)
|
413
|
+
resource_url = "#{@version}/#{@resource}/linkedin/linkuser"
|
414
|
+
response = connection.post(signature, resource_url, query_params, body)
|
415
|
+
social = SocialResponseBuilder.new()
|
416
|
+
socialObj = social.buildResponse(response)
|
417
|
+
rescue App42Exception =>e
|
418
|
+
raise e
|
419
|
+
rescue Exception => e
|
420
|
+
raise App42Exception.new(e)
|
421
|
+
end
|
422
|
+
return socialObj
|
423
|
+
end
|
424
|
+
|
425
|
+
#
|
426
|
+
# Links the User LinkedIn access credentials to the App User account.
|
427
|
+
#
|
428
|
+
# @param userName
|
429
|
+
# - Name of the user whose LinkedIn account to be linked
|
430
|
+
# @param accessToken
|
431
|
+
# - LinkedIn Access Token that has been received after authorization
|
432
|
+
# @param accessTokenSecret
|
433
|
+
# - LinkedIn Access Token Secret that has been received after authorization
|
434
|
+
#
|
435
|
+
# @return The Social object
|
436
|
+
#
|
437
|
+
# @raise App42Exception
|
438
|
+
#
|
439
|
+
|
440
|
+
def link_user_linkedIn_account_with_token(userName, accessToken, accessTokenSecret)
|
441
|
+
puts "linkUserLinkedInAccount Called "
|
442
|
+
puts "Base url #{@base_url}"
|
443
|
+
response = nil
|
444
|
+
social = Social.new
|
445
|
+
social = nil
|
446
|
+
util = Util.new
|
447
|
+
util.throwExceptionIfNullOrBlank(userName, "userName")
|
448
|
+
util.throwExceptionIfNullOrBlank(accessToken, "accessToken")
|
449
|
+
util.throwExceptionIfNullOrBlank(accessTokenSecret, "accessTokenSecret")
|
450
|
+
begin
|
451
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
452
|
+
body = {'app42' => {"social"=> {
|
453
|
+
"userName" => userName,
|
454
|
+
"accessToken" => accessToken,
|
455
|
+
"accessTokenSecret" => accessTokenSecret
|
456
|
+
}}}.to_json
|
457
|
+
puts "Body #{body}"
|
458
|
+
query_params = Hash.new
|
459
|
+
params = {
|
460
|
+
'apiKey'=> @api_key,
|
461
|
+
'version' => @version,
|
462
|
+
'timeStamp' => util.get_timestamp_utc,
|
463
|
+
}
|
464
|
+
query_params = params.clone
|
465
|
+
params.store("body", body)
|
466
|
+
puts query_params
|
467
|
+
signature = util.sign(@secret_key, params)
|
468
|
+
resource_url = "#{@version}/#{@resource}/linkedin/linkuser/accesscredentials"
|
469
|
+
response = connection.post(signature, resource_url, query_params, body)
|
470
|
+
social = SocialResponseBuilder.new()
|
471
|
+
socialObj = social.buildResponse(response)
|
472
|
+
rescue App42Exception =>e
|
473
|
+
raise e
|
474
|
+
rescue Exception => e
|
475
|
+
raise App42Exception.new(e)
|
476
|
+
end
|
477
|
+
return socialObj
|
478
|
+
end
|
479
|
+
|
480
|
+
#
|
481
|
+
# Updates the LinkedIn status of the specified user.
|
482
|
+
#
|
483
|
+
# @param userName
|
484
|
+
# - Name of the user for whom the status needs to be updated
|
485
|
+
# @param status
|
486
|
+
# - status that has to be updated
|
487
|
+
#
|
488
|
+
# @return The Social object
|
489
|
+
#
|
490
|
+
# @raise App42Exception
|
491
|
+
#
|
492
|
+
|
493
|
+
def update_linkedIn_status(userName, status)
|
494
|
+
puts "updateStatus Called "
|
495
|
+
puts "Base url #{@base_url}"
|
496
|
+
response = nil;
|
497
|
+
socialObj = nil;
|
498
|
+
socialObj = Social.new
|
499
|
+
util = Util.new
|
500
|
+
util.throwExceptionIfNullOrBlank(userName, "userName")
|
501
|
+
util.throwExceptionIfNullOrBlank(status, "status")
|
502
|
+
begin
|
503
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
504
|
+
body = {'app42' => {"social"=> {
|
505
|
+
"userName" => userName,
|
506
|
+
"status" => status
|
507
|
+
}}}.to_json
|
508
|
+
puts "Body #{body}"
|
509
|
+
query_params = Hash.new
|
510
|
+
params = {
|
511
|
+
'apiKey'=> @api_key,
|
512
|
+
'version' => @version,
|
513
|
+
'timeStamp' => util.get_timestamp_utc,
|
514
|
+
}
|
515
|
+
query_params = params.clone
|
516
|
+
params.store("body", body)
|
517
|
+
puts query_params
|
518
|
+
signature = util.sign(@secret_key, params)
|
519
|
+
resource_url = "#{@version}/#{@resource}/linkedin/updatestatus"
|
520
|
+
response = connection.post(signature, resource_url, query_params, body)
|
521
|
+
social = SocialResponseBuilder.new()
|
522
|
+
socialObj = social.buildResponse(response)
|
523
|
+
rescue App42Exception =>e
|
524
|
+
raise e
|
525
|
+
rescue Exception => e
|
526
|
+
raise App42Exception.new(e)
|
527
|
+
end
|
528
|
+
return socialObj
|
529
|
+
end
|
530
|
+
|
531
|
+
#
|
532
|
+
# Updates the status for all linked social accounts of the specified user.
|
533
|
+
#
|
534
|
+
# @param userName
|
535
|
+
# - Name of the user for whom the status needs to be updated
|
536
|
+
# @param status
|
537
|
+
# - status that has to be updated
|
538
|
+
#
|
539
|
+
# @return The Social object
|
540
|
+
#
|
541
|
+
# @raise App42Exception
|
542
|
+
#
|
543
|
+
|
544
|
+
def update_social_status_for_all(userName, status)
|
545
|
+
puts "updateStatus Called "
|
546
|
+
puts "Base url #{@base_url}"
|
547
|
+
response = nil;
|
548
|
+
socialObj = Social.new
|
549
|
+
socialObj = nil;
|
550
|
+
util = Util.new
|
551
|
+
util.throwExceptionIfNullOrBlank(userName, "userName")
|
552
|
+
util.throwExceptionIfNullOrBlank(status, "status")
|
553
|
+
begin
|
554
|
+
connection = App42::Connection::RESTConnection.new(@base_url)
|
555
|
+
body = {'app42' => {"social"=> {
|
556
|
+
"userName" => userName,
|
557
|
+
"status" => status
|
558
|
+
}}}.to_json
|
559
|
+
puts "Body #{body}"
|
560
|
+
query_params = Hash.new
|
561
|
+
params = {
|
562
|
+
'apiKey'=> @api_key,
|
563
|
+
'version' => @version,
|
564
|
+
'timeStamp' => util.get_timestamp_utc,
|
565
|
+
}
|
566
|
+
query_params = params.clone
|
567
|
+
params.store("body", body)
|
568
|
+
puts query_params
|
569
|
+
signature = util.sign(@secret_key, params)
|
570
|
+
resource_url = "#{@version}/#{@resource}/social/updatestatus/all"
|
571
|
+
response = connection.post(signature, resource_url, query_params, body)
|
572
|
+
social = SocialResponseBuilder.new()
|
573
|
+
socialObj = social.buildResponse(response)
|
574
|
+
rescue App42Exception =>e
|
575
|
+
raise e
|
576
|
+
rescue Exception => e
|
577
|
+
raise App42Exception.new(e)
|
578
|
+
end
|
579
|
+
puts socialObj.userName()
|
580
|
+
return socialObj
|
581
|
+
end
|
582
|
+
|
583
|
+
end
|
584
|
+
end
|
585
|
+
end
|