/// <summary>
        /// Updates the specified AuthenticationMethodConfiguration using PATCH.
        /// </summary>
        /// <param name="authenticationMethodConfigurationToUpdate">The AuthenticationMethodConfiguration to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
        /// <returns>The updated AuthenticationMethodConfiguration.</returns>
        public async System.Threading.Tasks.Task <AuthenticationMethodConfiguration> UpdateAsync(AuthenticationMethodConfiguration authenticationMethodConfigurationToUpdate, CancellationToken cancellationToken)
        {
            if (authenticationMethodConfigurationToUpdate.AdditionalData != null)
            {
                if (authenticationMethodConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    authenticationMethodConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, authenticationMethodConfigurationToUpdate.GetType().Name)
                    });
                }
            }
            if (authenticationMethodConfigurationToUpdate.AdditionalData != null)
            {
                if (authenticationMethodConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    authenticationMethodConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, authenticationMethodConfigurationToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <AuthenticationMethodConfiguration>(authenticationMethodConfigurationToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
Beispiel #2
0
 /// <summary>
 /// Adds the specified AuthenticationMethodConfiguration to the collection via POST.
 /// </summary>
 /// <param name="authenticationMethodConfiguration">The AuthenticationMethodConfiguration to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created AuthenticationMethodConfiguration.</returns>
 public System.Threading.Tasks.Task <AuthenticationMethodConfiguration> AddAsync(AuthenticationMethodConfiguration authenticationMethodConfiguration, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     authenticationMethodConfiguration.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(authenticationMethodConfiguration.GetType().FullName));
     return(this.SendAsync <AuthenticationMethodConfiguration>(authenticationMethodConfiguration, cancellationToken));
 }