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