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