Class: SAML2::Contact

Inherits:
Base
  • Object
show all
Defined in:
lib/saml2/contact.rb

Defined Under Namespace

Modules: Type

Instance Attribute Summary collapse

Attributes inherited from Base

#xml

Instance Method Summary collapse

Methods inherited from Base

#decrypt, from_xml, #inspect, load_object_array, load_string_array, lookup_qname, #to_s, #to_xml

Constructor Details

#initialize(type = Type::OTHER) ⇒ Contact

Returns a new instance of Contact.

Parameters:

  • type (String) (defaults to: Type::OTHER)


24
25
26
27
28
29
# File 'lib/saml2/contact.rb', line 24

def initialize(type = Type::OTHER)
  super()
  @type = type
  @email_addresses = []
  @telephone_numbers = []
end

Instance Attribute Details

#companyString?

Returns:

  • (String, nil)


19
20
21
# File 'lib/saml2/contact.rb', line 19

def company
  @company
end

#email_addressesArray<String>

Returns:

  • (Array<String>)


21
22
23
# File 'lib/saml2/contact.rb', line 21

def email_addresses
  @email_addresses
end

#given_nameString?

Returns:

  • (String, nil)


19
20
21
# File 'lib/saml2/contact.rb', line 19

def given_name
  @given_name
end

#surnameString?

Returns:

  • (String, nil)


19
20
21
# File 'lib/saml2/contact.rb', line 19

def surname
  @surname
end

#telephone_numbersArray<String>

Returns:

  • (Array<String>)


21
22
23
# File 'lib/saml2/contact.rb', line 21

def telephone_numbers
  @telephone_numbers
end

#typeString

Returns:

  • (String)

See Also:



17
18
19
# File 'lib/saml2/contact.rb', line 17

def type
  @type
end

Instance Method Details

#build(builder) ⇒ void

This method returns an undefined value.

Serialize this object to XML, as part of a larger document

Parameters:

  • builder (Nokogiri::XML::Builder)

    The builder helper object to serialize to.



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/saml2/contact.rb', line 46

def build(builder)
  builder["md"].ContactPerson("contactType" => type) do |contact_person|
    contact_person["md"].Company(company) if company
    contact_person["md"].GivenName(given_name) if given_name
    contact_person["md"].SurName(surname) if surname
    email_addresses.each do |email|
      contact_person["md"].EmailAddress(email)
    end
    telephone_numbers.each do |tel|
      contact_person["md"].TelephoneNumber(tel)
    end
  end
end

#from_xml(node) ⇒ void

This method returns an undefined value.

Parse an XML element into this object.

Parameters:

  • node (Nokogiri::XML::Element)


32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/saml2/contact.rb', line 32

def from_xml(node)
  self.type = node["contactType"]
  company = node.at_xpath("md:Company", Namespaces::ALL)
  self.company = company && company.content && company.content.strip
  given_name = node.at_xpath("md:GivenName", Namespaces::ALL)
  self.given_name = given_name && given_name.content && given_name.content.strip
  surname = node.at_xpath("md:SurName", Namespaces::ALL)
  self.surname = surname && surname.content && surname.content.strip
  self.email_addresses = load_string_array(node, "md:EmailAddress")
  self.telephone_numbers = load_string_array(node, "md:TelephoneNumber")
  self
end