~singpolyma/sgx-jmp

ref: da30c371e56b8bb577897f1151b59c24e209127f sgx-jmp/lib/port_in_order.rb -rw-r--r-- 726 bytes
da30c371Stephen Paul Weber Allow finishing admin command 1 year, 7 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