Class: Registrar::Provider::Enom::Contact

Inherits:
Object
  • Object
show all
Defined in:
lib/registrar/provider/enom/contact.rb

Overview

Contact object that wraps a generic contact and can be used to produce and parse wire-level representations of Enom contacts.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contact) ⇒ Contact

Returns a new instance of Contact.

Raises:

  • (ArgumentError)


10
11
12
13
# File 'lib/registrar/provider/enom/contact.rb', line 10

def initialize(contact)
  raise ArgumentError, "Contact is required" unless contact
  @contact = contact
end

Instance Attribute Details

#contactObject (readonly)

Returns the value of attribute contact.



8
9
10
# File 'lib/registrar/provider/enom/contact.rb', line 8

def contact
  @contact
end

Class Method Details

.from_response(type, attributes) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/registrar/provider/enom/contact.rb', line 45

def self.from_response(type, attributes)
  contact = Registrar::Contact.new
  contact.identifier = attributes["#{type}PartyID"]
  contact.address_1 = attributes["#{type}Address1"]
  contact.address_2 = attributes["#{type}Address2"]
  contact.city = attributes["#{type}City"]
  contact.country = attributes["#{type}Country"]
  contact.email = attributes["#{type}EmailAddress"]
  contact.fax = attributes["#{type}Fax"]
  contact.first_name = attributes["#{type}FirstName"]
  contact.last_name = attributes["#{type}LastName"]
  contact.job_title = attributes["#{type}JobTitle"]
  contact.organization_name = attributes["#{type}OrganizationName"]
  contact.phone = attributes["#{type}Phone"]
  contact.phone_ext = attributes["#{type}PhoneExt"]
  contact.postal_code = attributes["#{type}PostalCode"]
  contact.state_province = attributes["#{type}StateProvince"]
  contact.state_province_choice = attributes["#{type}StateProvinceChoice"]
  self.new(contact)
end

Instance Method Details

#identifierObject



15
16
17
# File 'lib/registrar/provider/enom/contact.rb', line 15

def identifier
  contact.identifier
end

#identifier=(identifier) ⇒ Object



19
20
21
# File 'lib/registrar/provider/enom/contact.rb', line 19

def identifier=(identifier)
  contact.identifier = identifier
end

#to_query(type) ⇒ Object

Returns a Hash that can be merged into a query. Type should be one of the following: Registrant, AuxBilling, Tech, Admin



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/registrar/provider/enom/contact.rb', line 25

def to_query(type)
  {
    "#{type}Address1" => contact.address_1,
    "#{type}Address2" => contact.address_2,
    "#{type}City" => contact.city,
    "#{type}Country" => contact.country,
    "#{type}EmailAddress" => contact.email,
    "#{type}Fax" => contact.fax,
    "#{type}FirstName" => contact.first_name,
    "#{type}LastName" => contact.last_name,
    "#{type}JobTitle" => contact.job_title,
    "#{type}OrganizationName" => contact.organization_name,
    "#{type}Phone" => contact.phone,
    "#{type}PhoneExt" => contact.phone_ext,
    "#{type}PostalCode" => contact.postal_code,
    "#{type}StateProvince" => contact.state_province,
    "#{type}StateProvinceChoice" => contact.state_province_choice
  }
end