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