From 214d81f32892ba614e9f4da3c5d706208a2bfcd4 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Fri, 13 May 2022 10:17:22 -0400 Subject: [PATCH] Allow moving tns between accounts (#67) * Allow moving tns between accounts * add test for `move` method * commit the helper xml * change sippeerid Co-authored-by: Cameron Koegel --- lib/bandwidth-iris/tn.rb | 8 ++++++++ spec/bandwidth-iris/tn_spec.rb | 13 +++++++++++++ spec/xml.yml | 1 + 3 files changed, 22 insertions(+) diff --git a/lib/bandwidth-iris/tn.rb b/lib/bandwidth-iris/tn.rb index 55087da..77f7c04 100644 --- a/lib/bandwidth-iris/tn.rb +++ b/lib/bandwidth-iris/tn.rb @@ -37,5 +37,13 @@ def get_rate_center() def get_details() @client.make_request(:get, "#{TN_PATH}/#{CGI.escape(telephone_number)}/tndetails")[0][:telephone_number_details] end + + def move(params) + @client.make_request( + :post, + @client.concat_account_path("moveTns"), + MoveTnsOrder: params.merge(TelephoneNumbers: { TelephoneNumber: telephone_number }) + ) + end end end diff --git a/spec/bandwidth-iris/tn_spec.rb b/spec/bandwidth-iris/tn_spec.rb index ba7de04..3d13e69 100644 --- a/spec/bandwidth-iris/tn_spec.rb +++ b/spec/bandwidth-iris/tn_spec.rb @@ -27,6 +27,19 @@ end end + describe '#move' do + it 'should move a number' do + client.stubs.get('/v1.0/tns/1234') {|env| [200, {}, Helper.xml['tn']]} + tn = Tn.get(client, '1234') + client.stubs.post('/v1.0/accounts/accountId/moveTns') {|env| [201, {}, Helper.xml['tn_move']]} + order = tn.move({'SiteId': 12345, 'SipPeerId': 123450})[0][:move_tns_order] + expect(order[:created_by_user]).to eql('userapi') + expect(order[:order_id]).to eql('55689569-86a9-fe40-ab48-f12f6c11e108') + expect(order[:sip_peer_id]).to eql(123450) + expect(order[:site_id]).to eql(12345) + end + end + describe '#get_sites' do it 'should return sites' do client.stubs.get('/v1.0/tns/1234/sites') {|env| [200, {}, Helper.xml['tn_sites']]} diff --git a/spec/xml.yml b/spec/xml.yml index f2392bf..09d16a0 100644 --- a/spec/xml.yml +++ b/spec/xml.yml @@ -13,6 +13,7 @@ rate_centers1: "1ACMEACME" tn: "1234Inservice2014-05-09T21:12:03.000Z2014-05-09T21:12:03.835Z5f3a4dab-aac7-4b0a-8ee4-1b6a67ae04beNEW_NUMBER_ORDER10919500149" tns: "5CARY426NC9192381138049Bandwidth CLECCARYInservice99000082013-12-05T05:58:27.000ZCARY4269192381139049Bandwidth CLECCARYInservice99000002013-12-05T05:58:27.000Z" + tn_move: "2022-05-12T15:30:54.236Z5551234userapi55689569-86a9-fe40-ab48-f12f6c11e1082022-05-12T15:30:54.271Z123451234RECEIVED123450" tn_sites: "1435Sales Training" tn_sip_peers: "4064Sales" tn_rate_center: "CODENVER"