/// <summary>
 /// Adds the specified AccessPackageResourceScope to the collection via POST.
 /// </summary>
 /// <param name="accessPackageResourceScope">The AccessPackageResourceScope to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created AccessPackageResourceScope.</returns>
 public System.Threading.Tasks.Task <AccessPackageResourceScope> AddAsync(AccessPackageResourceScope accessPackageResourceScope, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <AccessPackageResourceScope>(accessPackageResourceScope, cancellationToken));
 }
 /// <summary>
 /// Adds the specified AccessPackageResourceScope to the collection via POST.
 /// </summary>
 /// <param name="accessPackageResourceScope">The AccessPackageResourceScope to add.</param>
 /// <returns>The created AccessPackageResourceScope.</returns>
 public System.Threading.Tasks.Task <AccessPackageResourceScope> AddAsync(AccessPackageResourceScope accessPackageResourceScope)
 {
     return(this.AddAsync(accessPackageResourceScope, CancellationToken.None));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="accessPackageResourceScopeToInitialize">The <see cref="AccessPackageResourceScope"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(AccessPackageResourceScope accessPackageResourceScopeToInitialize)
 {
 }
        /// <summary>
        /// Creates the specified AccessPackageResourceScope using POST.
        /// </summary>
        /// <param name="accessPackageResourceScopeToCreate">The AccessPackageResourceScope to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created AccessPackageResourceScope.</returns>
        public async System.Threading.Tasks.Task <AccessPackageResourceScope> CreateAsync(AccessPackageResourceScope accessPackageResourceScopeToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <AccessPackageResourceScope>(accessPackageResourceScopeToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
        /// <summary>
        /// Updates the specified AccessPackageResourceScope using PATCH.
        /// </summary>
        /// <param name="accessPackageResourceScopeToUpdate">The AccessPackageResourceScope 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 AccessPackageResourceScope.</returns>
        public async System.Threading.Tasks.Task <AccessPackageResourceScope> UpdateAsync(AccessPackageResourceScope accessPackageResourceScopeToUpdate, CancellationToken cancellationToken)
        {
            if (accessPackageResourceScopeToUpdate.AdditionalData != null)
            {
                if (accessPackageResourceScopeToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    accessPackageResourceScopeToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, accessPackageResourceScopeToUpdate.GetType().Name)
                    });
                }
            }
            if (accessPackageResourceScopeToUpdate.AdditionalData != null)
            {
                if (accessPackageResourceScopeToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    accessPackageResourceScopeToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, accessPackageResourceScopeToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <AccessPackageResourceScope>(accessPackageResourceScopeToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }