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