Fixes #3910 - Adjust placetel endpoints from EOL v1 to v2.
This commit is contained in:
parent
9886d713d0
commit
920d034412
2 changed files with 10 additions and 13 deletions
|
@ -88,12 +88,13 @@ class Cti::Driver::Placetel < Cti::Driver::Base
|
||||||
list = Cache.read('placetelGetVoipUsers')
|
list = Cache.read('placetelGetVoipUsers')
|
||||||
return list if list
|
return list if list
|
||||||
|
|
||||||
response = UserAgent.post(
|
response = UserAgent.get(
|
||||||
'https://api.placetel.de/api/getVoIPUsers.json',
|
'https://api.placetel.de/v2/sip_users',
|
||||||
{
|
{},
|
||||||
api_key: @config[:api_token],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: "Bearer #{@config[:api_token]}",
|
||||||
|
},
|
||||||
log: {
|
log: {
|
||||||
facility: 'placetel',
|
facility: 'placetel',
|
||||||
},
|
},
|
||||||
|
@ -130,13 +131,9 @@ class Cti::Driver::Placetel < Cti::Driver::Base
|
||||||
list = {}
|
list = {}
|
||||||
result.each do |entry|
|
result.each do |entry|
|
||||||
next if entry['name'].blank?
|
next if entry['name'].blank?
|
||||||
|
next if entry['sipuid'].blank?
|
||||||
|
|
||||||
if entry['uid'].present?
|
list[entry['sipuid']] = entry['name']
|
||||||
list[entry['uid']] = entry['name']
|
|
||||||
end
|
|
||||||
next if entry['uid2'].blank?
|
|
||||||
|
|
||||||
list[entry['uid2']] = entry['name']
|
|
||||||
end
|
end
|
||||||
Cache.write('placetelGetVoipUsers', list, { expires_in: 24.hours })
|
Cache.write('placetelGetVoipUsers', list, { expires_in: 24.hours })
|
||||||
list
|
list
|
||||||
|
|
|
@ -569,8 +569,8 @@ RSpec.describe 'Integration Placetel', type: :request do
|
||||||
config[:outbound][:default_caller_id] = ''
|
config[:outbound][:default_caller_id] = ''
|
||||||
Setting.set('placetel_config', config)
|
Setting.set('placetel_config', config)
|
||||||
|
|
||||||
stub_request(:post, 'https://api.placetel.de/api/getVoIPUsers.json')
|
stub_request(:get, 'https://api.placetel.de/v2/sip_users')
|
||||||
.to_return(status: 200, body: [{ 'callerid' => '03055571600', 'did' => 10, 'name' => 'Bob Smith', 'stype' => 3, 'uid' => '777008478072@example.com', 'uid2' => nil }, { 'callerid' => '03055571600', 'did' => 12, 'name' => 'Josef Müller', 'stype' => 3, 'uid' => '777042617425@example.com', 'uid2' => nil }].to_json)
|
.to_return(status: 200, body: [{ 'callerid' => '03055571600', 'did' => 10, 'name' => 'Bob Smith', 'type' => 'standard', 'sipuid' => '777008478072@example.com' }, { 'callerid' => '03055571600', 'did' => 12, 'name' => 'Josef Müller', 'type' => 'standard', 'sipuid' => '777042617425@example.com' }].to_json)
|
||||||
|
|
||||||
params = 'event=OutgoingCall&direction=out&to=099999222222&call_id=1234567890-2&from=777008478072@example.com'
|
params = 'event=OutgoingCall&direction=out&to=099999222222&call_id=1234567890-2&from=777008478072@example.com'
|
||||||
post "/api/v1/placetel/#{token}", params: params
|
post "/api/v1/placetel/#{token}", params: params
|
||||||
|
|
Loading…
Reference in a new issue