class MiiCardDirectoryService
Constants
- CRITERION_EBAY
- CRITERION_EMAIL
- CRITERION_FACEBOOK
- CRITERION_GOOGLE
- CRITERION_LINKEDIN
- CRITERION_MICROSOFT_ID
- CRITERION_PHONE
- CRITERION_TWITTER
- CRITERION_USERNAME
- CRITERION_VERITAS_VITAE
Public Class Methods
hash_identifier(identifier)
click to toggle source
# File lib/miiCardConsumers.rb, line 964 def self.hash_identifier(identifier) return Digest::SHA1.hexdigest(identifier.downcase) end
Public Instance Methods
find_by(criterion, value, hashed = false)
click to toggle source
# File lib/miiCardConsumers.rb, line 936 def find_by(criterion, value, hashed = false) url = MiiCardServiceUrls::get_directory_service_query_url(criterion, value, hashed) uri = URI.parse(url) cert_store = OpenSSL::X509::Store.new cert_store.set_default_paths http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.cert_store = cert_store http.ca_file = File.join(File.dirname(__FILE__), "certs/sts.miicard.com.pem") request = Net::HTTP::Get.new(url) request['Content-type'] = 'application/json' response = (http.request(request) rescue nil) if !response.nil? && !response.body.to_s.empty? # Try parsing the response as a MiiApiResponse of MiiUserProfile parsed_response = (MiiApiResponse::from_hash(JSON.parse(response.body), MiiUserProfile.method(:from_hash)) rescue nil) if !parsed_response.nil? && !parsed_response.data.nil? to_return = parsed_response.data end end return to_return end
find_by_ebay(ebay_handle_or_profile_url, hashed = false)
click to toggle source
# File lib/miiCardConsumers.rb, line 928 def find_by_ebay(ebay_handle_or_profile_url, hashed = false) return find_by(CRITERION_EBAY, ebay_handle_or_profile_url, hashed) end
find_by_email(email, hashed = false)
click to toggle source
# File lib/miiCardConsumers.rb, line 896 def find_by_email(email, hashed = false) return find_by(CRITERION_EMAIL, email, hashed) end
find_by_facebook(facebook_url, hashed = false)
click to toggle source
# File lib/miiCardConsumers.rb, line 912 def find_by_facebook(facebook_url, hashed = false) return find_by(CRITERION_FACEBOOK, facebook_url, hashed) end
find_by_google(google_handle_or_profile_url, hashed = false)
click to toggle source
# File lib/miiCardConsumers.rb, line 920 def find_by_google(google_handle_or_profile_url, hashed = false) return find_by(CRITERION_GOOGLE, google_handle_or_profile_url, hashed) end
find_by_linkedin(linkedin_www_url, hashed = false)
click to toggle source
# File lib/miiCardConsumers.rb, line 916 def find_by_linkedin(linkedin_www_url, hashed = false) return find_by(CRITERION_LINKEDIN, linkedin_www_url, hashed) end
find_by_microsoft_id(microsoft_id_url, hashed = false)
click to toggle source
# File lib/miiCardConsumers.rb, line 924 def find_by_microsoft_id(microsoft_id_url, hashed = false) return find_by(CRITERION_MICROSOFT_ID, microsoft_id_url, hashed) end
find_by_phone_number(phone, hashed = false)
click to toggle source
# File lib/miiCardConsumers.rb, line 900 def find_by_phone_number(phone, hashed = false) return find_by(CRITERION_PHONE, phone, hashed) end
find_by_twitter(twitter_handle_or_profile_url, hashed = false)
click to toggle source
# File lib/miiCardConsumers.rb, line 908 def find_by_twitter(twitter_handle_or_profile_url, hashed = false) return find_by(CRITERION_TWITTER, twitter_handle_or_profile_url, hashed) end
find_by_username(username, hashed = false)
click to toggle source
# File lib/miiCardConsumers.rb, line 904 def find_by_username(username, hashed = false) return find_by(CRITERION_USERNAME, username, hashed) end
find_by_veritas_vitae(veritas_vitae_vv_number_or_profile_url, hashed = false)
click to toggle source
# File lib/miiCardConsumers.rb, line 932 def find_by_veritas_vitae(veritas_vitae_vv_number_or_profile_url, hashed = false) return find_by(CRITERION_VERITAS_VITAE, veritas_vitae_vv_number_or_profile_url, hashed) end