# 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