port_in_order.rb

 1# frozen_string_literal: true
 2
 3class PortInOrder
 4	def initialize(params)
 5		@params = params
 6		@params["SiteId"] = CONFIG[:bandwidth_site]
 7		@params["PeerId"] = CONFIG[:bandwidth_peer]
 8		@params["ProcessingStatus"] = "DRAFT"
 9		@params["Subscriber"]["SubscriberType"] ||= "RESIDENTIAL"
10	end
11
12	def loa_authorizing_person
13		"%s %s" % [
14			@params.dig("Subscriber", "FirstName"),
15			@params.dig("Subscriber", "LastName")
16		]
17	end
18
19	def to_h
20		@params.dup.tap do |h|
21			h["LoaAuthorizingPerson"] = loa_authorizing_person
22			h["BillingTelephoneNumber"].gsub!(/[^\d]/, "")
23			h["BillingTelephoneNumber"].gsub!(/\A1(\d{10})\Z/) { $1 }
24			h["ListOfPhoneNumbers"] = {
25				"PhoneNumber" => h["BillingTelephoneNumber"]
26			}
27		end
28	end
29end