/// <summary>
        /// Updates the specified OfficeClientConfiguration using PATCH.
        /// </summary>
        /// <param name="officeClientConfigurationToUpdate">The OfficeClientConfiguration 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 OfficeClientConfiguration.</returns>
        public async System.Threading.Tasks.Task <OfficeClientConfiguration> UpdateAsync(OfficeClientConfiguration officeClientConfigurationToUpdate, CancellationToken cancellationToken)
        {
            if (officeClientConfigurationToUpdate.AdditionalData != null)
            {
                if (officeClientConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    officeClientConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, officeClientConfigurationToUpdate.GetType().Name)
                    });
                }
            }
            if (officeClientConfigurationToUpdate.AdditionalData != null)
            {
                if (officeClientConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    officeClientConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, officeClientConfigurationToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <OfficeClientConfiguration>(officeClientConfigurationToUpdate, cancellationToken).ConfigureAwait(false);

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