~singpolyma/sgx-jmp

ref: 2d687b1a39c8318d4efba9300f428f58ed4ad713 sgx-jmp/lib/port_in_order.rb -rw-r--r-- 726 bytes
2d687b1aStephen Paul Weber Patch bandwidth-iris to raise useful exceptions 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

class PortInOrder
	def initialize(params)
		@params = params
		@params["SiteId"] = CONFIG[:bandwidth_site]
		@params["PeerId"] = CONFIG[:bandwidth_peer]
		@params["ProcessingStatus"] = "DRAFT"
		@params["Subscriber"]["SubscriberType"] ||= "RESIDENTIAL"
	end

	def loa_authorizing_person
		"%s %s" % [
			@params.dig("Subscriber", "FirstName"),
			@params.dig("Subscriber", "LastName")
		]
	end

	def to_h
		@params.dup.tap do |h|
			h["LoaAuthorizingPerson"] = loa_authorizing_person
			h["BillingTelephoneNumber"].gsub!(/[^\d]/, "")
			h["BillingTelephoneNumber"].gsub!(/\A1(\d{10})\Z/) { $1 }
			h["ListOfPhoneNumbers"] = {
				"PhoneNumber" => h["BillingTelephoneNumber"]
			}
		end
	end
end