PerformExchangeRequest() public method

Core method for performing EWS calls against the Exchange service.
public PerformExchangeRequest ( UserCredentials credentials, string exchangeUrl, string param, ExchangeRequestType requestType, IEnumerable additionalParam = null ) : IExchangeResponse
credentials Hummingbird.Models.UserCredentials User credentials.
exchangeUrl string URL to the EWS endpoint.
param string Additional parameters that work with the specific request.
requestType ExchangeRequestType Type of the EWS request.
additionalParam IEnumerable List of additional parameters needed for a request.
return IExchangeResponse
        private async void BtnTest_Click(object sender, RoutedEventArgs e)
        {
            var credManager = new CredentialManager();
            var creds = credManager.GetUserCredentials();

            IExchangeResponse result = null;

            await Task.Run(() =>
            {
                var connector = new ExchangeConnector();

                result = connector.PerformExchangeRequest(creds,
                    AccountSettingsViewModel.Instance.ServerUrl, string.Empty, ExchangeRequestType.DeleteGroup, null);
            });
        }
        private static async Task<bool> ValidateAlias(UserCredentials credentials, string alias)
        {
            IExchangeResponse result = null;

            await Task.Run(() =>
            {
                var connector = new ExchangeConnector();

                result = connector.PerformExchangeRequest(credentials,
                    AccountSettingsViewModel.Instance.ServerUrl, alias, ExchangeRequestType.ValidateAlias);
            });

            return result != null && ((AliasValidationEnvelope) result).Body.Response.IsAliasUnique;
        }
        private static async Task<SetMemberEnvelope> AddMembersToGroup(UserCredentials credentials, string alias,
            IEnumerable<string> members)
        {
            IExchangeResponse result = null;

            // add a loop here and add error messages
            await Task.Run(() =>
            {
                var connector = new ExchangeConnector();

                result = connector.PerformExchangeRequest(credentials,
                    AccountSettingsViewModel.Instance.ServerUrl, alias, ExchangeRequestType.AddMember, members);
            });

            return (SetMemberEnvelope)result;
        }
        private static async Task<string> CreateGroup(UserCredentials credentials, string alias, string owner)
        {
            IExchangeResponse result = null;

            await Task.Run(() =>
            {
                var connector = new ExchangeConnector();

                result = connector.PerformExchangeRequest(credentials,
                    AccountSettingsViewModel.Instance.ServerUrl, alias, ExchangeRequestType.CreateGroup, new List<string> { owner });
            });


            if (result != null)
            {
                if (((GroupCreationEnvelope)result).Body.CreateUnifiedGroupResponseMessage.GroupIdentity != null &&
                    ((GroupCreationEnvelope)result).Body.CreateUnifiedGroupResponseMessage.GroupIdentity.Type.ToLower() == "smtpaddress")
                {
                    return ((GroupCreationEnvelope)result).Body.CreateUnifiedGroupResponseMessage.GroupIdentity.Value;
                }
                return string.Empty;
            }
            return string.Empty;
        }
        private async Task<object> GetGroupInformation(UserCredentials credentials, string groupQualifiedName)
        {
            IExchangeResponse result = null;

            await Task.Run(() =>
            {
                var connector = new ExchangeConnector();

                result = connector.PerformExchangeRequest(credentials,
                    AccountSettingsViewModel.Instance.ServerUrl, groupQualifiedName, ExchangeRequestType.GetUnifiedGroupDetails);
            });

            return (GetUnifiedGroupEnvelope) result;
        }
        private static BulkAddMembersResult AddMembersToGroupSingleBatch(UserCredentials credentials, string alias,
            IEnumerable<string> members)
        {
            var memberList = members.ToList();
            var connector = new ExchangeConnector();

            IExchangeResponse result = connector.PerformExchangeRequest(credentials,
                AccountSettingsViewModel.Instance.ServerUrl, alias, ExchangeRequestType.AddMember, memberList);

            var addMemberResult = new BulkAddMembersResult
            {
                StatusCode = result != null
                    ? ((SetMemberEnvelope)result).Body.SetUnifiedGroupMembershipResponseMessage.ResponseCode
                    : string.Empty,

                MemberCount = memberList.Count
            };

            if (addMemberResult.StatusCode.ToLower() != "noerror" && addMemberResult.StatusCode.ToLower() != "errorinvalidid")
            {
                addMemberResult.FailedMembers = memberList;
            }
            else if (result != null)
            {
                addMemberResult.FailedMembers = ((SetMemberEnvelope)result).Body.SetUnifiedGroupMembershipResponseMessage.FailedMembers;

                addMemberResult.InvalidMembers = ((SetMemberEnvelope)result).Body.SetUnifiedGroupMembershipResponseMessage.InvalidMembers;
            }

            return addMemberResult;
        }