Ejemplo n.º 1
0
        /// <summary>
        /// Sends invitation to current member
        /// </summary>
        /// <param name="subject">Invitation subject</param>
        /// <param name="body">Invitation body</param>
        /// <returns>Value containing true or false, depending on operation success, and response status</returns>
        /// <exception cref="LinkedInMissingParameterException">Thrown when some of the following is missing: subject, body, <see cref="ApiStandardProfileRquest"/> property or ApiStandardProfileRquest headers</exception>
        public LinkedInResponse <bool> SendInvitation(string subject, string body)
        {
            if (string.IsNullOrEmpty(subject))
            {
                throw new LinkedInMissingParameterException("Invitation subject cannot be null or empty", "Subject");
            }
            if (string.IsNullOrEmpty(body))
            {
                throw new LinkedInMissingParameterException("Invitation body cannot be null or empty", "Body");
            }
            if (ApiStandardProfileRquest == null)
            {
                throw new LinkedInMissingParameterException("ApiStandardProfileRquest field is not set", "ApiStandardProfileRquest");
            }
            if (!ApiStandardProfileRquest.Headers.Any())
            {
                throw new LinkedInMissingParameterException("There are no headers in ApiStandardProfileRquest field", "Headers");
            }
            var header = ApiStandardProfileRquest.Headers.First();
            var arr    = header.Value.Split(':');

            var options = new LinkedInInvitationOptions
            {
                Body               = body,
                Subject            = subject,
                RecipientId        = Id,
                AuthorizationName  = arr[0],
                AuthorizationValue = arr[1]
            };

            return(RequestRunner.SendInvitation(options));
        }