diff --git a/lib/bandwidth_iris_patch.rb b/lib/bandwidth_iris_patch.rb new file mode 100644 index 0000000000000000000000000000000000000000..5b7f83cb6f2e05ec4ba925847b280d725d1068d5 --- /dev/null +++ b/lib/bandwidth_iris_patch.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require "ruby-bandwidth-iris" + +module BandwidthIris + class APIError < StandardError + attr_reader :code + + def initialize(description:, code: nil) + super(description) + @code = code + end + end + + class Client + # Expose useful error messages from the API instead of hiding them + def check_response(response) + parsed_body = parse_xml(response.body || "") + return parsed_body unless response.status >= 400 + raise APIError.new(**parsed_body[:error]) if parsed_body.key?(:error) + + raise Errors::GenericError.new( + "", "Http code #{response.status}", response.status + ) + end + end +end diff --git a/lib/tel_selections.rb b/lib/tel_selections.rb index cb18d2a664aa00f498297d12b5810ee1fc6623a2..68b62d14798fee3a24aa69ca905b711f757feea4 100644 --- a/lib/tel_selections.rb +++ b/lib/tel_selections.rb @@ -190,8 +190,16 @@ class TelSelections Q.register(/\A([^,]+)\s*,\s*([A-Z]{2})\Z/, &method(:new)) CITY_MAP = { + "ajax" => "Ajax-Pickering", "kitchener" => "Kitchener-Waterloo", - "waterloo" => "Kitchener-Waterloo" + "new york" => "New York City", + "pickering" => "Ajax-Pickering", + "sault ste marie" => "sault sainte marie", + "sault ste. marie" => "sault sainte marie", + "south durham" => "Durham", + "township of langley" => "Langley", + "waterloo" => "Kitchener-Waterloo", + "west durham" => "Durham" }.freeze STATE_MAP = { diff --git a/sgx_jmp.rb b/sgx_jmp.rb index 12847799d07c30e86ff6ea8f52cd4cd6d495e092..91a94dc563bb364eacd513454b166897e73f309f 100644 --- a/sgx_jmp.rb +++ b/sgx_jmp.rb @@ -70,6 +70,7 @@ require_relative "lib/alt_top_up_form" require_relative "lib/add_bitcoin_address" require_relative "lib/backend_sgx" require_relative "lib/bwmsgsv2_repo" +require_relative "lib/bandwidth_iris_patch" require_relative "lib/bandwidth_tn_order" require_relative "lib/btc_sell_prices" require_relative "lib/buy_account_credit_form"