class SAML2::Contact

Attributes

company[RW]

@return [String, nil]

email_addresses[RW]

@return [Array<String>]

given_name[RW]

@return [String, nil]

surname[RW]

@return [String, nil]

telephone_numbers[RW]

@return [Array<String>]

type[RW]

@see Type @return [String]

Public Class Methods

new(type = Type::OTHER) click to toggle source

@param type [String]

Calls superclass method SAML2::Base::new
# File lib/saml2/contact.rb, line 24
def initialize(type = Type::OTHER)
  super()
  @type = type
  @email_addresses = []
  @telephone_numbers = []
end

Public Instance Methods

build(builder) click to toggle source

(see Base#build)

# 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) click to toggle source

(see Base#from_xml)

# 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