module Vcard::SwissMatch
  def self.included(base)
    base.extend ClassMethods
  end

  def directory_lookup
    search = {}
    search[:first_name] = given_name
    search[:last_name] = family_name
    search[:street] = street_address
    search[:zip_code] = postal_code
    search[:city] = locality

    ::SwissMatch.directory_service.addresses(search)
  end

  def directory_match?
    directory_lookup.present?
  end

  module ClassMethods
  end
end

module Vcard::SwissMatch
  def self.included(base)
    base.extend ClassMethods
  end

  def map_for_directory
    search = {}
    search[:first_name] = given_name
    search[:last_name] = family_name
    search[:street] = street_address
    search[:zip_code] = postal_code
    search[:city] = locality

    search
  end

  def directory_lookup(ignore_fields = [])
    search = map_for_directory

    search.reject!{|key, value| ignore_fields.include? key}

    ::SwissMatch.directory_service.addresses(search)
  end

  def directory_match?(ignore_fields = [])
    directory_lookup(ignore_fields).present?
  end

  module ClassMethods
  end
end

Support passing an ignore_fields parameter to Vcard.directory_lookup and .directory_match?.
Support passing an ignore_fields parameter to Vcard.directory_lookup and .directory_match?.
