Class: InternetBS::DomainContact
- Defined in:
- lib/internetbs/domain_contact.rb
Instance Method Summary collapse
-
#initialize(attributes = nil) ⇒ DomainContact
constructor
A new instance of DomainContact.
- #params ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(attributes = nil) ⇒ DomainContact
Returns a new instance of DomainContact.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/internetbs/domain_contact.rb', line 22 def initialize(attributes = nil) super(attributes) # Add any additional attributes case @domain_extension when 'asia' @additional_attributes = DotAsiaAttributes.new when 'de' @additional_attributes = DotDEAttributes.new when 'eu' @additional_attributes = DotEUAttributes.new when 'fr', 're', 'pm', 'tf', 'wf', 'yt' @additional_attributes = DotFRAttributes.new when 'it' @additional_attributes = DotITAttributes.new when 'nl' @additional_attributes = DotDLAttributes.new when 'uk' @additional_attributes = DotUKAttributes.new when 'us' @additional_attributes = DotUSAttributes.new end # Set contact_type and domain_extension for additional attributes @additional_attributes.contact_type = @contact_type @additional_attributes.domain_extension = @domain_extension end |
Instance Method Details
#params ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/internetbs/domain_contact.rb', line 50 def params contact = { "#{@contact_type.to_s}_firstname" => @first_name, "#{@contact_type.to_s}_lastname" => @last_name, "#{@contact_type.to_s}_email" => @email, "#{@contact_type.to_s}_phone_number" => @phone_number, "#{@contact_type.to_s}_city" => @city, "#{@contact_type.to_s}_street" => @street, "#{@contact_type.to_s}_postal_code" => @postal_code, "#{@contact_type.to_s}_country_code" => @country_code } if @organization || @domain_extension == 'uk' contact.merge!({"#{@contact_type.to_s}_organization" => @organization}) end if @fax && @domain_extension == 'uk' contact.merge!({"#{@contact_type.to_s}_fax" => @fax}) end if %w[com net tv].include?(@domain_extension) contact.merge!({"#{@contact_type.to_s}_obfuscateemail" => @obfuscate_email ? 1 : 0}) end if @street_2 contact.merge!({"#{@contact_type.to_s}_street2" => @street_2}) end if @street_3 contact.merge!({"#{@contact_type.to_s}_street3" => @street_3}) end case @contact_type when :registrant contact.merge!(@additional_attributes.registrant_params) when :admin contact.merge!(@additional_attributes.admin_params) when :billing contact.merge!(@additional_attributes.billing_params) when :tech contact.merge!(@additional_attributes.tech_params) when :zone # .de only contact.merge!(@additional_attributes.zone_params) if @domain_extension == 'de' end contact.merge!(@additional_attributes.mandatory_params) contact.merge!(@additional_attributes.optional_params) return contact end |
#valid? ⇒ Boolean
101 102 103 104 105 106 107 |
# File 'lib/internetbs/domain_contact.rb', line 101 def valid? ensure_attribute_has_value :first_name, :last_name, :email, :phone_number, :city, :street, :postal_code, :country_code unless COUNTRY_CODES.has_key?(@country_code) @errors << "country_code must be one in COUNTRY_CODES" end end |