Beispiel #1
0
        /// <summary>
        /// Get groups suggested to member
        /// </summary>
        /// <param name="options">The object of type <see cref="LinkedInGetGroupOptions"/> representing retrieval options</param>
        /// <returns>Value containing collection of <see cref="LinkedInGroup"/> objects and response status</returns>
        /// <example>
        /// This sample shows how to call this method:
        /// <code>
        /// using LinkedIn.NET;
        /// using LinkedIn.NET.Groups;
        /// using LinkedIn.NET.Members;
        /// using LinkedIn.NET.Options;
        /// using LinkedIn.NET.Search;
        /// using LinkedIn.NET.Updates;
        /// ...
        /// // define retrieval options
        /// var options = new LinkedInGetGroupOptions();
        /// options.GroupOptions.SelectAll();
        /// var result = _Client.GetSuggestedGroups(options)
        /// // always check response.Result and response.Status before processing
        /// if (result.Result != null &amp;&amp; result.Status == LinkedInResponseStatus.OK)
        /// {
        ///     foreach (var r in result.Result)
        ///     {
        ///         Console.WriteLine(r.Name);
        ///     }
        /// }
        /// </code>
        /// </example>
        public LinkedInResponse<IEnumerable<LinkedInGroup>> GetSuggestedGroups(LinkedInGetGroupOptions options)
        {
            try
            {
                var sb = new StringBuilder(Utils.GROUPS_SUGGESTIONS_URL);
                var paramsGroup = RequestFields.PrepareGroupFields(options);
                if (!string.IsNullOrEmpty(paramsGroup))
                    sb.Append(paramsGroup);

                sb.Append("?start=0&count=250&oauth2_access_token=");
                sb.Append(Singleton.Instance.AccessToken);
                return
                    new LinkedInResponse<IEnumerable<LinkedInGroup>>(
                        RequestRunner.GetSuggestedGroups(sb.ToString(), options),
                        LinkedInResponseStatus.OK, null);
            }
            catch (WebException wex)
            {
                return Utils.GetResponse<IEnumerable<LinkedInGroup>>(null, wex, null);
            }
            catch (Exception ex)
            {
                return new LinkedInResponse<IEnumerable<LinkedInGroup>>(null, LinkedInResponseStatus.OtherException, null, ex);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Asynchronously gets groups suggested to member
 /// </summary>
 /// <param name="options">The object of type <see cref="LinkedInGetGroupOptions"/> representing retrieval options</param>
 /// <param name="action">Action to be invoked when the retrieval process ends</param>
 /// <returns>Status of asynchronous operation</returns>
 /// <example>
 /// This sample shows how to call this method:
 /// <code>
 /// using LinkedIn.NET;
 /// using LinkedIn.NET.Groups;
 /// using LinkedIn.NET.Members;
 /// using LinkedIn.NET.Options;
 /// using LinkedIn.NET.Search;
 /// using LinkedIn.NET.Updates;
 /// ...
 /// // define retrieval options
 /// var options = new LinkedInGetGroupOptions();
 /// options.GroupOptions.SelectAll();
 /// _Client.GetSuggestedGroups(options, listSuggestedGroups)
 /// ...
 /// // application defined function
 /// private void listSuggestedGroups(LinkedInResponse&lt;IEnumerable&lt;LinkedInGroup&gt;&gt; result)
 /// {
 ///     // always check response.Result and response.Status before processing
 ///     if (result.Result != null &amp;&amp; result.Status == LinkedInResponseStatus.OK)
 ///     {
 ///         foreach (var r in result.Result)
 ///         {
 ///             Console.WriteLine(r.Name);
 ///         }
 ///     }
 /// }
 /// </code>
 /// </example> 
 public IAsyncResult GetSuggestedGroups(LinkedInGetGroupOptions options,
     Action<LinkedInResponse<IEnumerable<LinkedInGroup>>> action)
 {
     ListGroupsDelegate _delegate = GetSuggestedGroups;
     return _delegate.BeginInvoke(options, listGroupsCallback, action);
 }
Beispiel #3
0
 /// <summary>
 /// Gets groups that currently logged in user belongs to
 /// </summary>
 /// <param name="options">The object of type <see cref="LinkedInGetGroupOptions"/> representing retrieval options</param>
 /// <returns>Value containing collection of <see cref="LinkedInGroup"/> objects and response status</returns>
 /// <example>
 /// This sample shows how to call this method:
 /// <code>
 /// using LinkedIn.NET;
 /// using LinkedIn.NET.Groups;
 /// using LinkedIn.NET.Members;
 /// using LinkedIn.NET.Options;
 /// using LinkedIn.NET.Search;
 /// using LinkedIn.NET.Updates;
 /// ...
 /// // define retrieval options
 /// var options = new LinkedInGetGroupOptions();
 /// options.GroupOptions.SelectAll();
 /// var result = _Client.GetMemberGroups(options)
 /// // always check response.Result and response.Status before processing
 /// if (result.Result != null &amp;&amp; result.Status == LinkedInResponseStatus.OK)
 /// {
 ///     foreach (var r in result.Result)
 ///     {
 ///         Console.WriteLine(r.Name);
 ///     }
 /// }
 /// </code>
 /// </example>
 public LinkedInResponse<IEnumerable<LinkedInGroup>> GetMemberGroups(LinkedInGetGroupOptions options)
 {
     try
     {
         var sb = new StringBuilder(Utils.GROUPS_MEMBERSHIP_URL);
         var paramsGroup = RequestFields.PrepareGroupFields(options);
         if (!string.IsNullOrEmpty(paramsGroup))
             sb.Append(paramsGroup);
         sb.Append(",membership-state,show-group-logo-in-profile,allow-messages-from-members,email-digest-frequency,email-announcements-from-managers,email-for-every-new-post)?start=0&count=250&oauth2_access_token=");
         sb.Append(Singleton.Instance.AccessToken);
         return
             new LinkedInResponse<IEnumerable<LinkedInGroup>>(
                 RequestRunner.GetMemberGroups(sb.ToString(), options),
                 LinkedInResponseStatus.OK, null);
     }
     catch (WebException wex)
     {
         return Utils.GetResponse<IEnumerable<LinkedInGroup>>(null, wex, null);
     }
     catch (Exception ex)
     {
         return new LinkedInResponse<IEnumerable<LinkedInGroup>>(null, LinkedInResponseStatus.OtherException, null, ex);
     }
 }
Beispiel #4
0
 internal static IEnumerable<LinkedInGroup> GetMemberGroups(string requestUrl, LinkedInGetGroupOptions options)
 {
     var results = new List<LinkedInGroup>();
     var responseString = Utils.MakeRequest(requestUrl, "GET");
     var xdoc = XDocument.Parse(responseString);
     var xroot = xdoc.Root;
     if (xroot == null)
         return results.AsEnumerable();
     foreach (var xm in xroot.Elements("group-membership"))
     {
         var xg = xm.Element("group");
         if (xg == null) continue;
         var g = Utils.BuildGroup(xg);
         g.Settings = Utils.BuildGroupSettings(xm);
         results.Add(g);
     }
     return results.AsEnumerable();
 }
Beispiel #5
0
 internal static IEnumerable<LinkedInGroup> GetSuggestedGroups(string requestUrl, LinkedInGetGroupOptions options)
 {
     var results = new List<LinkedInGroup>();
     var responseString = Utils.MakeRequest(requestUrl, "GET");
     var xdoc = XDocument.Parse(responseString);
     var xroot = xdoc.Root;
     if (xroot == null)
         return results.AsEnumerable();
     results.AddRange(xroot.Elements("group").Select(Utils.BuildGroup));
     return results.AsEnumerable();
 }
Beispiel #6
0
		/// <summary>
		/// Load synchronously.  Call with a await Task.Run(()=>LoadAllGroups()); to run async. 
		/// </summary>
		protected void LoadAllGroups()
		{
			if (haveAccessToken)
			{
				LinkedInGetGroupOptions options = new LinkedInGetGroupOptions();
				options.GroupOptions.SelectAll();
				LinkedInResponse<IEnumerable<LinkedInGroup>> groupResult = linkedInClient.GetMemberGroups(options);
				groupResult.Result.ForEach(g => groups[g.Id] = g);
			}
		}
Beispiel #7
0
        internal static string PrepareGroupFields(LinkedInGetGroupOptions options)
        {
            var sb = new StringBuilder();
            var go = options.GroupOptions;

            if (go.HasValues)
            {
                sb.Append(":(");
                if (go[LinkedInGroupFields.Id])
                    sb.Append("id,");
                if (go[LinkedInGroupFields.Name])
                    sb.Append("name,");
                if (go[LinkedInGroupFields.ShortDescription])
                    sb.Append("short-description,");
                if (go[LinkedInGroupFields.Description])
                    sb.Append("description,");
                if (go[LinkedInGroupFields.RelationToViewer])
                    sb.Append("relation-to-viewer,");
                if (go[LinkedInGroupFields.CountsByCategory])
                    sb.Append("counts-by-category,");
                if (go[LinkedInGroupFields.IsOpenToNonMembers])
                    sb.Append("is-open-to-non-members,");
                if (go[LinkedInGroupFields.Category])
                    sb.Append("category,");
                if (go[LinkedInGroupFields.WebSiteUrl])
                    sb.Append("website-url,");
                if (go[LinkedInGroupFields.SiteGroupUrl])
                    sb.Append("site-group-url,");
                if (go[LinkedInGroupFields.Locale])
                    sb.Append("locale,");
                if (go[LinkedInGroupFields.Location])
                    sb.Append("location,");
                if (go[LinkedInGroupFields.AllowMembersInvite])
                    sb.Append("allow-member-invites,");
                if (go[LinkedInGroupFields.SmallLogoUrl])
                    sb.Append("small-logo-url,");
                if (go[LinkedInGroupFields.LargeLogoUrl])
                    sb.Append("large-logo-url,");
                if (go[LinkedInGroupFields.NumberOfMembers])
                    sb.Append("num-members,");
                sb.Length -= 1;
                sb.Append(")");
            }

            return sb.ToString();
        }