diff options
-rw-r--r-- | app/controllers/api/v1/calls_controller.rb | 17 | ||||
-rw-r--r-- | app/views/switchboards/show.html.erb | 1 | ||||
-rw-r--r-- | public/js/app.js | 8 |
3 files changed, 24 insertions, 2 deletions
diff --git a/app/controllers/api/v1/calls_controller.rb b/app/controllers/api/v1/calls_controller.rb index e6fbed4..329bd94 100644 --- a/app/controllers/api/v1/calls_controller.rb +++ b/app/controllers/api/v1/calls_controller.rb @@ -14,6 +14,23 @@ module Api if params[:transfer_blind] @call.transfer_blind(params[:transfer_blind]) + else + if params[:transfer_attended] && @call.b_sip_account.phones.first.phone_model.manufacturer.name == 'SNOM Technology AG' + phone = @call.b_sip_account.phones.first + ip_address = phone.ip_address + http_user = phone.http_user + http_password = phone.http_password + + # Hold + open("http://#{ip_address}/command.htm?key=F_HOLD", :http_basic_authentication=>[http_user, http_password]) + + # Call the other party + (0..(params[:transfer_attended].length - 1)).each do |i| + digit = params[:transfer_attended][i] + open("http://#{ip_address}/command.htm?key=#{digit}", :http_basic_authentication=>[http_user, http_password]) + end + open("http://#{ip_address}/command.htm?key=ENTER", :http_basic_authentication=>[http_user, http_password]) + end end respond_with @call diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb index 1a8e5a0..f3304cf 100644 --- a/app/views/switchboards/show.html.erb +++ b/app/views/switchboards/show.html.erb @@ -50,6 +50,7 @@ <p> {{#each activeCall in activeCalls}} <button {{action transfer_blind activeCall.id phoneNumber.number}} class="btn btn-small">Transfer</button> + <button {{action transfer_attended activeCall.id phoneNumber.number}} class="btn btn-small">Attended Transfer</button> {{/each}} </p> {{/if}} diff --git a/public/js/app.js b/public/js/app.js index 6d8448a..efc0752 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -27,10 +27,14 @@ App.SwitchboardRoute = Ember.Route.extend({ // Controller App.SwitchboardController = Ember.ObjectController.extend({ transfer_blind: function(call_id, destination) { - console.log('test') request_url = '/api/v1/calls/' + call_id + '.json'; jQuery.get(request_url, { transfer_blind: destination }); - } + }, + + transfer_attended: function(call_id, destination) { + request_url = '/api/v1/calls/' + call_id + '.json'; + jQuery.get(request_url, { transfer_attended: destination }); + } }); // Models |