Permalink
Browse files

Updated Profile API (skills, certifications, publications, languages …

…and courses) [SPRNETSOCIALLI-3]
  • Loading branch information...
bbaia committed Nov 1, 2012
1 parent 74d68b3 commit 15d48a324359460ef6b564436930720726ffa818
@@ -0,0 +1,64 @@
+#region License
+
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * 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.
+ */
+
+#endregion
+
+using System;
+
+namespace Spring.Social.LinkedIn.Api
+{
+ /// <summary>
+ /// Represents an certification details for a Profile on LinkedIn.
+ /// </summary>
+ /// <author>James Fleming</author>
+#if !SILVERLIGHT
+ [Serializable]
+#endif
+ public class Certification
+ {
+ /// <summary>
+ /// Gets or sets the unique identifier for the certification entry.
+ /// </summary>
+ public int ID { get; set; }
+
+ /// <summary>
+ /// Gets or sets the name of this certification.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the name of the certification's issuing body.
+ /// </summary>
+ public string AuthorityName { get; set; }
+
+ /// <summary>
+ /// Gets or sets the license number for this certification.
+ /// </summary>
+ public string Number { get; set; }
+
+ /// <summary>
+ /// Gets or sets the start date for the certification.
+ /// </summary>
+ public LinkedInDate StartDate { get; set; }
+
+ /// <summary>
+ /// Gets or sets the end date for the certification.
+ /// </summary>
+ public LinkedInDate EndDate { get; set; }
+ }
+}
@@ -0,0 +1,49 @@
+#region License
+
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * 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.
+ */
+
+#endregion
+
+using System;
+
+namespace Spring.Social.LinkedIn.Api
+{
+ /// <summary>
+ /// Represents an course details for a Profile on LinkedIn.
+ /// </summary>
+ /// <author>James Fleming</author>
+#if !SILVERLIGHT
+ [Serializable]
+#endif
+ public class Course
+ {
+ /// <summary>
+ /// Gets or sets the unique identifier for the course entry.
+ /// </summary>
+ public int ID { get; set; }
+
+ /// <summary>
+ /// Gets or sets the name of this course, as entered by the member.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the course number assigned, as entered by the member.
+ /// </summary>
+ public string Number { get; set; }
+ }
+}
@@ -30,6 +30,7 @@ namespace Spring.Social.LinkedIn.Api.Impl.Json
/// JSON deserializer for LinkedIn full user's profile.
/// </summary>
/// <author>Bruno Baia</author>
+ /// <author>James Fleming</author>
class LinkedInFullProfileDeserializer : LinkedInProfileDeserializer
{
public override object Deserialize(JsonValue json, JsonMapper mapper)
@@ -54,10 +55,14 @@ public override object Deserialize(JsonValue json, JsonMapper mapper)
profile.ProposalComments = json.GetValueOrDefault<string>("proposalComments", String.Empty);
profile.Recommendations = DeserializeRecommendations(json.GetValue("recommendationsReceived"), mapper);
profile.RecommendersCount = json.GetValueOrDefault<int?>("numRecommenders");
- profile.Skills = DeserializeSkills(json.GetValue("skills"));
profile.Specialties = json.GetValueOrDefault<string>("specialties", String.Empty);
profile.TwitterAccounts = DeserializeTwitterAccounts(json.GetValue("twitterAccounts"));
profile.UrlResources = DeserializeUrlResources(json.GetValue("memberUrlResources"));
+ profile.Certifications = DeserializeCertifications(json.GetValue("certifications"));
+ profile.Skills = DeserializeSkills(json.GetValue("skills"));
+ profile.Publications = DeserializePublications(json.GetValue("publications"));
+ profile.Courses = DeserializeCourses(json.GetValue("courses"));
+ profile.Languages = DeserializeLanguages(json.GetValue("languages"));
return profile;
}
@@ -81,23 +86,6 @@ private static LinkedInDate DeserializeLinkedInDate(JsonValue json)
return null;
}
- private static IList<string> DeserializeSkills(JsonValue json)
- {
- IList<string> skills = new List<string>();
- if (json != null)
- {
- JsonValue valuesJson = json.GetValue("values");
- if (valuesJson != null)
- {
- foreach (JsonValue itemJson in valuesJson.GetValues())
- {
- skills.Add(itemJson.GetValue("skill").GetValue<string>("name"));
- }
- }
- }
- return skills;
- }
-
private static IList<ImAccount> DeserializeImAccounts(JsonValue json)
{
IList<ImAccount> imAccounts = new List<ImAccount>();
@@ -263,7 +251,7 @@ private static IList<Position> DeserializePositions(JsonValue json)
{
positions.Add(new Position()
{
- ID = itemJson.GetValue<string>("id"),
+ ID = itemJson.GetValueOrDefault<string>("id"),
Company = DeserializeCompany(itemJson.GetValue("company")),
Title = itemJson.GetValueOrDefault<string>("title", String.Empty),
Summary = itemJson.GetValueOrDefault<string>("summary", String.Empty),
@@ -293,5 +281,148 @@ private static Company DeserializeCompany(JsonValue json)
}
return null;
}
+
+ private static IList<Skill> DeserializeSkills(JsonValue json)
+ {
+ IList<Skill> skills = new List<Skill>();
+ if (json != null)
+ {
+ JsonValue valuesJson = json.GetValue("values");
+ if (valuesJson != null)
+ {
+ foreach (JsonValue itemJson in valuesJson.GetValues())
+ {
+ skills.Add(new Skill
+ {
+ ID = itemJson.GetValueOrDefault<int>("id"),
+ Name = itemJson.ContainsName("skill") ? itemJson.GetValue("skill").GetValueOrDefault<string>("name", String.Empty) : String.Empty,
+ Proficiency = DeserializeProficiency(itemJson.GetValue("proficiency")),
+ Years = DeserializeYears(itemJson.GetValue("years"))
+ });
+ }
+ }
+ }
+ return skills;
+ }
+
+ private static Proficiency DeserializeProficiency(JsonValue json)
+ {
+ if (json != null)
+ {
+ return new Proficiency()
+ {
+ Level = json.GetValueOrDefault<string>("level", String.Empty),
+ Name = json.GetValueOrDefault<string>("name", String.Empty)
+ };
+ }
+ return null;
+ }
+
+ private static Years DeserializeYears(JsonValue json)
+ {
+ if (json != null)
+ {
+ return new Years()
+ {
+ ID = json.GetValueOrDefault<int>("id"),
+ Name = json.GetValueOrDefault<string>("name", String.Empty)
+ };
+ }
+ return null;
+ }
+
+ private static IList<Certification> DeserializeCertifications(JsonValue json)
+ {
+ IList<Certification> certifications = new List<Certification>();
+ if (json != null)
+ {
+ JsonValue valuesJson = json.GetValue("values");
+ if (valuesJson != null)
+ {
+ foreach (JsonValue itemJson in valuesJson.GetValues())
+ {
+ certifications.Add(new Certification()
+ {
+ ID = itemJson.GetValueOrDefault<int>("id"),
+ Name = itemJson.GetValueOrDefault<string>("name", String.Empty),
+ AuthorityName = itemJson.ContainsName("authority") ? itemJson.GetValue("authority").GetValueOrDefault<string>("name", String.Empty) : String.Empty,
+ Number = itemJson.GetValueOrDefault<string>("number", String.Empty),
+ StartDate = DeserializeLinkedInDate(itemJson.GetValue("startDate")),
+ EndDate = DeserializeLinkedInDate(itemJson.GetValue("endDate"))
+ });
+ }
+ }
+ }
+ return certifications;
+ }
+
+ private static IList<Course> DeserializeCourses(JsonValue json)
+ {
+ IList<Course> courses = new List<Course>();
+ if (json != null)
+ {
+ JsonValue valuesJson = json.GetValue("values");
+ if (valuesJson != null)
+ {
+ foreach (JsonValue itemJson in valuesJson.GetValues())
+ {
+ courses.Add(new Course()
+ {
+ ID = itemJson.GetValueOrDefault<int>("id"),
+ Name = itemJson.GetValueOrDefault<string>("name", String.Empty),
+ Number = itemJson.GetValueOrDefault<string>("number", String.Empty)
+ });
+ }
+ }
+ }
+ return courses;
+ }
+
+ private static IList<Language> DeserializeLanguages(JsonValue json)
+ {
+ IList<Language> languages = new List<Language>();
+ if (json != null)
+ {
+ JsonValue valuesJson = json.GetValue("values");
+ if (valuesJson != null)
+ {
+ foreach (JsonValue itemJson in valuesJson.GetValues())
+ {
+ languages.Add(new Language
+ {
+ ID = itemJson.GetValueOrDefault<int>("id"),
+ Name = itemJson.ContainsName("language") ? itemJson.GetValue("language").GetValueOrDefault<string>("name", String.Empty) : String.Empty,
+ Proficiency = DeserializeProficiency(itemJson.GetValue("proficiency"))
+ });
+ }
+ }
+ }
+ return languages;
+ }
+
+ private static IList<Publication> DeserializePublications(JsonValue json)
+ {
+ IList<Publication> publications = new List<Publication>();
+ if (json != null)
+ {
+ JsonValue valuesJson = json.GetValue("values");
+ if (valuesJson != null)
+ {
+ foreach (JsonValue itemJson in valuesJson.GetValues())
+ {
+ publications.Add(new Publication()
+ {
+ ID = itemJson.GetValueOrDefault<int>("id"),
+ Title = itemJson.GetValueOrDefault<string>("title", String.Empty),
+ PublisherName = itemJson.ContainsName("publisher") ? itemJson.GetValue("publisher").GetValueOrDefault<string>("name", String.Empty) : String.Empty,
+ Summary = itemJson.GetValueOrDefault<string>("summary", String.Empty),
+ Url = itemJson.GetValueOrDefault<string>("url"),
+ Date = DeserializeLinkedInDate(itemJson.GetValue("date"))
+ });
+ }
+ }
+ }
+ return publications;
+ }
}
}
@@ -41,7 +41,8 @@ namespace Spring.Social.LinkedIn.Api.Impl
class ProfileTemplate : AbstractLinkedInOperations, IProfileOperations
{
private const string ProfileUrl = "people/{id}:(id,first-name,last-name,headline,industry,public-profile-url,picture-url,summary,site-standard-profile-request,api-standard-profile-request)?format=json";
- private const string FullProfileUrl = "people/{id}:(id,first-name,last-name,headline,industry,public-profile-url,picture-url,summary,site-standard-profile-request,api-standard-profile-request,location,distance,num-connections,num-connections-capped,specialties,proposal-comments,associations,honors,interests,positions,skills,educations,num-recommenders,recommendations-received,phone-numbers,im-accounts,twitter-accounts,date-of-birth,main-address,member-url-resources)?format=json";
+ private const string FullProfileUrl = "people/{id}:(id,first-name,last-name,headline,industry,public-profile-url,picture-url,summary,site-standard-profile-request,api-standard-profile-request,location,distance,num-connections,num-connections-capped,specialties,proposal-comments,associations,honors,interests,positions,skills,educations,num-recommenders,recommendations-received,phone-numbers,im-accounts,twitter-accounts,date-of-birth,main-address,member-url-resources,certifications,publications,courses,languages)?format=json";
+
private const string SearchUrl = "https://api.linkedin.com/v1/people-search:(people:(id,first-name,last-name,headline,industry,public-profile-url,picture-url,summary,site-standard-profile-request,api-standard-profile-request))?format=json";
private RestTemplate restTemplate;
@@ -0,0 +1,51 @@
+#region License
+
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * 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.
+ */
+
+#endregion
+
+using System;
+
+namespace Spring.Social.LinkedIn.Api
+{
+ /// <summary>
+ /// Represents an language details for a Profile on LinkedIn.
+ /// </summary>
+ /// <author>James Fleming</author>
+#if !SILVERLIGHT
+ [Serializable]
+#endif
+ public class Language
+ {
+ /// <summary>
+ /// Gets or sets the unique identifier for a single language in the list of languages.
+ /// </summary>
+ public int ID { get; set; }
+
+ /// <summary>
+ /// Gets or sets the language name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the user's fluency.
+ /// <para/>
+ /// Possible values for level are: elementary, limited-working, professional-working, full-professional and native-or-bilingual.
+ /// </summary>
+ public Proficiency Proficiency { get; set; }
+ }
+}
Oops, something went wrong.

0 comments on commit 15d48a3

Please sign in to comment.