Skip to content

Commit

Permalink
task/update error model (#64)
Browse files Browse the repository at this point in the history
* task/update error model

* update test

* update examples

* fix config url

* add to error test
  • Loading branch information
ckoegel authored Apr 25, 2022
1 parent 889c056 commit bd4e7e7
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 139 deletions.
7 changes: 6 additions & 1 deletion examples/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@
:password => config['password'],
:account_id => config['account_id']
}
puts BandwidthIris::Account.get()

begin
puts BandwidthIris::Account.get()
rescue BandwidthIris::Errors::GenericError => e
puts e.message
end

6 changes: 5 additions & 1 deletion examples/available_npa_nxx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
}


puts BandwidthIris::AvailableNpaNxx.list({:state => 'NC', :quantity => 3})
begin
puts BandwidthIris::AvailableNpaNxx.list({:state => 'NC', :quantity => 3})
rescue BandwidthIris::Errors::GenericError => e
puts e.message
end

6 changes: 5 additions & 1 deletion examples/available_number.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
}


puts BandwidthIris::AvailableNumber.list({:state => "NC", :quantity => 3})
begin
puts BandwidthIris::AvailableNumber.list({:state => "NC", :quantity => 3})
rescue BandwidthIris::Errors::GenericError => e
puts e.message
end

6 changes: 5 additions & 1 deletion examples/available_number_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@
:account_id => config['account_id']
}

puts BandwidthIris::AvailableNumber.list({:state => "NC", :quantity => 3, :enable_t_n_detail => true})
begin
puts BandwidthIris::AvailableNumber.list({:state => "NC", :quantity => 3, :enable_t_n_detail => true})
rescue BandwidthIris::Errors::GenericError => e
puts e.message
end
6 changes: 5 additions & 1 deletion examples/city.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@
:account_id => config['account_id']
}

puts BandwidthIris::City.list({:available => true, :state => 'NC'})
begin
puts BandwidthIris::City.list({:available => true, :state => 'NC'})
rescue BandwidthIris::Errors::GenericError => e
puts e.message
end

2 changes: 1 addition & 1 deletion examples/config.yml.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
api_endpoint: "https:/dashboard.bandwidth.com"
api_endpoint: "https://dashboard.bandwidth.com"
account_id: ""
user_name: ""
password: ""
9 changes: 6 additions & 3 deletions examples/covered-rate-center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
:account_id => config['account_id']
}


BandwidthIris::CoveredRateCenter.list({:zip => '27609', :page=>1, :size=>100}).each do |c|
puts c.to_data
begin
BandwidthIris::CoveredRateCenter.list({:zip => '27609', :page=>1, :size=>100}).each do |c|
puts c.to_data
end
rescue BandwidthIris::Errors::GenericError => e
puts e.message
end

60 changes: 32 additions & 28 deletions examples/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,39 @@

number = '9195551212' #exisitng number for order

begin
site = BandwidthIris::Site.create({
:name => "Ruby Test Site",
:description => "A Site From Ruby SDK Examples",
:address => {
:house_number => "123",
:street_name => "Anywhere St",
:city => "Raleigh",
:state_code =>"NC",
:zip => "27609",
:address_type => "Service"
}
})

order = BandwidthIris::Order.create({
:name =>"A Test Order",
:site_id => site.id,
:existing_telephone_number_order_type => {
:telephone_number_list =>
{
:telephone_number => [number]
}

}
})

puts order.to_data

order = BandwidthIris::Order.get(order.id)
rescue BandwidthIris::Errors::GenericError => e
puts e.message
end

site = BandwidthIris::Site.create({
:name => "Ruby Test Site",
:description => "A Site From Ruby SDK Examples",
:address => {
:house_number => "123",
:street_name => "Anywhere St",
:city => "Raleigh",
:state_code =>"NC",
:zip => "27609",
:address_type => "Service"
}
})

order = BandwidthIris::Order.create({
:name =>"A Test Order",
:site_id => site.id,
:existing_telephone_number_order_type => {
:telephone_number_list =>
{
:telephone_number => [number]
}

}
})

puts order.to_data

order = BandwidthIris::Order.get(order.id)

puts order.to_data

Expand Down
90 changes: 47 additions & 43 deletions examples/port-in.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,62 @@

host = '1.1.2.3'

begin
site = BandwidthIris::Site.create({
:name => "Ruby Test Site",
:description => "A Site From Ruby SDK Examples",
:address => {
:house_number => "123",
:street_name => "Anywhere St",
:city => "Raleigh",
:state_code =>"NC",
:zip => "27609",
:address_type => "Service"
}
})

site = BandwidthIris::Site.create({
:name => "Ruby Test Site",
:description => "A Site From Ruby SDK Examples",
:address => {
:house_number => "123",
:street_name => "Anywhere St",
:city => "Raleigh",
:state_code =>"NC",
:zip => "27609",
:address_type => "Service"
}
})

data = {
:peer_name => "A New SIP Peer",
:is_default_peer => true,
:short_messaging_protocol => "SMPP",
:site_id => site[:id],
:voice_hosts =>
{
:host => {
:host_name => host
}
},
:sms_hosts =>
{
:host => {
:host_name => host
}
},
:termination_hosts =>
data = {
:peer_name => "A New SIP Peer",
:is_default_peer => true,
:short_messaging_protocol => "SMPP",
:site_id => site[:id],
:voice_hosts =>
{
:termination_host => {
:host_name => host,
:port => 5060,
:host => {
:host_name => host
}
},
:sms_hosts =>
{
:host => {
:host_name => host
}
},
:termination_hosts =>
{
:termination_host => {
:host_name => host,
:port => 5060,
}
}
}

}
}

sip_peer = BandwidthIris::SipPeer.create(site[:id], data)
sip_peer = BandwidthIris::SipPeer.create(site[:id], data)

res = BandwidthIris::LnpChecker.check(number_to_check)
res = BandwidthIris::LnpChecker.check(number_to_check)

if res[:portable_numbers] && res[:portable_numbers][:tn] == number_to_check
puts 'Your number is portable. Creating PortIn Order'
port_in = BandwidthIris::PortIn.create(create_port_in_order(number_to_check, site, sip_peer))
puts "Created order #{port_in[:id]}"
port_in.create_file(File.open('./loa.pdf', 'r'), 'application/pdf')
if res[:portable_numbers] && res[:portable_numbers][:tn] == number_to_check
puts 'Your number is portable. Creating PortIn Order'
port_in = BandwidthIris::PortIn.create(create_port_in_order(number_to_check, site, sip_peer))
puts "Created order #{port_in[:id]}"
port_in.create_file(File.open('./loa.pdf', 'r'), 'application/pdf')
end
rescue BandwidthIris::Errors::GenericError => e
puts e.message
end


def create_port_in_order(number, site, sip_peer)
{
:site_id => site[:id],
Expand Down
78 changes: 41 additions & 37 deletions examples/sip_peer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,51 @@

host = '10.20.30.41'

begin
site = BandwidthIris::Site.create({
:name => "Ruby Test Site",
:description => "A Site From Ruby SDK Examples",
:address => {
:house_number => "123",
:street_name => "Anywhere St",
:city => "Raleigh",
:state_code =>"NC",
:zip => "27609",
:address_type => "Service"
}
})

site = BandwidthIris::Site.create({
:name => "Ruby Test Site",
:description => "A Site From Ruby SDK Examples",
:address => {
:house_number => "123",
:street_name => "Anywhere St",
:city => "Raleigh",
:state_code =>"NC",
:zip => "27609",
:address_type => "Service"
}
})

data = {
:peer_name => "A New SIP Peer",
:is_default_peer => true,
:short_messaging_protocol => "SMPP",
:site_id => site[:id],
:voice_hosts =>
{
:host => {
:host_name => host
}
},
:sms_hosts =>
{
:host => {
:host_name => host
}
},
:termination_hosts =>
data = {
:peer_name => "A New SIP Peer",
:is_default_peer => true,
:short_messaging_protocol => "SMPP",
:site_id => site[:id],
:voice_hosts =>
{
:host => {
:host_name => host
}
},
:sms_hosts =>
{
:termination_host => {
:host_name => host,
:port => 5060,
:host => {
:host_name => host
}
},
:termination_hosts =>
{
:termination_host => {
:host_name => host,
:port => 5060,
}
}
}

}
sip_peer = BandwidthIris::SipPeer.create(site[:id], data)
}
sip_peer = BandwidthIris::SipPeer.create(site[:id], data)
rescue BandwidthIris::Errors::GenericError => e
puts e.message
end



sip_peer.delete(site[:id])
29 changes: 16 additions & 13 deletions examples/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@
:account_id => config['account_id']
}


site = BandwidthIris::Site.create({
:name => "Ruby Test Sitei1",
:description => "A Site From Ruby SDK Examples",
:address => {
:house_number => "123",
:street_name => "Anywhere St",
:city => "Raleigh",
:state_code =>"NC",
:zip => "27609",
:address_type => "Service"
}
})
begin
site = BandwidthIris::Site.create({
:name => "Ruby Test Sitei1",
:description => "A Site From Ruby SDK Examples",
:address => {
:house_number => "123",
:street_name => "Anywhere St",
:city => "Raleigh",
:state_code =>"NC",
:zip => "27609",
:address_type => "Service"
}
})
rescue BandwidthIris::Errors::GenericError => e
puts e.message
end

site.delete()
11 changes: 7 additions & 4 deletions examples/tn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
:account_id => config['account_id']
}

list = BandwidthIris::Tn.list({:npa => '818', :page => 1, :size => 100}).each do |n|
puts n.to_data
begin
list = BandwidthIris::Tn.list({:npa => '818', :page => 1, :size => 100}).each do |n|
puts n.to_data
end
puts BandwidthIris::Tn.get(list[0][:full_number]).to_data
rescue BandwidthIris::Errors::GenericError => e
puts e.message
end

puts BandwidthIris::Tn.get(list[0][:full_number]).to_data
Loading

0 comments on commit bd4e7e7

Please sign in to comment.