
org.scribe.up.profile.yahoo.YahooProfile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scribe-up Show documentation
Show all versions of scribe-up Show documentation
Get a user profile after OAuth authentication process with Scribe library
The newest version!
/*
Copyright 2012 Jerome Leleu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.scribe.up.profile.yahoo;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import org.scribe.up.profile.AttributesDefinition;
import org.scribe.up.profile.BaseOAuthProfile;
import org.scribe.up.profile.CommonProfile;
import org.scribe.up.profile.Gender;
import org.scribe.up.profile.OAuthAttributesDefinitions;
/**
* This class is the user profile for Yahoo with appropriate getters.
* It is returned by the {@link org.scribe.up.provider.impl.YahooProvider}.
*
*
*
* Method :
* From the JSON profile response :
*
*
* The attributes of the {@link org.scribe.up.profile.CommonProfile}
*
*
* String getEmail()
* the primary (or only one) email from the emails attribute
*
*
* String getFirstName()
* the given_name attribute
*
*
* String getFamilyName()
* the family_name attribute
*
*
* String getDisplayName()
* the given_name attribute followed by a space and the family_name attribute
*
*
* String getUsername()
* the nickname attribute
*
*
* Gender getGender()
* the gender attribute
*
*
* Locale getLocale()
* the lang attribute
*
*
* String getPictureUrl()
* the imageUrl sub-attribute from the image attribute
*
*
* String getProfileUrl()
* the profile_url attribute
*
*
* String getLocation()
* the location attribute
*
*
* More specific attributes
*
*
* String getAboutMe()
* the aboutMe attribute
*
*
* List<YahooAddress> getAddresses()
* the addresses attribute
*
*
* Integer getBirthYear()
* the birthYear attribute
*
*
* Date getBirthdate()
* the birthdate attribute
*
*
* Date getCreated()
* the created attribute
*
*
* Integer getDisplayAge()
* the displayAge attribute
*
*
* List<YahooDisclosure> getDisclosures()
* the disclosures attribute
*
*
* List<YahooEmail> getEmails()
* the emails attribute
*
*
* YahooImage getImage()
* the image attribute
*
*
* List<YahooInterest> getInterests()
* the interests attribute
*
*
* Boolean getIsConnected()
* the isConnected attribute
*
*
* Date getMemberSince()
* the memberSince attribute
*
*
* String getTimeZone()
* the timeZone attribute
*
*
* Date getUpdated()
* the updated attribute
*
*
* String getUri()
* the uri attribute
*
*
*
* @see org.scribe.up.provider.impl.YahooProvider
* @author Jerome Leleu
* @since 1.1.0
*/
@SuppressWarnings("unchecked")
public class YahooProfile extends BaseOAuthProfile implements CommonProfile {
private static final long serialVersionUID = 4488038951978277301L;
@Override
protected AttributesDefinition getAttributesDefinition() {
return OAuthAttributesDefinitions.yahooDefinition;
}
public String getEmail() {
final List emails = getEmails();
if (emails != null) {
for (final YahooEmail email : emails) {
if (email != null && ((email.getPrimary() != null && email.getPrimary()) || emails.size() == 1)) {
return email.getHandle();
}
}
}
return null;
}
public String getFirstName() {
return (String) get(YahooAttributesDefinition.GIVEN_NAME);
}
public String getFamilyName() {
return (String) get(YahooAttributesDefinition.FAMILY_NAME);
}
public String getDisplayName() {
return getFirstName() + " " + getFamilyName();
}
public String getUsername() {
return (String) get(YahooAttributesDefinition.NICKNAME);
}
public Gender getGender() {
return (Gender) get(YahooAttributesDefinition.GENDER);
}
public Locale getLocale() {
return (Locale) get(YahooAttributesDefinition.LANG);
}
public String getPictureUrl() {
final YahooImage yahooImage = (YahooImage) get(YahooAttributesDefinition.IMAGE);
if (yahooImage != null) {
return yahooImage.getImageUrl();
}
return null;
}
public String getProfileUrl() {
return (String) get(YahooAttributesDefinition.PROFILE_URL);
}
public String getLocation() {
return (String) get(YahooAttributesDefinition.LOCATION);
}
public String getAboutMe() {
return (String) get(YahooAttributesDefinition.ABOUT_ME);
}
public List getAddresses() {
return (List) get(YahooAttributesDefinition.ADDRESSES);
}
public Integer getBirthYear() {
return (Integer) get(YahooAttributesDefinition.BIRTH_YEAR);
}
public Date getBirthdate() {
return (Date) get(YahooAttributesDefinition.BIRTHDATE);
}
public Date getCreated() {
return (Date) get(YahooAttributesDefinition.CREATED);
}
public Integer getDisplayAge() {
return (Integer) get(YahooAttributesDefinition.DISPLAY_AGE);
}
public List getDisclosures() {
return (List) get(YahooAttributesDefinition.DISCLOSURES);
}
public List getEmails() {
return (List) get(YahooAttributesDefinition.EMAILS);
}
public YahooImage getImage() {
return (YahooImage) get(YahooAttributesDefinition.IMAGE);
}
public List getInterests() {
return (List) get(YahooAttributesDefinition.INTERESTS);
}
public Boolean getIsConnected() {
return (Boolean) get(YahooAttributesDefinition.IS_CONNECTED);
}
public Date getMemberSince() {
return (Date) get(YahooAttributesDefinition.MEMBER_SINCE);
}
public String getTimeZone() {
return (String) get(YahooAttributesDefinition.TIME_ZONE);
}
public Date getUpdated() {
return (Date) get(YahooAttributesDefinition.UPDATED);
}
public String getUri() {
return (String) get(YahooAttributesDefinition.URI);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy