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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
Beispiel #2
0
        /// <summary>
        /// Creates the specified ConversationThread using PUT.
        /// </summary>
        /// <param name="conversationThreadToCreate">The ConversationThread to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created ConversationThread.</returns>
        public async Task <ConversationThread> CreateAsync(ConversationThread conversationThreadToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "PUT";
            var newEntity = await this.SendAsync <ConversationThread>(conversationThreadToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
        /// <summary>
        /// Updates the specified ConversationThread using PATCH.
        /// </summary>
        /// <param name="conversationThreadToUpdate">The ConversationThread to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The updated ConversationThread.</returns>
        public async System.Threading.Tasks.Task <ConversationThread> UpdateAsync(ConversationThread conversationThreadToUpdate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <ConversationThread>(conversationThreadToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
Beispiel #4
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="conversationThreadToInitialize">The <see cref="ConversationThread"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(ConversationThread conversationThreadToInitialize)
        {
            if (conversationThreadToInitialize != null && conversationThreadToInitialize.AdditionalData != null)
            {
                if (conversationThreadToInitialize.Posts != null && conversationThreadToInitialize.Posts.CurrentPage != null)
                {
                    conversationThreadToInitialize.Posts.AdditionalData = conversationThreadToInitialize.AdditionalData;

                    object nextPageLink;
                    conversationThreadToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        conversationThreadToInitialize.Posts.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Beispiel #5
0
 /// <summary>
 /// Creates the specified ConversationThread using PUT.
 /// </summary>
 /// <param name="conversationThreadToCreate">The ConversationThread to create.</param>
 /// <returns>The created ConversationThread.</returns>
 public Task <ConversationThread> CreateAsync(ConversationThread conversationThreadToCreate)
 {
     return(this.CreateAsync(conversationThreadToCreate, CancellationToken.None));
 }
Beispiel #6
0
 /// <summary>
 /// Adds the specified ConversationThread to the collection via POST.
 /// </summary>
 /// <param name="conversationThread">The ConversationThread to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created ConversationThread.</returns>
 public Task <ConversationThread> AddAsync(ConversationThread conversationThread, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <ConversationThread>(conversationThread, cancellationToken));
 }
Beispiel #7
0
 /// <summary>
 /// Adds the specified ConversationThread to the collection via POST.
 /// </summary>
 /// <param name="conversationThread">The ConversationThread to add.</param>
 /// <returns>The created ConversationThread.</returns>
 public Task <ConversationThread> AddAsync(ConversationThread conversationThread)
 {
     return(this.AddAsync(conversationThread, CancellationToken.None));
 }
Beispiel #8
0
 /// <summary>
 /// Updates the specified ConversationThread using PATCH.
 /// </summary>
 /// <param name="conversationThreadToUpdate">The ConversationThread to update.</param>
 /// <returns>The updated ConversationThread.</returns>
 public System.Threading.Tasks.Task <ConversationThread> UpdateAsync(ConversationThread conversationThreadToUpdate)
 {
     return(this.UpdateAsync(conversationThreadToUpdate, CancellationToken.None));
 }