/// <summary> /// Updates the specified ContactFolder using PATCH. /// </summary> /// <param name="contactFolderToUpdate">The ContactFolder 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 ContactFolder.</returns> public async System.Threading.Tasks.Task <ContactFolder> UpdateAsync(ContactFolder contactFolderToUpdate, CancellationToken cancellationToken) { if (contactFolderToUpdate.AdditionalData != null) { if (contactFolderToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || contactFolderToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, contactFolderToUpdate.GetType().Name) }); } } if (contactFolderToUpdate.AdditionalData != null) { if (contactFolderToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || contactFolderToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, contactFolderToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <ContactFolder>(contactFolderToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }
/// <summary> /// Creates the specified ContactFolder using POST. /// </summary> /// <param name="contactFolderToCreate">The ContactFolder to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created ContactFolder.</returns> public async System.Threading.Tasks.Task <ContactFolder> CreateAsync(ContactFolder contactFolderToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <ContactFolder>(contactFolderToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Updates the specified ContactFolder using PATCH. /// </summary> /// <param name="contactFolderToUpdate">The ContactFolder to update.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The updated ContactFolder.</returns> public async Task <ContactFolder> UpdateAsync(ContactFolder contactFolderToUpdate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <ContactFolder>(contactFolderToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="contactFolderToInitialize">The <see cref="ContactFolder"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(ContactFolder contactFolderToInitialize) { if (contactFolderToInitialize != null && contactFolderToInitialize.AdditionalData != null) { if (contactFolderToInitialize.Contacts != null && contactFolderToInitialize.Contacts.CurrentPage != null) { contactFolderToInitialize.Contacts.AdditionalData = contactFolderToInitialize.AdditionalData; object nextPageLink; contactFolderToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { contactFolderToInitialize.Contacts.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (contactFolderToInitialize.ChildFolders != null && contactFolderToInitialize.ChildFolders.CurrentPage != null) { contactFolderToInitialize.ChildFolders.AdditionalData = contactFolderToInitialize.AdditionalData; object nextPageLink; contactFolderToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { contactFolderToInitialize.ChildFolders.InitializeNextPageRequest( this.Client, nextPageLinkString); } } } }
/// <summary> /// Creates the specified ContactFolder using POST. /// </summary> /// <param name="contactFolderToCreate">The ContactFolder to create.</param> /// <returns>The created ContactFolder.</returns> public System.Threading.Tasks.Task <ContactFolder> CreateAsync(ContactFolder contactFolderToCreate) { return(this.CreateAsync(contactFolderToCreate, CancellationToken.None)); }
/// <summary> /// Adds the specified ContactFolder to the collection via POST. /// </summary> /// <param name="contactFolder">The ContactFolder to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created ContactFolder.</returns> public System.Threading.Tasks.Task <ContactFolder> AddAsync(ContactFolder contactFolder, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; return(this.SendAsync <ContactFolder>(contactFolder, cancellationToken)); }
/// <summary> /// Adds the specified ContactFolder to the collection via POST. /// </summary> /// <param name="contactFolder">The ContactFolder to add.</param> /// <returns>The created ContactFolder.</returns> public System.Threading.Tasks.Task <ContactFolder> AddAsync(ContactFolder contactFolder) { return(this.AddAsync(contactFolder, CancellationToken.None)); }
/// <summary> /// Creates the specified ContactFolder using PUT. /// </summary> /// <param name="contactFolderToCreate">The ContactFolder to create.</param> /// <returns>The created ContactFolder.</returns> public Task <ContactFolder> CreateAsync(ContactFolder contactFolderToCreate) { return(this.CreateAsync(contactFolderToCreate, CancellationToken.None)); }
/// <summary> /// Adds the specified ContactFolder to the collection via POST. /// </summary> /// <param name="contactFolder">The ContactFolder to add.</param> /// <returns>The created ContactFolder.</returns> public Task <ContactFolder> AddAsync(ContactFolder contactFolder) { return(this.AddAsync(contactFolder, CancellationToken.None)); }