/// <summary>
        /// Creates the specified CalendarSharingMessage using POST.
        /// </summary>
        /// <param name="calendarSharingMessageToCreate">The CalendarSharingMessage to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created CalendarSharingMessage.</returns>
        public async System.Threading.Tasks.Task <CalendarSharingMessage> CreateAsync(CalendarSharingMessage calendarSharingMessageToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <CalendarSharingMessage>(calendarSharingMessageToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="calendarSharingMessageToInitialize">The <see cref="CalendarSharingMessage"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(CalendarSharingMessage calendarSharingMessageToInitialize)
 {
 }
 /// <summary>
 /// Creates the specified CalendarSharingMessage using POST.
 /// </summary>
 /// <param name="calendarSharingMessageToCreate">The CalendarSharingMessage to create.</param>
 /// <returns>The created CalendarSharingMessage.</returns>
 public System.Threading.Tasks.Task <CalendarSharingMessage> CreateAsync(CalendarSharingMessage calendarSharingMessageToCreate)
 {
     return(this.CreateAsync(calendarSharingMessageToCreate, CancellationToken.None));
 }
        /// <summary>
        /// Updates the specified CalendarSharingMessage using PATCH.
        /// </summary>
        /// <param name="calendarSharingMessageToUpdate">The CalendarSharingMessage 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 CalendarSharingMessage.</returns>
        public async System.Threading.Tasks.Task <CalendarSharingMessage> UpdateAsync(CalendarSharingMessage calendarSharingMessageToUpdate, CancellationToken cancellationToken)
        {
            if (calendarSharingMessageToUpdate.AdditionalData != null)
            {
                if (calendarSharingMessageToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    calendarSharingMessageToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, calendarSharingMessageToUpdate.GetType().Name)
                    });
                }
            }
            if (calendarSharingMessageToUpdate.AdditionalData != null)
            {
                if (calendarSharingMessageToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    calendarSharingMessageToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, calendarSharingMessageToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <CalendarSharingMessage>(calendarSharingMessageToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }