Class: EnomAPI::Registrant
- Inherits:
-
Object
- Object
- EnomAPI::Registrant
- Defined in:
- lib/enom-api/registrant.rb
Overview
Represents a registrant or other type of Contact in the eNom API
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#email ⇒ Object
Returns the value of attribute email.
-
#fax ⇒ Object
Returns the value of attribute fax.
-
#firstname ⇒ Object
Returns the value of attribute firstname.
-
#id ⇒ Object
Returns the value of attribute id.
-
#job_title ⇒ Object
Returns the value of attribute job_title.
-
#lastname ⇒ Object
Returns the value of attribute lastname.
-
#organisation ⇒ Object
Returns the value of attribute organisation.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#phone_extension ⇒ Object
Returns the value of attribute phone_extension.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#state ⇒ Object
Returns the value of attribute state.
Class Method Summary collapse
-
.from_xml(xmldoc) ⇒ Registrant
Registrant composed from the information in the xmldoc.
Instance Method Summary collapse
-
#initialize(first, last) {|registrant| ... } ⇒ Registrant
constructor
A new instance of Registrant.
-
#to_post_data(prefix = nil) ⇒ Hash
Converts the object into a form suitable for POSTing to the eNom API.
Constructor Details
#initialize(first, last) {|registrant| ... } ⇒ Registrant
Returns a new instance of Registrant.
47 48 49 50 51 52 |
# File 'lib/enom-api/registrant.rb', line 47 def initialize(first, last, &blk) raise ArgumentError, "first and last may not be nil" unless first && last @firstname, @lastname = first, last yield self if blk end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def address @address end |
#city ⇒ Object
Returns the value of attribute city.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def country @country end |
#email ⇒ Object
Returns the value of attribute email.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def email @email end |
#fax ⇒ Object
Returns the value of attribute fax.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def fax @fax end |
#firstname ⇒ Object
Returns the value of attribute firstname.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def firstname @firstname end |
#id ⇒ Object
Returns the value of attribute id.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def id @id end |
#job_title ⇒ Object
Returns the value of attribute job_title.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def job_title @job_title end |
#lastname ⇒ Object
Returns the value of attribute lastname.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def lastname @lastname end |
#organisation ⇒ Object
Returns the value of attribute organisation.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def organisation @organisation end |
#phone ⇒ Object
Returns the value of attribute phone.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def phone @phone end |
#phone_extension ⇒ Object
Returns the value of attribute phone_extension.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def phone_extension @phone_extension end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def postal_code @postal_code end |
#state ⇒ Object
Returns the value of attribute state.
40 41 42 |
# File 'lib/enom-api/registrant.rb', line 40 def state @state end |
Class Method Details
.from_xml(xmldoc) ⇒ Registrant
Returns Registrant composed from the information in the xmldoc.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/enom-api/registrant.rb', line 8 def self.from_xml(xmldoc) return if xmldoc.nil? @xml = xml = xmldoc.kind_of?(Demolisher::Node) ? xmldoc : Demolisher.demolish(xmldoc.to_s) r = new("", "") mapping = if xml.FName from_xml_mapping_one elsif xml.RegistrantFirstName from_xml_mapping_two('Registrant') elsif xml.AuxBillingFirstName from_xml_mapping_two('AuxBilling') elsif xml.TechFirstName from_xml_mapping_two('Tech') elsif xml.AdminFirstName from_xml_mapping_two('Admin') elsif xml.BillingFirstName from_xml_mapping_two('Billing') end mapping.each do |meth, el| case el when Array r.send(:"#{meth}=", el.map { |n| xml.send(n).to_s }.delete_if { |n| n.nil? || n == "" }.join("\n")) else r.send(:"#{meth}=", xml.send(el).to_s) end end r end |
Instance Method Details
#to_post_data(prefix = nil) ⇒ Hash
Converts the object into a form suitable for POSTing to the eNom API
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/enom-api/registrant.rb', line 58 def to_post_data(prefix=nil) data = { "#{prefix}FirstName" => firstname, "#{prefix}LastName" => lastname, "#{prefix}City" => city, "#{prefix}StateProvince" => state, "#{prefix}PostalCode" => postal_code, "#{prefix}Country" => country, "#{prefix}EmailAddress" => email, "#{prefix}Phone" => phone, "#{prefix}Fax" => fax } data["#{prefix}Address1"], data["#{prefix}Address2"] = address && address.split("\n", 2) unless organisation.nil? || organisation == '' data["#{prefix}OrganizationName"] = organisation data["#{prefix}JobTitle"] = (job_title || "Domains Manager") end data.reject { |_,v| v.nil? || v == '' } end |