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