soullab 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/soullab.rb +411 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f60d9381f604f5a9cbd18e29c3d26cc9d8f8fc90
|
4
|
+
data.tar.gz: 2571e9ce61440545b2b1cd21a6b6334f7ebe4375
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bbe22ac7e876c359a0b39eabec622b8936f99eefe8580e6b8c39a362e725ae8739c6ae689664a636b2db5f272965c9d18d63f8e5bb8ce03f27ad5020e1ff2280
|
7
|
+
data.tar.gz: 6e2c135e10008946ada5226875ba2138c867f4fa58bdf0ed8caa5e29a6c34fb245f5d015718f5915c7806f08f9670a1a5e62198e49e16bf7e619e5fecc3fe826
|
data/lib/soullab.rb
ADDED
@@ -0,0 +1,411 @@
|
|
1
|
+
require 'restclient'
|
2
|
+
require 'json'
|
3
|
+
require 'date'
|
4
|
+
require 'digest/sha1'
|
5
|
+
require 'openssl'
|
6
|
+
require 'base64'
|
7
|
+
|
8
|
+
class Soullab
|
9
|
+
|
10
|
+
$DEBUG = false
|
11
|
+
|
12
|
+
$base_url = "http://www.soullab.com.br/SoullabWebService/service/"
|
13
|
+
|
14
|
+
def initialize(company, keyPath, keyPass, language)
|
15
|
+
@company = company
|
16
|
+
@keyPath = keyPath
|
17
|
+
@keyPass = keyPass
|
18
|
+
@language = language
|
19
|
+
end
|
20
|
+
|
21
|
+
def integrarEscola(codigo, nomeEscola, cep, cidade, uf, bairro, rua, numero, complemento, telefone, celular, nomeGestor, emailGestor, login)
|
22
|
+
|
23
|
+
puts "Generating json..." if $DEBUG
|
24
|
+
|
25
|
+
escola = {
|
26
|
+
endereco: {
|
27
|
+
cep: cep,
|
28
|
+
cidade: cidade,
|
29
|
+
uf: uf,
|
30
|
+
bairro: bairro,
|
31
|
+
rua: rua,
|
32
|
+
numero: numero,
|
33
|
+
complemento: complemento
|
34
|
+
},
|
35
|
+
gestor: {
|
36
|
+
nome: nomeGestor,
|
37
|
+
email: emailGestor,
|
38
|
+
login: login
|
39
|
+
|
40
|
+
},
|
41
|
+
codigo: codigo,
|
42
|
+
nomeEscola: nomeEscola,
|
43
|
+
telefone: telefone,
|
44
|
+
celular: celular,
|
45
|
+
nomeContato: nomeGestor,
|
46
|
+
emailContato: emailGestor
|
47
|
+
}
|
48
|
+
|
49
|
+
timestamp = DateTime.now.strftime('%Q')
|
50
|
+
|
51
|
+
mensagem = {
|
52
|
+
jsonObject: escola.to_json,
|
53
|
+
timestamp: timestamp,
|
54
|
+
empresa: @company
|
55
|
+
}
|
56
|
+
|
57
|
+
puts "Json generated." if $DEBUG
|
58
|
+
puts "Generating SHA1 hash using base64..." if $DEBUG
|
59
|
+
|
60
|
+
raw_content = mensagem.to_json
|
61
|
+
|
62
|
+
puts raw_content
|
63
|
+
|
64
|
+
assinatura = Digest::SHA1.base64digest raw_content
|
65
|
+
|
66
|
+
puts "THE HASH IS: #{assinatura}" if $DEBUG
|
67
|
+
|
68
|
+
puts "SHA1 hash generated." if $DEBUG
|
69
|
+
puts "Signing hash..." if $DEBUG
|
70
|
+
|
71
|
+
keyfile = File.read @keyPath
|
72
|
+
private_key = OpenSSL::PKey::RSA.new(keyfile, @keyPass)
|
73
|
+
|
74
|
+
assinatura = private_key.private_encrypt assinatura
|
75
|
+
|
76
|
+
puts "Hash signed." if $DEBUG
|
77
|
+
|
78
|
+
mensagem[:assinatura] = Base64.encode64(assinatura)
|
79
|
+
|
80
|
+
mensagem[:idioma] = @language
|
81
|
+
|
82
|
+
puts "JSON: #{mensagem.to_json}" if $DEBUG
|
83
|
+
|
84
|
+
url = $base_url + "escola/cadastrarEscola"
|
85
|
+
|
86
|
+
response = RestClient.post(
|
87
|
+
url,
|
88
|
+
mensagem.to_json,
|
89
|
+
:content_type => :json,
|
90
|
+
:accept => :json
|
91
|
+
)
|
92
|
+
|
93
|
+
return JSON.parse(response.body)
|
94
|
+
end
|
95
|
+
|
96
|
+
def integrarProfessor(codigoEscola, login, nome, rua, numero, complemento, bairro, cidade, cep, uf, telefone, celular, email)
|
97
|
+
|
98
|
+
puts "Generating json..." if $DEBUG
|
99
|
+
|
100
|
+
professor = {
|
101
|
+
endereco: {
|
102
|
+
cep: cep,
|
103
|
+
cidade: cidade,
|
104
|
+
uf: uf,
|
105
|
+
bairro: bairro,
|
106
|
+
rua: rua,
|
107
|
+
numero: numero,
|
108
|
+
complemento: complemento
|
109
|
+
},
|
110
|
+
nome: nome,
|
111
|
+
email: email,
|
112
|
+
login: login,
|
113
|
+
codigoEscola: codigoEscola,
|
114
|
+
telefone: telefone,
|
115
|
+
celular: celular
|
116
|
+
}
|
117
|
+
|
118
|
+
timestamp = DateTime.now.strftime('%Q')
|
119
|
+
|
120
|
+
mensagem = {
|
121
|
+
jsonObject: professor.to_json,
|
122
|
+
timestamp: timestamp,
|
123
|
+
empresa: @company
|
124
|
+
}
|
125
|
+
|
126
|
+
puts "Json generated." if $DEBUG
|
127
|
+
puts "Generating SHA1 hash using base64..." if $DEBUG
|
128
|
+
|
129
|
+
raw_content = mensagem.to_json
|
130
|
+
|
131
|
+
puts raw_content
|
132
|
+
|
133
|
+
assinatura = Digest::SHA1.base64digest raw_content
|
134
|
+
|
135
|
+
puts "THE HASH IS: #{assinatura}" if $DEBUG
|
136
|
+
|
137
|
+
puts "SHA1 hash generated." if $DEBUG
|
138
|
+
puts "Signing hash..." if $DEBUG
|
139
|
+
|
140
|
+
keyfile = File.read @keyPath
|
141
|
+
private_key = OpenSSL::PKey::RSA.new(keyfile, @keyPass)
|
142
|
+
|
143
|
+
assinatura = private_key.private_encrypt assinatura
|
144
|
+
|
145
|
+
puts "Hash signed." if $DEBUG
|
146
|
+
|
147
|
+
mensagem[:assinatura] = Base64.encode64(assinatura)
|
148
|
+
|
149
|
+
mensagem[:idioma] = @language
|
150
|
+
|
151
|
+
puts "JSON: #{mensagem.to_json}" if $DEBUG
|
152
|
+
|
153
|
+
url = $base_url + "professor/cadastrarProfessor"
|
154
|
+
|
155
|
+
response = RestClient.post(
|
156
|
+
url,
|
157
|
+
mensagem.to_json,
|
158
|
+
:content_type => :json,
|
159
|
+
:accept => :json
|
160
|
+
)
|
161
|
+
|
162
|
+
return JSON.parse(response.body)
|
163
|
+
end
|
164
|
+
|
165
|
+
def integrarTurma(codigoEscola, codigo, anoTurma, periodoAno, professor, dataInicio, dataFim, avisos)
|
166
|
+
|
167
|
+
puts "Generating json..." if $DEBUG
|
168
|
+
|
169
|
+
turma = {
|
170
|
+
codigoEscola: codigoEscola,
|
171
|
+
codigo: codigo,
|
172
|
+
anoTurma: anoTurma,
|
173
|
+
periodoAno: periodoAno,
|
174
|
+
professor: professor,
|
175
|
+
dataInicio: dataInicio,
|
176
|
+
dataFim: dataFim,
|
177
|
+
avisos: avisos
|
178
|
+
}
|
179
|
+
|
180
|
+
timestamp = DateTime.now.strftime('%Q')
|
181
|
+
|
182
|
+
mensagem = {
|
183
|
+
jsonObject: turma.to_json,
|
184
|
+
timestamp: timestamp,
|
185
|
+
empresa: @company
|
186
|
+
}
|
187
|
+
|
188
|
+
puts "Json generated." if $DEBUG
|
189
|
+
puts "Generating SHA1 hash using base64..." if $DEBUG
|
190
|
+
|
191
|
+
raw_content = mensagem.to_json
|
192
|
+
|
193
|
+
puts raw_content
|
194
|
+
|
195
|
+
assinatura = Digest::SHA1.base64digest raw_content
|
196
|
+
|
197
|
+
puts "THE HASH IS: #{assinatura}" if $DEBUG
|
198
|
+
|
199
|
+
puts "SHA1 hash generated." if $DEBUG
|
200
|
+
puts "Signing hash..." if $DEBUG
|
201
|
+
|
202
|
+
keyfile = File.read @keyPath
|
203
|
+
private_key = OpenSSL::PKey::RSA.new(keyfile, @keyPass)
|
204
|
+
|
205
|
+
assinatura = private_key.private_encrypt assinatura
|
206
|
+
|
207
|
+
puts "Hash signed." if $DEBUG
|
208
|
+
|
209
|
+
mensagem[:assinatura] = Base64.encode64(assinatura)
|
210
|
+
|
211
|
+
mensagem[:idioma] = @language
|
212
|
+
|
213
|
+
puts "JSON: #{mensagem.to_json}" if $DEBUG
|
214
|
+
|
215
|
+
url = $base_url + "turma/cadastrarTurma"
|
216
|
+
|
217
|
+
response = RestClient.post(
|
218
|
+
url,
|
219
|
+
mensagem.to_json,
|
220
|
+
:content_type => :json,
|
221
|
+
:accept => :json
|
222
|
+
)
|
223
|
+
|
224
|
+
return JSON.parse(response.body)
|
225
|
+
|
226
|
+
end
|
227
|
+
|
228
|
+
def integrarAluno(codigoEscola, login, nome, rua, numero, complemento, bairro, cidade, cep, uf, telefone, celular, email)
|
229
|
+
|
230
|
+
puts "Generating json..." if $DEBUG
|
231
|
+
|
232
|
+
aluno = {
|
233
|
+
endereco: {
|
234
|
+
cep: cep,
|
235
|
+
cidade: cidade,
|
236
|
+
uf: uf,
|
237
|
+
bairro: bairro,
|
238
|
+
rua: rua,
|
239
|
+
numero: numero,
|
240
|
+
complemento: complemento
|
241
|
+
},
|
242
|
+
nome: nome,
|
243
|
+
email: email,
|
244
|
+
login: login,
|
245
|
+
codigoEscola: codigoEscola,
|
246
|
+
telefone: telefone,
|
247
|
+
celular: celular
|
248
|
+
}
|
249
|
+
|
250
|
+
timestamp = DateTime.now.strftime('%Q')
|
251
|
+
|
252
|
+
mensagem = {
|
253
|
+
jsonObject: aluno.to_json,
|
254
|
+
timestamp: timestamp,
|
255
|
+
empresa: @company
|
256
|
+
}
|
257
|
+
|
258
|
+
puts "Json generated." if $DEBUG
|
259
|
+
puts "Generating SHA1 hash using base64..." if $DEBUG
|
260
|
+
|
261
|
+
raw_content = mensagem.to_json
|
262
|
+
|
263
|
+
puts raw_content
|
264
|
+
|
265
|
+
assinatura = Digest::SHA1.base64digest raw_content
|
266
|
+
|
267
|
+
puts "THE HASH IS: #{assinatura}" if $DEBUG
|
268
|
+
|
269
|
+
puts "SHA1 hash generated." if $DEBUG
|
270
|
+
puts "Signing hash..." if $DEBUG
|
271
|
+
|
272
|
+
keyfile = File.read @keyPath
|
273
|
+
private_key = OpenSSL::PKey::RSA.new(keyfile, @keyPass)
|
274
|
+
|
275
|
+
assinatura = private_key.private_encrypt assinatura
|
276
|
+
|
277
|
+
puts "Hash signed." if $DEBUG
|
278
|
+
|
279
|
+
mensagem[:assinatura] = Base64.encode64(assinatura)
|
280
|
+
|
281
|
+
mensagem[:idioma] = @language
|
282
|
+
|
283
|
+
puts "JSON: #{mensagem.to_json}" if $DEBUG
|
284
|
+
|
285
|
+
url = $base_url + "aluno/cadastrarAluno"
|
286
|
+
|
287
|
+
response = RestClient.post(
|
288
|
+
url,
|
289
|
+
mensagem.to_json,
|
290
|
+
:content_type => :json,
|
291
|
+
:accept => :json
|
292
|
+
)
|
293
|
+
|
294
|
+
return JSON.parse(response.body)
|
295
|
+
end
|
296
|
+
|
297
|
+
def integrarHorarios(codigoEscola, codigoTurma, horarios)
|
298
|
+
|
299
|
+
puts "Generating json..." if $DEBUG
|
300
|
+
|
301
|
+
horarios = {
|
302
|
+
codigoEscola: codigoEscola,
|
303
|
+
codigoTurma: codigoTurma,
|
304
|
+
horarios: horarios
|
305
|
+
}
|
306
|
+
|
307
|
+
timestamp = DateTime.now.strftime('%Q')
|
308
|
+
|
309
|
+
mensagem = {
|
310
|
+
jsonObject: horarios.to_json,
|
311
|
+
timestamp: timestamp,
|
312
|
+
empresa: @company
|
313
|
+
}
|
314
|
+
|
315
|
+
puts "Json generated." if $DEBUG
|
316
|
+
puts "Generating SHA1 hash using base64..." if $DEBUG
|
317
|
+
|
318
|
+
raw_content = mensagem.to_json
|
319
|
+
|
320
|
+
puts raw_content
|
321
|
+
|
322
|
+
assinatura = Digest::SHA1.base64digest raw_content
|
323
|
+
|
324
|
+
puts "THE HASH IS: #{assinatura}" if $DEBUG
|
325
|
+
|
326
|
+
puts "SHA1 hash generated." if $DEBUG
|
327
|
+
puts "Signing hash..." if $DEBUG
|
328
|
+
|
329
|
+
keyfile = File.read @keyPath
|
330
|
+
private_key = OpenSSL::PKey::RSA.new(keyfile, @keyPass)
|
331
|
+
|
332
|
+
assinatura = private_key.private_encrypt assinatura
|
333
|
+
|
334
|
+
puts "Hash signed." if $DEBUG
|
335
|
+
|
336
|
+
mensagem[:assinatura] = Base64.encode64(assinatura)
|
337
|
+
|
338
|
+
mensagem[:idioma] = @language
|
339
|
+
|
340
|
+
puts "JSON: #{mensagem.to_json}" if $DEBUG
|
341
|
+
|
342
|
+
url = $base_url + "horario/cadastrarHorario"
|
343
|
+
|
344
|
+
response = RestClient.post(
|
345
|
+
url,
|
346
|
+
mensagem.to_json,
|
347
|
+
:content_type => :json,
|
348
|
+
:accept => :json
|
349
|
+
)
|
350
|
+
|
351
|
+
return JSON.parse(response.body)
|
352
|
+
end
|
353
|
+
|
354
|
+
def integrarEnturmamento(codigoEscola, codigoTurma, matriculas)
|
355
|
+
|
356
|
+
puts "Generating json..." if $DEBUG
|
357
|
+
|
358
|
+
enturmamento = {
|
359
|
+
codigoEscola: codigoEscola,
|
360
|
+
codigoTurma: codigoTurma,
|
361
|
+
matriculas: matriculas
|
362
|
+
}
|
363
|
+
|
364
|
+
timestamp = DateTime.now.strftime('%Q')
|
365
|
+
|
366
|
+
mensagem = {
|
367
|
+
jsonObject: enturmamento.to_json,
|
368
|
+
timestamp: timestamp,
|
369
|
+
empresa: @company
|
370
|
+
}
|
371
|
+
|
372
|
+
puts "Json generated." if $DEBUG
|
373
|
+
puts "Generating SHA1 hash using base64..." if $DEBUG
|
374
|
+
|
375
|
+
raw_content = mensagem.to_json
|
376
|
+
|
377
|
+
puts raw_content
|
378
|
+
|
379
|
+
assinatura = Digest::SHA1.base64digest raw_content
|
380
|
+
|
381
|
+
puts "THE HASH IS: #{assinatura}" if $DEBUG
|
382
|
+
|
383
|
+
puts "SHA1 hash generated." if $DEBUG
|
384
|
+
puts "Signing hash..." if $DEBUG
|
385
|
+
|
386
|
+
keyfile = File.read @keyPath
|
387
|
+
private_key = OpenSSL::PKey::RSA.new(keyfile, @keyPass)
|
388
|
+
|
389
|
+
assinatura = private_key.private_encrypt assinatura
|
390
|
+
|
391
|
+
puts "Hash signed." if $DEBUG
|
392
|
+
|
393
|
+
mensagem[:assinatura] = Base64.encode64(assinatura)
|
394
|
+
|
395
|
+
mensagem[:idioma] = @language
|
396
|
+
|
397
|
+
puts "JSON: #{mensagem.to_json}" if $DEBUG
|
398
|
+
|
399
|
+
url = $base_url + "enturmamento/cadastrarEnturmamento"
|
400
|
+
|
401
|
+
response = RestClient.post(
|
402
|
+
url,
|
403
|
+
mensagem.to_json,
|
404
|
+
:content_type => :json,
|
405
|
+
:accept => :json
|
406
|
+
)
|
407
|
+
|
408
|
+
return JSON.parse(response.body)
|
409
|
+
end
|
410
|
+
|
411
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soullab
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Augusto Russo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: restclient
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.11.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.11.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: base64
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.2.4
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.2.4
|
55
|
+
description: 'Want to integrate your system with soullab? No problem! This gem provides
|
56
|
+
all you need. Know more about soullab at: www.soullab.com.br'
|
57
|
+
email: augusto.russo@inovaz.com.br
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/soullab.rb
|
63
|
+
homepage: http://www.soullab.com.br
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.4.5.1
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Soullab integration gem
|
87
|
+
test_files: []
|