~singpolyma/sgx-jmp

6f019455a26cea485babd446f078142f4364803b — Stephen Paul Weber 2 years ago 27b2711
Include customer id as CustomerOrderId when ordering number

So we can tell who ordered a number in case of issues
4 files changed, 31 insertions(+), 4 deletions(-)

M lib/bandwidth_tn_order.rb
M lib/registration.rb
M test/test_bandwidth_tn_order.rb
M test/test_helper.rb
M lib/bandwidth_tn_order.rb => lib/bandwidth_tn_order.rb +2 -2
@@ 15,10 15,10 @@ class BandwidthTNOrder
		end
	end

	def self.create(tel, name: "sgx-jmp order #{tel}")
	def self.create(tel, name: "sgx-jmp order #{tel}", **kwargs)
		EMPromise.resolve(nil).then do
			Received.new(BandwidthIris::Order.create(
				name: name,
				name: name, **kwargs,
				site_id: CONFIG[:bandwidth_site],
				peer_id: CONFIG[:bandwidth_peer],
				existing_telephone_number_order_type: {

M lib/registration.rb => lib/registration.rb +4 -1
@@ 461,7 461,10 @@ class Registration
		end

		def write
			BandwidthTNOrder.create(@tel).then(&:poll).then(
			BandwidthTNOrder.create(
				@tel,
				customer_order_id: @customer.customer_id
			).then(&:poll).then(
				->(_) { customer_active_tel_purchased },
				->(_) { number_purchase_error }
			)

M test/test_bandwidth_tn_order.rb => test/test_bandwidth_tn_order.rb +22 -0
@@ 4,6 4,28 @@ require "test_helper"
require "bandwidth_tn_order"

class BandwidthTNOrderTest < Minitest::Test
	def test_create
		req = stub_request(
			:post,
			"https://dashboard.bandwidth.com/v1.0/accounts//orders"
		).with(
			body: {
				Name: "sgx-jmp order +15551234567",
				CustomerOrderId: "test",
				SiteId: "test_site",
				PeerId: "test_peer",
				ExistingTelephoneNumberOrderType: {
					TelephoneNumberList: {
						TelephoneNumber: "5551234567"
					}
				}
			}.to_xml(indent: 0, root: "Order")
		).to_return(status: 200)
		BandwidthTNOrder.create("+15551234567", customer_order_id: "test").sync
		assert_requested req
	end
	em :test_create

	def test_for_received
		order = BandwidthTNOrder.for(BandwidthIris::Order.new(
			order_status: "RECEIVED"

M test/test_helper.rb => test/test_helper.rb +3 -1
@@ 108,7 108,9 @@ CONFIG = {
	approved_domains: {
		"approved.example.com": nil,
		"refer.example.com": "refer_to"
	}
	},
	bandwidth_site: "test_site",
	bandwidth_peer: "test_peer"
}.freeze

def panic(e)