Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow moving tns between accounts #67

Merged
merged 4 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/bandwidth-iris/tn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions spec/bandwidth-iris/tn_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']]}
Expand Down
1 change: 1 addition & 0 deletions spec/xml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
rate_centers1: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><RateCenterResponse><ResultCount>1</ResultCount><RateCenters><RateCenter><Abbreviation>ACME</Abbreviation><Name>ACME</Name></RateCenter></RateCenters></RateCenterResponse>"
tn: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><TelephoneNumberResponse><TelephoneNumber>1234</TelephoneNumber><Status>Inservice</Status><LastModifiedDate>2014-05-09T21:12:03.000Z</LastModifiedDate><OrderCreateDate>2014-05-09T21:12:03.835Z</OrderCreateDate><OrderId>5f3a4dab-aac7-4b0a-8ee4-1b6a67ae04be</OrderId><OrderType>NEW_NUMBER_ORDER</OrderType><SiteId>1091</SiteId><AccountId>9500149</AccountId></TelephoneNumberResponse>"
tns: "<?xml version=\"1.0\"?><TelephoneNumbersResponse><TelephoneNumberCount>5</TelephoneNumberCount><Links><first></first><next></next></Links><TelephoneNumbers><TelephoneNumber><City>CARY</City><Lata>426</Lata><State>NC</State><FullNumber>9192381138</FullNumber><Tier>0</Tier><VendorId>49</VendorId><VendorName>Bandwidth CLEC</VendorName><RateCenter>CARY</RateCenter><Status>Inservice</Status><AccountId>9900008</AccountId><LastModified>2013-12-05T05:58:27.000Z</LastModified></TelephoneNumber><TelephoneNumber><City>CARY</City><Lata>426</Lata><FullNumber>9192381139</FullNumber><Tier>0</Tier><VendorId>49</VendorId><VendorName>Bandwidth CLEC</VendorName><RateCenter>CARY</RateCenter><Status>Inservice</Status><AccountId>9900000</AccountId><LastModified>2013-12-05T05:58:27.000Z</LastModified></TelephoneNumber></TelephoneNumbers></TelephoneNumbersResponse>"
tn_move: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><MoveTnsOrderResponse><MoveTnsOrder><OrderCreateDate>2022-05-12T15:30:54.236Z</OrderCreateDate><AccountId>5551234</AccountId><CreatedByUser>userapi</CreatedByUser><OrderId>55689569-86a9-fe40-ab48-f12f6c11e108</OrderId><LastModifiedDate>2022-05-12T15:30:54.271Z</LastModifiedDate><SiteId>12345</SiteId><TelephoneNumbers><TelephoneNumber>1234</TelephoneNumber></TelephoneNumbers><ProcessingStatus>RECEIVED</ProcessingStatus><SipPeerId>123450</SipPeerId><Errors/><Warnings/></MoveTnsOrder></MoveTnsOrderResponse>"
tn_sites: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Site><Id>1435</Id><Name>Sales Training</Name></Site>"
tn_sip_peers: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><SipPeer><Id>4064</Id><Name>Sales</Name></SipPeer>"
tn_rate_center: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><TelephoneNumberResponse><TelephoneNumberDetails><State>CO</State><RateCenter>DENVER</RateCenter></TelephoneNumberDetails></TelephoneNumberResponse>"
Expand Down