libriciel 0.1.3 → 0.1.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 +4 -4
- data/lib/libriciel.rb +106 -0
- data/lib/libriciel/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d8579e1407573197fe75fbbbf76b522752e2fc0cca1614c62225b8fed00ffeb
|
4
|
+
data.tar.gz: 2bdfd897113a6028a07cab9881ab9ba79e770b2d3c8e5c6e6ab54fdfc62e34f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 887ba857081a67fdb3d9dd3d5e6bf9d9703f0951ec34029af5a36f31ae9f7c3b5c4e6cbe466095984320a13333296de9105ef8d70bc85e716f2f32557355a5ee
|
7
|
+
data.tar.gz: 414fbfaf22f2e41b30d502a8e4d70b8a2d6df503387ae432a2a2a4d3917d1a4d81b8b796397afac0442d019fa2be232e5cb453ff0c71e97650ce69f8400511b4
|
data/lib/libriciel.rb
CHANGED
@@ -250,6 +250,11 @@ module Libriciel
|
|
250
250
|
STDERR.puts("Line is not associated with Device")
|
251
251
|
exit(36)
|
252
252
|
end
|
253
|
+
sip_id_from_line = Libriciel::ApiXivo.get_sip_id_from_line(line_id, token)
|
254
|
+
|
255
|
+
options = Libriciel::ApiXivo.get_sip_options(sip_id_from_line, token)
|
256
|
+
|
257
|
+
sip_add_options = Libriciel::ApiXivo.add_webrtc_of_sip(sip_id_from_line, token, options)
|
253
258
|
|
254
259
|
end
|
255
260
|
|
@@ -272,6 +277,11 @@ module Libriciel
|
|
272
277
|
STDERR.puts("Line is already associated to a Device")
|
273
278
|
exit(36)
|
274
279
|
end
|
280
|
+
sip_id_from_line = Libriciel::ApiXivo.get_sip_id_from_line(line_id, token)
|
281
|
+
|
282
|
+
options = Libriciel::ApiXivo.get_sip_options(sip_id_from_line, token)
|
283
|
+
|
284
|
+
sip_del_options = Libriciel::ApiXivo.dell_webrtc_of_sip(sip_id_from_line, token, options)
|
275
285
|
|
276
286
|
end
|
277
287
|
|
@@ -327,6 +337,102 @@ module Libriciel
|
|
327
337
|
request["cache-control"] = 'no-cache'
|
328
338
|
request.body = csv_entry
|
329
339
|
|
340
|
+
response = http.request(request)
|
341
|
+
end
|
342
|
+
|
343
|
+
|
344
|
+
## Recherche du sip_id en fonction du numéro en entrée
|
345
|
+
def self.get_sip_id_from_line(line_id, token)
|
346
|
+
url = URI("https://xivo.libriciel.fr:9486/1.1/lines/#{line_id}/endpoints/sip")
|
347
|
+
|
348
|
+
http = Net::HTTP.new(url.host, url.port)
|
349
|
+
http.use_ssl = true
|
350
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
351
|
+
|
352
|
+
request = Net::HTTP::Get.new(url)
|
353
|
+
request["x-auth-token"] = "#{token}"
|
354
|
+
request["cache-control"] = 'no-cache'
|
355
|
+
|
356
|
+
response = http.request(request)
|
357
|
+
json = JSON.parse(response.read_body)
|
358
|
+
|
359
|
+
return json["endpoint_id"]
|
360
|
+
end
|
361
|
+
|
362
|
+
## Recherche des options du numéro SIP (à faire : traitement pour ajout et enlevement webrtc)
|
363
|
+
def self.get_sip_options(sip_id, token)
|
364
|
+
options_line = "[\n "
|
365
|
+
url = URI("https://xivo.libriciel.fr:9486/1.1/endpoints/sip/#{sip_id}")
|
366
|
+
|
367
|
+
http = Net::HTTP.new(url.host, url.port)
|
368
|
+
http.use_ssl = true
|
369
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
370
|
+
|
371
|
+
request = Net::HTTP::Get.new(url)
|
372
|
+
request["x-auth-token"] = "#{token}"
|
373
|
+
request["cache-control"] = 'no-cache'
|
374
|
+
|
375
|
+
response = http.request(request)
|
376
|
+
json = JSON.parse(response.read_body)
|
377
|
+
json["options"].each do |options|
|
378
|
+
if options[0] == "callerid"
|
379
|
+
options[1] = options[1].gsub(/\"/, "\\\"")
|
380
|
+
|
381
|
+
options_line << "[\n \"#{options[0]}\",\n \"#{options[1]}\"\n ],\n "
|
382
|
+
else
|
383
|
+
options_line << "[\n \"#{options[0]}\",\n \"#{options[1]}\"\n ],\n "
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
return options_line.gsub(/,\n $/, "\n]\n")
|
388
|
+
end
|
389
|
+
|
390
|
+
def self.dell_webrtc_of_sip(sip_id, token)
|
391
|
+
options = Libriciel::ApiXivo.get_sip_options(sip_id, token)
|
392
|
+
if options.include?("webrtc")
|
393
|
+
options_less_webrtc = "{\n \"options\": #{options.gsub(/\,\n \[\n \"webrtc\"\,\n \"yes\"\n \]/, '')}}"
|
394
|
+
|
395
|
+
else
|
396
|
+
end
|
397
|
+
|
398
|
+
url = URI("https://xivo.libriciel.fr:9486/1.1/endpoints/sip/#{sip_id}")
|
399
|
+
|
400
|
+
http = Net::HTTP.new(url.host, url.port)
|
401
|
+
http.use_ssl = true
|
402
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
403
|
+
|
404
|
+
request = Net::HTTP::Put.new(url)
|
405
|
+
request["x-auth-token"] = "#{token}"
|
406
|
+
request["content-type"] = 'application/json'
|
407
|
+
request["cache-control"] = 'no-cache'
|
408
|
+
request.body = "#{options_less_webrtc}"
|
409
|
+
|
410
|
+
response = http.request(request)
|
411
|
+
|
412
|
+
end
|
413
|
+
|
414
|
+
def self.add_webrtc_of_sip(sip_id, token)
|
415
|
+
options = Libriciel::ApiXivo.get_sip_options(sip_id, token)
|
416
|
+
if !options.include?("webrtc")
|
417
|
+
options_plus_webrtc = "{\n \"options\": #{options.gsub(/\]\n\]$/, "],\n \[\n \"webrtc\",\n \"yes\"\n ]\n]")}}"
|
418
|
+
|
419
|
+
else
|
420
|
+
STDERR.puts("webrtc already configured")
|
421
|
+
exit 1
|
422
|
+
end
|
423
|
+
|
424
|
+
url = URI("https://xivo.libriciel.fr:9486/1.1/endpoints/sip/#{sip_id}")
|
425
|
+
|
426
|
+
http = Net::HTTP.new(url.host, url.port)
|
427
|
+
http.use_ssl = true
|
428
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
429
|
+
|
430
|
+
request = Net::HTTP::Put.new(url)
|
431
|
+
request["x-auth-token"] = "#{token}"
|
432
|
+
request["content-type"] = 'application/json'
|
433
|
+
request["cache-control"] = 'no-cache'
|
434
|
+
request.body = "#{options_plus_webrtc}"
|
435
|
+
|
330
436
|
response = http.request(request)
|
331
437
|
|
332
438
|
end
|
data/lib/libriciel/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libriciel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Axel CHEVRIER
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|