cloudrail_si 0.1.5
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/LICENSE.txt +3 -0
- data/examples/README.md +3 -0
- data/examples/simple/index.rb +11 -0
- data/lib/cloudrail_si.rb +41 -0
- data/lib/cloudrail_si/RedirectReceivers.rb +40 -0
- data/lib/cloudrail_si/Settings.rb +12 -0
- data/lib/cloudrail_si/errors/DetailErrors.rb +13 -0
- data/lib/cloudrail_si/errors/InternalError.rb +10 -0
- data/lib/cloudrail_si/errors/UserError.rb +11 -0
- data/lib/cloudrail_si/helpers/Helper.rb +151 -0
- data/lib/cloudrail_si/helpers/LimitedReadableStream.rb +55 -0
- data/lib/cloudrail_si/helpers/SequenceReadableStream.rb +59 -0
- data/lib/cloudrail_si/servicecode/InitSelfTest.rb +92 -0
- data/lib/cloudrail_si/servicecode/Interpreter.rb +213 -0
- data/lib/cloudrail_si/servicecode/Sandbox.rb +361 -0
- data/lib/cloudrail_si/servicecode/VarAddress.rb +11 -0
- data/lib/cloudrail_si/servicecode/commands/AwaitCodeRedirect.rb +48 -0
- data/lib/cloudrail_si/servicecode/commands/Break.rb +16 -0
- data/lib/cloudrail_si/servicecode/commands/CallFunc.rb +26 -0
- data/lib/cloudrail_si/servicecode/commands/Clone.rb +18 -0
- data/lib/cloudrail_si/servicecode/commands/Concat.rb +22 -0
- data/lib/cloudrail_si/servicecode/commands/Conditional.rb +27 -0
- data/lib/cloudrail_si/servicecode/commands/Create.rb +56 -0
- data/lib/cloudrail_si/servicecode/commands/Delete.rb +21 -0
- data/lib/cloudrail_si/servicecode/commands/Get.rb +25 -0
- data/lib/cloudrail_si/servicecode/commands/GetMimeType.rb +1005 -0
- data/lib/cloudrail_si/servicecode/commands/JumpRel.rb +18 -0
- data/lib/cloudrail_si/servicecode/commands/Pull.rb +34 -0
- data/lib/cloudrail_si/servicecode/commands/Push.rb +32 -0
- data/lib/cloudrail_si/servicecode/commands/Return.rb +16 -0
- data/lib/cloudrail_si/servicecode/commands/Set.rb +23 -0
- data/lib/cloudrail_si/servicecode/commands/Size.rb +26 -0
- data/lib/cloudrail_si/servicecode/commands/ThrowError.rb +17 -0
- data/lib/cloudrail_si/servicecode/commands/array/Uint8ToBase64.rb +25 -0
- data/lib/cloudrail_si/servicecode/commands/debug/Out.rb +24 -0
- data/lib/cloudrail_si/servicecode/commands/hash/md5.rb +29 -0
- data/lib/cloudrail_si/servicecode/commands/hash/sha1.rb +30 -0
- data/lib/cloudrail_si/servicecode/commands/http/RequestCall.rb +51 -0
- data/lib/cloudrail_si/servicecode/commands/json/Parse.rb +40 -0
- data/lib/cloudrail_si/servicecode/commands/json/Stringify.rb +21 -0
- data/lib/cloudrail_si/servicecode/commands/math/Floor.rb +27 -0
- data/lib/cloudrail_si/servicecode/commands/math/MathCombine.rb +35 -0
- data/lib/cloudrail_si/servicecode/commands/object/GetKeyArray.rb +21 -0
- data/lib/cloudrail_si/servicecode/commands/object/GetKeyValueArrays.rb +29 -0
- data/lib/cloudrail_si/servicecode/commands/stream/MakeJoinedStream.rb +38 -0
- data/lib/cloudrail_si/servicecode/commands/stream/MakeLimitedStream.rb +23 -0
- data/lib/cloudrail_si/servicecode/commands/stream/StreamToString.rb +25 -0
- data/lib/cloudrail_si/servicecode/commands/stream/StringToStream.rb +20 -0
- data/lib/cloudrail_si/servicecode/commands/string/Base64Encode.rb +42 -0
- data/lib/cloudrail_si/servicecode/commands/string/Format.rb +43 -0
- data/lib/cloudrail_si/servicecode/commands/string/IndexOf.rb +29 -0
- data/lib/cloudrail_si/servicecode/commands/string/LastIndexOf.rb +29 -0
- data/lib/cloudrail_si/servicecode/commands/string/Split.rb +29 -0
- data/lib/cloudrail_si/servicecode/commands/string/StringTransform.rb +29 -0
- data/lib/cloudrail_si/servicecode/commands/string/Substr.rb +30 -0
- data/lib/cloudrail_si/servicecode/commands/string/Substring.rb +30 -0
- data/lib/cloudrail_si/services/Facebook.rb +528 -0
- data/lib/cloudrail_si/services/FacebookPage.rb +310 -0
- data/lib/cloudrail_si/services/Foursquare.rb +314 -0
- data/lib/cloudrail_si/services/GitHub.rb +354 -0
- data/lib/cloudrail_si/services/GooglePlaces.rb +309 -0
- data/lib/cloudrail_si/services/GooglePlus.rb +367 -0
- data/lib/cloudrail_si/services/Instagram.rb +342 -0
- data/lib/cloudrail_si/services/LinkedIn.rb +363 -0
- data/lib/cloudrail_si/services/MicrosoftLive.rb +346 -0
- data/lib/cloudrail_si/services/Nexmo.rb +173 -0
- data/lib/cloudrail_si/services/Slack.rb +318 -0
- data/lib/cloudrail_si/services/Twilio.rb +173 -0
- data/lib/cloudrail_si/services/Twitter.rb +795 -0
- data/lib/cloudrail_si/services/Yahoo.rb +408 -0
- data/lib/cloudrail_si/services/Yelp.rb +389 -0
- data/lib/cloudrail_si/statistics/Statistics.rb +125 -0
- data/lib/cloudrail_si/types/Address.rb +9 -0
- data/lib/cloudrail_si/types/Charge.rb +33 -0
- data/lib/cloudrail_si/types/CloudMetaData.rb +19 -0
- data/lib/cloudrail_si/types/CreditCard.rb +76 -0
- data/lib/cloudrail_si/types/Date.rb +49 -0
- data/lib/cloudrail_si/types/DateOfBirth.rb +16 -0
- data/lib/cloudrail_si/types/Error.rb +21 -0
- data/lib/cloudrail_si/types/Location.rb +8 -0
- data/lib/cloudrail_si/types/POI.rb +17 -0
- data/lib/cloudrail_si/types/Refund.rb +25 -0
- data/lib/cloudrail_si/types/SandboxObject.rb +20 -0
- data/lib/cloudrail_si/types/SpaceAllocation.rb +13 -0
- data/lib/cloudrail_si/types/Subscription.rb +27 -0
- data/lib/cloudrail_si/types/SubscriptionPlan.rb +26 -0
- data/lib/cloudrail_si/types/Types.rb +43 -0
- data/lib/cloudrail_si/version.rb +3 -0
- metadata +205 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
require_relative '../servicecode/Interpreter'
|
|
2
|
+
require_relative '../servicecode/Sandbox'
|
|
3
|
+
require_relative '../errors/DetailErrors'
|
|
4
|
+
require_relative '../servicecode/InitSelfTest'
|
|
5
|
+
require_relative '../statistics/Statistics'
|
|
6
|
+
|
|
7
|
+
module CloudRailSi
|
|
8
|
+
module Services
|
|
9
|
+
class GooglePlus
|
|
10
|
+
|
|
11
|
+
SERVICE_CODE = {
|
|
12
|
+
|
|
13
|
+
"AdvancedRequestSupporter:advancedRequest" => [
|
|
14
|
+
[ "create", "$L0", "Object"],
|
|
15
|
+
[ "create", "$L0.url", "String"],
|
|
16
|
+
[ "if!=than", "$P2.appendBaseUrl", 0, 1],
|
|
17
|
+
[ "set", "$L0.url", "https://www.googleapis.com/plus/v1"],
|
|
18
|
+
[ "string.concat", "$L0.url", "$L0.url", "$P2.url"],
|
|
19
|
+
[ "set", "$L0.requestHeaders", "$P2.headers"],
|
|
20
|
+
[ "set", "$L0.method", "$P2.method"],
|
|
21
|
+
[ "set", "$L0.requestBody", "$P2.body"],
|
|
22
|
+
[ "if!=than", "$P2.appendAuthorization", 0, 2],
|
|
23
|
+
[ "callFunc", "checkAuthentication", "$P0"],
|
|
24
|
+
[ "string.concat", "$L0.requestHeaders.Authorization", "Bearer ", "$S0.accessToken"],
|
|
25
|
+
[ "http.requestCall", "$L1", "$L0"],
|
|
26
|
+
[ "if!=than", "$P2.checkErrors", 0, 1],
|
|
27
|
+
[ "callFunc", "validateResponse", "$P0", "$L1"],
|
|
28
|
+
[ "create", "$P1", "AdvancedRequestResponse"],
|
|
29
|
+
[ "set", "$P1.status", "$L1.code"],
|
|
30
|
+
[ "set", "$P1.headers", "$L1.responseHeaders"],
|
|
31
|
+
[ "set", "$P1.body", "$L1.responseBody"]
|
|
32
|
+
|
|
33
|
+
],
|
|
34
|
+
|
|
35
|
+
"Authenticating:login" => [
|
|
36
|
+
[ "callFunc", "checkAuthentication", "$P0"]
|
|
37
|
+
|
|
38
|
+
],
|
|
39
|
+
|
|
40
|
+
"Authenticating:logout" => [
|
|
41
|
+
[ "create", "$L0", "Object"],
|
|
42
|
+
[ "string.concat", "$L0.url", "https://accounts.google.com/o/oauth2/revoke?token=", "$S0.accessToken"],
|
|
43
|
+
[ "set", "$L0.method", "GET"],
|
|
44
|
+
[ "http.requestCall", "$L1", "$L0"],
|
|
45
|
+
[ "callFunc", "validateResponse", "$P0", "$L1"],
|
|
46
|
+
[ "set", "$S0.accessToken", nil],
|
|
47
|
+
[ "set", "$P0.userInfo", nil]
|
|
48
|
+
|
|
49
|
+
],
|
|
50
|
+
|
|
51
|
+
"Profile:getIdentifier" => [
|
|
52
|
+
[ "callFunc", "checkUserInfo", "$P0"],
|
|
53
|
+
[ "string.concat", "$P1", "googleplus-", "$P0.userInfo.id"]
|
|
54
|
+
|
|
55
|
+
],
|
|
56
|
+
|
|
57
|
+
"Profile:getFullName" => [
|
|
58
|
+
[ "callFunc", "checkUserInfo", "$P0"],
|
|
59
|
+
[ "if!=than", "$P0.userInfo.displayName", nil, 1],
|
|
60
|
+
[ "set", "$P1", "$P0.userInfo.displayName"]
|
|
61
|
+
|
|
62
|
+
],
|
|
63
|
+
|
|
64
|
+
"Profile:getEmail" => [
|
|
65
|
+
[ "callFunc", "checkUserInfo", "$P0"],
|
|
66
|
+
[ "get", "$P1", "$P0.userInfo.emails", 0, "value"]
|
|
67
|
+
|
|
68
|
+
],
|
|
69
|
+
|
|
70
|
+
"Profile:getGender" => [
|
|
71
|
+
[ "callFunc", "checkUserInfo", "$P0"],
|
|
72
|
+
[ "if!=than", "$P0.userInfo.gender", nil, 1],
|
|
73
|
+
[ "set", "$P1", "$P0.userInfo.gender"]
|
|
74
|
+
|
|
75
|
+
],
|
|
76
|
+
|
|
77
|
+
"Profile:getDescription" => [
|
|
78
|
+
[ "callFunc", "checkUserInfo", "$P0"],
|
|
79
|
+
[ "if!=than", "$P0.userInfo.aboutMe", nil, 1],
|
|
80
|
+
[ "set", "$P1", "$P0.userInfo.aboutMe"]
|
|
81
|
+
|
|
82
|
+
],
|
|
83
|
+
|
|
84
|
+
"Profile:getDateOfBirth" => [
|
|
85
|
+
[ "callFunc", "checkUserInfo", "$P0"],
|
|
86
|
+
[ "create", "$P1", "DateOfBirth"],
|
|
87
|
+
[ "if!=than", "$P0.userInfo.birthday", nil, 10],
|
|
88
|
+
[ "string.split", "$L0", "$P0.userInfo.birthday", "-"],
|
|
89
|
+
[ "get", "$L1", "$L0", 0],
|
|
90
|
+
[ "if!=than", "$L1", "0000", 1],
|
|
91
|
+
[ "math.add", "$P1.year", "$L1", 0],
|
|
92
|
+
[ "get", "$L1", "$L0", 1],
|
|
93
|
+
[ "if!=than", "$L1", "00", 1],
|
|
94
|
+
[ "math.add", "$P1.month", "$L1", 0],
|
|
95
|
+
[ "get", "$L1", "$L0", 2],
|
|
96
|
+
[ "if!=than", "$L1", "00", 1],
|
|
97
|
+
[ "math.add", "$P1.day", "$L1", 0]
|
|
98
|
+
|
|
99
|
+
],
|
|
100
|
+
|
|
101
|
+
"Profile:getLocale" => [
|
|
102
|
+
[ "callFunc", "checkUserInfo", "$P0"],
|
|
103
|
+
[ "if!=than", "$P0.userInfo.language", nil, 1],
|
|
104
|
+
[ "set", "$P1", "$P0.userInfo.language"]
|
|
105
|
+
|
|
106
|
+
],
|
|
107
|
+
|
|
108
|
+
"Profile:getPictureURL" => [
|
|
109
|
+
[ "callFunc", "checkUserInfo", "$P0"],
|
|
110
|
+
[ "if!=than", "$P0.userInfo.image.url", nil, 1],
|
|
111
|
+
[ "set", "$P1", "$P0.userInfo.image.url"]
|
|
112
|
+
|
|
113
|
+
],
|
|
114
|
+
|
|
115
|
+
"checkUserInfo" => [
|
|
116
|
+
[ "create", "$L0", "Date"],
|
|
117
|
+
[ "if!=than", "$P0.userInfo", nil, 2],
|
|
118
|
+
[ "if>than", "$P0.expirationTime", "$L0", 1],
|
|
119
|
+
[ "return"],
|
|
120
|
+
[ "callFunc", "checkAuthentication", "$P0"],
|
|
121
|
+
[ "create", "$L2", "Object"],
|
|
122
|
+
[ "set", "$L2.url", "https://www.googleapis.com/plus/v1/people/me"],
|
|
123
|
+
[ "create", "$L2.requestHeaders", "Object"],
|
|
124
|
+
[ "string.concat", "$L2.requestHeaders.Authorization", "Bearer ", "$S0.accessToken"],
|
|
125
|
+
[ "set", "$L2.method", "GET"],
|
|
126
|
+
[ "http.requestCall", "$L3", "$L2"],
|
|
127
|
+
[ "callFunc", "validateResponse", "$P0", "$L3"],
|
|
128
|
+
[ "json.parse", "$P0.userInfo", "$L3.responseBody"],
|
|
129
|
+
[ "create", "$P0.expirationTime", "Date"],
|
|
130
|
+
[ "math.add", "$P0.expirationTime.time", "$P0.expirationTime.time", 60000]
|
|
131
|
+
|
|
132
|
+
],
|
|
133
|
+
|
|
134
|
+
"checkAuthentication" => [
|
|
135
|
+
[ "create", "$L0", "Date"],
|
|
136
|
+
[ "if==than", "$S0.accessToken", nil, 2],
|
|
137
|
+
[ "callFunc", "authenticate", "$P0", "accessToken"],
|
|
138
|
+
[ "return"],
|
|
139
|
+
[ "create", "$L1", "Date"],
|
|
140
|
+
[ "set", "$L1.time", "$S0.expireIn"],
|
|
141
|
+
[ "if<than", "$L1", "$L0", 1],
|
|
142
|
+
[ "callFunc", "authenticate", "$P0", "refreshToken"]
|
|
143
|
+
|
|
144
|
+
],
|
|
145
|
+
|
|
146
|
+
"authenticate" => [
|
|
147
|
+
[ "create", "$L2", "String"],
|
|
148
|
+
[ "if==than", "$P1", "accessToken", 4],
|
|
149
|
+
[ "string.concat", "$L0", "https://accounts.google.com/o/oauth2/v2/auth?client_id=", "$P0.clientID", "&scope=", "https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fplus.me+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile", "&response_type=code&prompt=consent&access_type=offline&redirect_uri=", "$P0.redirectUri", "&state=", "$P0.state", "&suppress_webview_warning=true"],
|
|
150
|
+
[ "awaitCodeRedirect", "$L1", "$L0"],
|
|
151
|
+
[ "string.concat", "$L2", "client_id=", "$P0.clientID", "&redirect_uri=", "$P0.redirectUri", "&client_secret=", "$P0.clientSecret", "&code=", "$L1", "&grant_type=authorization_code"],
|
|
152
|
+
[ "jumpRel", 1],
|
|
153
|
+
[ "string.concat", "$L2", "client_id=", "$P0.clientID", "&redirect_uri=", "$P0.redirectUri", "&client_secret=", "$P0.clientSecret", "&refresh_token=", "$S0.refreshToken", "&grant_type=refresh_token"],
|
|
154
|
+
[ "stream.stringToStream", "$L3", "$L2"],
|
|
155
|
+
[ "create", "$L4", "Object"],
|
|
156
|
+
[ "set", "$L4", "application/x-www-form-urlencoded", "Content-Type"],
|
|
157
|
+
[ "create", "$L5", "Object"],
|
|
158
|
+
[ "set", "$L5.url", "https://www.googleapis.com/oauth2/v4/token"],
|
|
159
|
+
[ "set", "$L5.method", "POST"],
|
|
160
|
+
[ "set", "$L5.requestBody", "$L3"],
|
|
161
|
+
[ "set", "$L5.requestHeaders", "$L4"],
|
|
162
|
+
[ "http.requestCall", "$L6", "$L5"],
|
|
163
|
+
[ "callFunc", "validateResponse", "$P0", "$L6"],
|
|
164
|
+
[ "stream.streamToString", "$L7", "$L6.responseBody"],
|
|
165
|
+
[ "json.parse", "$L8", "$L7"],
|
|
166
|
+
[ "set", "$S0.accessToken", "$L8.access_token"],
|
|
167
|
+
[ "if!=than", "$L8.refresh_token", nil, 1],
|
|
168
|
+
[ "set", "$S0.refreshToken", "$L8.refresh_token"],
|
|
169
|
+
[ "create", "$L10", "Date"],
|
|
170
|
+
[ "math.multiply", "$L9", "$L8.expires_in", 1000],
|
|
171
|
+
[ "math.add", "$L9", "$L9", "$L10.time", -60000],
|
|
172
|
+
[ "set", "$S0.expireIn", "$L9"]
|
|
173
|
+
|
|
174
|
+
],
|
|
175
|
+
|
|
176
|
+
"validateResponse" => [
|
|
177
|
+
[ "if>=than", "$P1.code", 400, 19],
|
|
178
|
+
[ "stream.streamToString", "$L2", "$P1.responseBody"],
|
|
179
|
+
[ "if==than", "$P1.code", 401, 2],
|
|
180
|
+
[ "create", "$L3", "Error", "$L2", "Authentication"],
|
|
181
|
+
[ "throwError", "$L3"],
|
|
182
|
+
[ "if==than", "$P1.code", 400, 2],
|
|
183
|
+
[ "create", "$L3", "Error", "$L2", "Http"],
|
|
184
|
+
[ "throwError", "$L3"],
|
|
185
|
+
[ "if>=than", "$P1.code", 402, 5],
|
|
186
|
+
[ "if<=than", "$P1.code", 509, 4],
|
|
187
|
+
[ "if!=than", "$P1.code", 503, 3],
|
|
188
|
+
[ "if!=than", "$P1.code", 404, 2],
|
|
189
|
+
[ "create", "$L3", "Error", "$L2", "Http"],
|
|
190
|
+
[ "throwError", "$L3"],
|
|
191
|
+
[ "if==than", "$P1.code", 503, 2],
|
|
192
|
+
[ "create", "$L3", "Error", "$L2", "ServiceUnavailable"],
|
|
193
|
+
[ "throwError", "$L3"],
|
|
194
|
+
[ "if==than", "$P1.code", 404, 2],
|
|
195
|
+
[ "create", "$L3", "Error", "$L2", "NotFound"],
|
|
196
|
+
[ "throwError", "$L3"]
|
|
197
|
+
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
def initialize(redirect_receiver, client_id, client_secret, redirect_uri, state)
|
|
203
|
+
@interpreter_storage = {}
|
|
204
|
+
@persistent_storage = [{}]
|
|
205
|
+
@instance_dependency_storage = {
|
|
206
|
+
redirect_receiver: redirect_receiver
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
ServiceCode::InitSelfTest.init_test('GooglePlus')
|
|
210
|
+
|
|
211
|
+
@interpreter_storage['clientID'] = client_id
|
|
212
|
+
@interpreter_storage['clientSecret'] = client_secret
|
|
213
|
+
@interpreter_storage['redirectUri'] = redirect_uri
|
|
214
|
+
@interpreter_storage['state'] = state
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
# call init servicecode function
|
|
220
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
221
|
+
# check and call the initialization function if is available
|
|
222
|
+
|
|
223
|
+
ip.call_function_sync('init', @interpreter_storage) if (SERVICE_CODE['init'])
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def check_for_error(error)
|
|
227
|
+
if (error)
|
|
228
|
+
ServiceCode::Statistics.add_error('GooglePlus', '')
|
|
229
|
+
case (error.type)
|
|
230
|
+
when 'IllegalArgument'
|
|
231
|
+
raise Errors::IllegalArgumentError.new(error.message)
|
|
232
|
+
when 'Authentication'
|
|
233
|
+
raise Errors::AuthenticationError.new(error.message)
|
|
234
|
+
when 'NotFound'
|
|
235
|
+
raise Errors::NotFoundError.new(error.message)
|
|
236
|
+
when 'Http'
|
|
237
|
+
raise Errors::HttpError.new(error.message)
|
|
238
|
+
when 'ServiceUnavailable'
|
|
239
|
+
raise Errors::ServiceUnavailableError.new(error.message)
|
|
240
|
+
else
|
|
241
|
+
raise Errors::StandardError.new(error.message)
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def get_identifier()
|
|
248
|
+
ServiceCode::Statistics.add_call('GooglePlus', 'get_identifier')
|
|
249
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
250
|
+
ip.call_function('Profile:getIdentifier', @interpreter_storage, nil)
|
|
251
|
+
|
|
252
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
253
|
+
return nil || ip.get_parameter(1)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def get_full_name()
|
|
257
|
+
ServiceCode::Statistics.add_call('GooglePlus', 'get_full_name')
|
|
258
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
259
|
+
ip.call_function('Profile:getFullName', @interpreter_storage, nil)
|
|
260
|
+
|
|
261
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
262
|
+
return nil || ip.get_parameter(1)
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def get_email()
|
|
266
|
+
ServiceCode::Statistics.add_call('GooglePlus', 'get_email')
|
|
267
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
268
|
+
ip.call_function('Profile:getEmail', @interpreter_storage, nil)
|
|
269
|
+
|
|
270
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
271
|
+
return nil || ip.get_parameter(1)
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def get_gender()
|
|
275
|
+
ServiceCode::Statistics.add_call('GooglePlus', 'get_gender')
|
|
276
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
277
|
+
ip.call_function('Profile:getGender', @interpreter_storage, nil)
|
|
278
|
+
|
|
279
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
280
|
+
return nil || ip.get_parameter(1)
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def get_description()
|
|
284
|
+
ServiceCode::Statistics.add_call('GooglePlus', 'get_description')
|
|
285
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
286
|
+
ip.call_function('Profile:getDescription', @interpreter_storage, nil)
|
|
287
|
+
|
|
288
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
289
|
+
return nil || ip.get_parameter(1)
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
def get_date_of_birth()
|
|
293
|
+
ServiceCode::Statistics.add_call('GooglePlus', 'get_date_of_birth')
|
|
294
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
295
|
+
ip.call_function('Profile:getDateOfBirth', @interpreter_storage, nil)
|
|
296
|
+
|
|
297
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
298
|
+
return nil || ip.get_parameter(1)
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
def get_locale()
|
|
302
|
+
ServiceCode::Statistics.add_call('GooglePlus', 'get_locale')
|
|
303
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
304
|
+
ip.call_function('Profile:getLocale', @interpreter_storage, nil)
|
|
305
|
+
|
|
306
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
307
|
+
return nil || ip.get_parameter(1)
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
def get_picture_url()
|
|
311
|
+
ServiceCode::Statistics.add_call('GooglePlus', 'get_picture_url')
|
|
312
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
313
|
+
ip.call_function('Profile:getPictureURL', @interpreter_storage, nil)
|
|
314
|
+
|
|
315
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
316
|
+
return nil || ip.get_parameter(1)
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
def login()
|
|
320
|
+
ServiceCode::Statistics.add_call('GooglePlus', 'login')
|
|
321
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
322
|
+
ip.call_function('Authenticating:login', @interpreter_storage)
|
|
323
|
+
|
|
324
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
325
|
+
return nil
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
def logout()
|
|
329
|
+
ServiceCode::Statistics.add_call('GooglePlus', 'logout')
|
|
330
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
331
|
+
ip.call_function('Authenticating:logout', @interpreter_storage)
|
|
332
|
+
|
|
333
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
334
|
+
return nil
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
def advanced_request(specification)
|
|
338
|
+
ServiceCode::Statistics.add_call('GooglePlus', 'advanced_request')
|
|
339
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
340
|
+
ip.call_function('AdvancedRequestSupporter:advancedRequest', @interpreter_storage, nil, specification)
|
|
341
|
+
|
|
342
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
343
|
+
return nil || ip.get_parameter(1)
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def save_as_string
|
|
348
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
349
|
+
return ip.save_as_string()
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
def load_as_string(saved_state)
|
|
353
|
+
sandbox = ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage)
|
|
354
|
+
ip = ServiceCode::Interpreter.new(sandbox)
|
|
355
|
+
ip.load_as_string(saved_state)
|
|
356
|
+
@persistent_storage = sandbox.persistent_storage
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
def resume_login(execution_state, callback)
|
|
360
|
+
sandbox = ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage)
|
|
361
|
+
sandbox.load_state_from_string(execution_state)
|
|
362
|
+
ip = ServiceCode::Interpreter.new(sandbox)
|
|
363
|
+
ip.resume_function('Authenticating:login', @interpreter_storage, callback)
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
end
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
require_relative '../servicecode/Interpreter'
|
|
2
|
+
require_relative '../servicecode/Sandbox'
|
|
3
|
+
require_relative '../errors/DetailErrors'
|
|
4
|
+
require_relative '../servicecode/InitSelfTest'
|
|
5
|
+
require_relative '../statistics/Statistics'
|
|
6
|
+
|
|
7
|
+
module CloudRailSi
|
|
8
|
+
module Services
|
|
9
|
+
class Instagram
|
|
10
|
+
|
|
11
|
+
SERVICE_CODE = {
|
|
12
|
+
|
|
13
|
+
"AdvancedRequestSupporter:advancedRequest" => [
|
|
14
|
+
[ "create", "$L0", "Object"],
|
|
15
|
+
[ "create", "$L0.url", "String"],
|
|
16
|
+
[ "if!=than", "$P2.appendBaseUrl", 0, 1],
|
|
17
|
+
[ "set", "$L0.url", "https://api.instagram.com/v1"],
|
|
18
|
+
[ "string.concat", "$L0.url", "$L0.url", "$P2.url"],
|
|
19
|
+
[ "set", "$L0.requestHeaders", "$P2.headers"],
|
|
20
|
+
[ "set", "$L0.method", "$P2.method"],
|
|
21
|
+
[ "set", "$L0.requestBody", "$P2.body"],
|
|
22
|
+
[ "if!=than", "$P2.appendAuthorization", 0, 6],
|
|
23
|
+
[ "callFunc", "checkAuthentication", "$P0"],
|
|
24
|
+
[ "string.indexOf", "$L2", "$P2.url", "?"],
|
|
25
|
+
[ "if==than", "$L2", -1, 2],
|
|
26
|
+
[ "string.concat", "$L0.url", "$L0.url", "?access_token=", "$S0.accessToken"],
|
|
27
|
+
[ "jumpRel", 1],
|
|
28
|
+
[ "string.concat", "$L0.url", "$L0.url", "&access_token=", "$S0.accessToken"],
|
|
29
|
+
[ "http.requestCall", "$L1", "$L0"],
|
|
30
|
+
[ "if!=than", "$P2.checkErrors", 0, 1],
|
|
31
|
+
[ "callFunc", "validateResponse", "$P0", "$L1"],
|
|
32
|
+
[ "create", "$P1", "AdvancedRequestResponse"],
|
|
33
|
+
[ "set", "$P1.status", "$L1.code"],
|
|
34
|
+
[ "set", "$P1.headers", "$L1.responseHeaders"],
|
|
35
|
+
[ "set", "$P1.body", "$L1.responseBody"]
|
|
36
|
+
|
|
37
|
+
],
|
|
38
|
+
|
|
39
|
+
"Authenticating:login" => [
|
|
40
|
+
[ "callFunc", "checkAuthentication", "$P0"]
|
|
41
|
+
|
|
42
|
+
],
|
|
43
|
+
|
|
44
|
+
"Authenticating:logout" => [
|
|
45
|
+
[ "set", "$S0.accessToken", nil]
|
|
46
|
+
|
|
47
|
+
],
|
|
48
|
+
|
|
49
|
+
"Profile:getIdentifier" => [
|
|
50
|
+
[ "callFunc", "updateUserInfo", "$P0"],
|
|
51
|
+
[ "set", "$P1", "$P0.userInfo.id"]
|
|
52
|
+
|
|
53
|
+
],
|
|
54
|
+
|
|
55
|
+
"Profile:getFullName" => [
|
|
56
|
+
[ "callFunc", "updateUserInfo", "$P0"],
|
|
57
|
+
[ "set", "$P1", "$P0.userInfo.fullName"]
|
|
58
|
+
|
|
59
|
+
],
|
|
60
|
+
|
|
61
|
+
"Profile:getPictureURL" => [
|
|
62
|
+
[ "callFunc", "updateUserInfo", "$P0"],
|
|
63
|
+
[ "set", "$P1", "$P0.userInfo.pictureURL"]
|
|
64
|
+
|
|
65
|
+
],
|
|
66
|
+
|
|
67
|
+
"Profile:getDescription" => [
|
|
68
|
+
[ "callFunc", "updateUserInfo", "$P0"],
|
|
69
|
+
[ "set", "$P1", "$P0.userInfo.description"]
|
|
70
|
+
|
|
71
|
+
],
|
|
72
|
+
|
|
73
|
+
"Profile:getEmail" => [
|
|
74
|
+
[ "set", "$P1", nil]
|
|
75
|
+
|
|
76
|
+
],
|
|
77
|
+
|
|
78
|
+
"Profile:getGender" => [
|
|
79
|
+
[ "set", "$P1", nil]
|
|
80
|
+
|
|
81
|
+
],
|
|
82
|
+
|
|
83
|
+
"Profile:getDateOfBirth" => [
|
|
84
|
+
[ "create", "$P1", "DateOfBirth"]
|
|
85
|
+
|
|
86
|
+
],
|
|
87
|
+
|
|
88
|
+
"Profile:getLocale" => [
|
|
89
|
+
|
|
90
|
+
],
|
|
91
|
+
|
|
92
|
+
"checkAuthentication" => [
|
|
93
|
+
[ "if==than", "$S0.accessToken", nil, 1],
|
|
94
|
+
[ "callFunc", "authenticate", "$P0"]
|
|
95
|
+
|
|
96
|
+
],
|
|
97
|
+
|
|
98
|
+
"authenticate" => [
|
|
99
|
+
[ "create", "$L2", "String"],
|
|
100
|
+
[ "string.concat", "$L0", "https://api.instagram.com/oauth/authorize/?client_id=", "$P0.clientID", "&response_type=code&redirect_uri=", "$P0.redirectUri", "&state=", "$P0.state"],
|
|
101
|
+
[ "awaitCodeRedirect", "$L1", "$L0"],
|
|
102
|
+
[ "string.concat", "$L2", "--------------------------c77df4126e3a1dc1\r\n"],
|
|
103
|
+
[ "string.concat", "$L2", "$L2", "Content-Disposition: form-data; name=\"client_id\"\r\n\r\n"],
|
|
104
|
+
[ "string.concat", "$L2", "$L2", "$P0.clientID", "\r\n"],
|
|
105
|
+
[ "string.concat", "$L2", "$L2", "--------------------------c77df4126e3a1dc1\r\n"],
|
|
106
|
+
[ "string.concat", "$L2", "$L2", "Content-Disposition: form-data; name=\"client_secret\"\r\n\r\n"],
|
|
107
|
+
[ "string.concat", "$L2", "$L2", "$P0.clientSecret", "\r\n"],
|
|
108
|
+
[ "string.concat", "$L2", "$L2", "--------------------------c77df4126e3a1dc1\r\n"],
|
|
109
|
+
[ "string.concat", "$L2", "$L2", "Content-Disposition: form-data; name=\"grant_type\"\r\n\r\n"],
|
|
110
|
+
[ "string.concat", "$L2", "$L2", "authorization_code\r\n"],
|
|
111
|
+
[ "string.concat", "$L2", "$L2", "--------------------------c77df4126e3a1dc1\r\n"],
|
|
112
|
+
[ "string.concat", "$L2", "$L2", "Content-Disposition: form-data; name=\"redirect_uri\"\r\n\r\n"],
|
|
113
|
+
[ "string.concat", "$L2", "$L2", "$P0.redirectUri", "\r\n"],
|
|
114
|
+
[ "string.concat", "$L2", "$L2", "--------------------------c77df4126e3a1dc1\r\n"],
|
|
115
|
+
[ "string.concat", "$L2", "$L2", "Content-Disposition: form-data; name=\"code\"\r\n\r\n"],
|
|
116
|
+
[ "string.concat", "$L2", "$L2", "$L1", "\r\n"],
|
|
117
|
+
[ "string.concat", "$L2", "$L2", "--------------------------c77df4126e3a1dc1--\r\n"],
|
|
118
|
+
[ "stream.stringToStream", "$L3", "$L2"],
|
|
119
|
+
[ "create", "$L4", "Object"],
|
|
120
|
+
[ "set", "$L4", "multipart/form-data; boundary=------------------------c77df4126e3a1dc1", "Content-Type"],
|
|
121
|
+
[ "size", "$L20", "$L2"],
|
|
122
|
+
[ "string.concat", "$L4.Content-Length", "$L20"],
|
|
123
|
+
[ "create", "$L5", "Object"],
|
|
124
|
+
[ "set", "$L5.url", "https://api.instagram.com/oauth/access_token"],
|
|
125
|
+
[ "set", "$L5.method", "POST"],
|
|
126
|
+
[ "set", "$L5.requestBody", "$L3"],
|
|
127
|
+
[ "set", "$L5.requestHeaders", "$L4"],
|
|
128
|
+
[ "http.requestCall", "$L6", "$L5"],
|
|
129
|
+
[ "callFunc", "validateResponse", "$P0", "$L6"],
|
|
130
|
+
[ "stream.streamToString", "$L7", "$L6.responseBody"],
|
|
131
|
+
[ "json.parse", "$L8", "$L7"],
|
|
132
|
+
[ "set", "$S0.accessToken", "$L8.access_token"]
|
|
133
|
+
|
|
134
|
+
],
|
|
135
|
+
|
|
136
|
+
"parseUser" => [
|
|
137
|
+
[ "create", "$L0", "Object"],
|
|
138
|
+
[ "create", "$L1", "Date"],
|
|
139
|
+
[ "math.add", "$L0.expires", "$L1.time", 60000],
|
|
140
|
+
[ "string.concat", "$L0.id", "instagram-", "$P1.id"],
|
|
141
|
+
[ "set", "$L0.fullName", "$P1.full_name"],
|
|
142
|
+
[ "set", "$L0.pictureURL", "$P1.profile_picture"],
|
|
143
|
+
[ "set", "$L0.description", "$P1.bio"],
|
|
144
|
+
[ "set", "$P0.userInfo", "$L0"]
|
|
145
|
+
|
|
146
|
+
],
|
|
147
|
+
|
|
148
|
+
"updateUserInfo" => [
|
|
149
|
+
[ "callFunc", "checkAuthentication", "$P0"],
|
|
150
|
+
[ "if!=than", "$P0.userInfo", nil, 3],
|
|
151
|
+
[ "create", "$L0", "Date"],
|
|
152
|
+
[ "if<than", "$L0.time", "$P0.userInfo.expires", 1],
|
|
153
|
+
[ "return"],
|
|
154
|
+
[ "create", "$L0", "Object"],
|
|
155
|
+
[ "set", "$L0.method", "GET"],
|
|
156
|
+
[ "string.concat", "$L0.url", "https://api.instagram.com/v1/users/self/?access_token=", "$S0.accessToken"],
|
|
157
|
+
[ "http.requestCall", "$L1", "$L0"],
|
|
158
|
+
[ "callFunc", "validateResponse", "$P0", "$L1"],
|
|
159
|
+
[ "json.parse", "$L2", "$L1.responseBody"],
|
|
160
|
+
[ "callFunc", "parseUser", "$P0", "$L2.data"]
|
|
161
|
+
|
|
162
|
+
],
|
|
163
|
+
|
|
164
|
+
"validateResponse" => [
|
|
165
|
+
[ "if>=than", "$P1.code", 400, 6],
|
|
166
|
+
[ "json.parse", "$L0", "$P1.responseBody"],
|
|
167
|
+
[ "set", "$L2", "$L0.error_message"],
|
|
168
|
+
[ "if==than", "$L2", nil, 1],
|
|
169
|
+
[ "set", "$L2", "$L0.meta.error_message"],
|
|
170
|
+
[ "create", "$L3", "Error", "$L2", "Http"],
|
|
171
|
+
[ "throwError", "$L3"]
|
|
172
|
+
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
def initialize(redirect_receiver, client_id, client_secret, redirect_uri, state)
|
|
178
|
+
@interpreter_storage = {}
|
|
179
|
+
@persistent_storage = [{}]
|
|
180
|
+
@instance_dependency_storage = {
|
|
181
|
+
redirect_receiver: redirect_receiver
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
ServiceCode::InitSelfTest.init_test('Instagram')
|
|
185
|
+
|
|
186
|
+
@interpreter_storage['clientID'] = client_id
|
|
187
|
+
@interpreter_storage['clientSecret'] = client_secret
|
|
188
|
+
@interpreter_storage['redirectUri'] = redirect_uri
|
|
189
|
+
@interpreter_storage['state'] = state
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
# call init servicecode function
|
|
195
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
196
|
+
# check and call the initialization function if is available
|
|
197
|
+
|
|
198
|
+
ip.call_function_sync('init', @interpreter_storage) if (SERVICE_CODE['init'])
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def check_for_error(error)
|
|
202
|
+
if (error)
|
|
203
|
+
ServiceCode::Statistics.add_error('Instagram', '')
|
|
204
|
+
case (error.type)
|
|
205
|
+
when 'IllegalArgument'
|
|
206
|
+
raise Errors::IllegalArgumentError.new(error.message)
|
|
207
|
+
when 'Authentication'
|
|
208
|
+
raise Errors::AuthenticationError.new(error.message)
|
|
209
|
+
when 'NotFound'
|
|
210
|
+
raise Errors::NotFoundError.new(error.message)
|
|
211
|
+
when 'Http'
|
|
212
|
+
raise Errors::HttpError.new(error.message)
|
|
213
|
+
when 'ServiceUnavailable'
|
|
214
|
+
raise Errors::ServiceUnavailableError.new(error.message)
|
|
215
|
+
else
|
|
216
|
+
raise Errors::StandardError.new(error.message)
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def get_identifier()
|
|
223
|
+
ServiceCode::Statistics.add_call('Instagram', 'get_identifier')
|
|
224
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
225
|
+
ip.call_function('Profile:getIdentifier', @interpreter_storage, nil)
|
|
226
|
+
|
|
227
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
228
|
+
return nil || ip.get_parameter(1)
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def get_full_name()
|
|
232
|
+
ServiceCode::Statistics.add_call('Instagram', 'get_full_name')
|
|
233
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
234
|
+
ip.call_function('Profile:getFullName', @interpreter_storage, nil)
|
|
235
|
+
|
|
236
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
237
|
+
return nil || ip.get_parameter(1)
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def get_email()
|
|
241
|
+
ServiceCode::Statistics.add_call('Instagram', 'get_email')
|
|
242
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
243
|
+
ip.call_function('Profile:getEmail', @interpreter_storage, nil)
|
|
244
|
+
|
|
245
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
246
|
+
return nil || ip.get_parameter(1)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def get_gender()
|
|
250
|
+
ServiceCode::Statistics.add_call('Instagram', 'get_gender')
|
|
251
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
252
|
+
ip.call_function('Profile:getGender', @interpreter_storage, nil)
|
|
253
|
+
|
|
254
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
255
|
+
return nil || ip.get_parameter(1)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def get_description()
|
|
259
|
+
ServiceCode::Statistics.add_call('Instagram', 'get_description')
|
|
260
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
261
|
+
ip.call_function('Profile:getDescription', @interpreter_storage, nil)
|
|
262
|
+
|
|
263
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
264
|
+
return nil || ip.get_parameter(1)
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def get_date_of_birth()
|
|
268
|
+
ServiceCode::Statistics.add_call('Instagram', 'get_date_of_birth')
|
|
269
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
270
|
+
ip.call_function('Profile:getDateOfBirth', @interpreter_storage, nil)
|
|
271
|
+
|
|
272
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
273
|
+
return nil || ip.get_parameter(1)
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def get_locale()
|
|
277
|
+
ServiceCode::Statistics.add_call('Instagram', 'get_locale')
|
|
278
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
279
|
+
ip.call_function('Profile:getLocale', @interpreter_storage, nil)
|
|
280
|
+
|
|
281
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
282
|
+
return nil || ip.get_parameter(1)
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def get_picture_url()
|
|
286
|
+
ServiceCode::Statistics.add_call('Instagram', 'get_picture_url')
|
|
287
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
288
|
+
ip.call_function('Profile:getPictureURL', @interpreter_storage, nil)
|
|
289
|
+
|
|
290
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
291
|
+
return nil || ip.get_parameter(1)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
def login()
|
|
295
|
+
ServiceCode::Statistics.add_call('Instagram', 'login')
|
|
296
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
297
|
+
ip.call_function('Authenticating:login', @interpreter_storage)
|
|
298
|
+
|
|
299
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
300
|
+
return nil
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
def logout()
|
|
304
|
+
ServiceCode::Statistics.add_call('Instagram', 'logout')
|
|
305
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
306
|
+
ip.call_function('Authenticating:logout', @interpreter_storage)
|
|
307
|
+
|
|
308
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
309
|
+
return nil
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def advanced_request(specification)
|
|
313
|
+
ServiceCode::Statistics.add_call('Instagram', 'advanced_request')
|
|
314
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
315
|
+
ip.call_function('AdvancedRequestSupporter:advancedRequest', @interpreter_storage, nil, specification)
|
|
316
|
+
|
|
317
|
+
check_for_error(ip.sandbox.thrown_error)
|
|
318
|
+
return nil || ip.get_parameter(1)
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def save_as_string
|
|
323
|
+
ip = ServiceCode::Interpreter.new(ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage))
|
|
324
|
+
return ip.save_as_string()
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def load_as_string(saved_state)
|
|
328
|
+
sandbox = ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage)
|
|
329
|
+
ip = ServiceCode::Interpreter.new(sandbox)
|
|
330
|
+
ip.load_as_string(saved_state)
|
|
331
|
+
@persistent_storage = sandbox.persistent_storage
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def resume_login(execution_state, callback)
|
|
335
|
+
sandbox = ServiceCode::Sandbox.new(SERVICE_CODE, @persistent_storage, @instance_dependency_storage)
|
|
336
|
+
sandbox.load_state_from_string(execution_state)
|
|
337
|
+
ip = ServiceCode::Interpreter.new(sandbox)
|
|
338
|
+
ip.resume_function('Authenticating:login', @interpreter_storage, callback)
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
end
|