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