Exemplo n.º 1
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="appConsentRequestObjectToInitialize">The <see cref="AppConsentRequestObject"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(AppConsentRequestObject appConsentRequestObjectToInitialize)
        {
            if (appConsentRequestObjectToInitialize != null && appConsentRequestObjectToInitialize.AdditionalData != null)
            {
                if (appConsentRequestObjectToInitialize.UserConsentRequests != null && appConsentRequestObjectToInitialize.UserConsentRequests.CurrentPage != null)
                {
                    appConsentRequestObjectToInitialize.UserConsentRequests.AdditionalData = appConsentRequestObjectToInitialize.AdditionalData;

                    object nextPageLink;
                    appConsentRequestObjectToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        appConsentRequestObjectToInitialize.UserConsentRequests.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Adds the specified AppConsentRequestObject to the collection via POST.
 /// </summary>
 /// <param name="appConsentRequest">The AppConsentRequestObject to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created AppConsentRequestObject.</returns>
 public System.Threading.Tasks.Task <AppConsentRequestObject> AddAsync(AppConsentRequestObject appConsentRequest, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <AppConsentRequestObject>(appConsentRequest, cancellationToken));
 }
 /// <summary>
 /// Adds the specified AppConsentRequestObject to the collection via POST.
 /// </summary>
 /// <param name="appConsentRequest">The AppConsentRequestObject to add.</param>
 /// <returns>The created AppConsentRequestObject.</returns>
 public System.Threading.Tasks.Task <AppConsentRequestObject> AddAsync(AppConsentRequestObject appConsentRequest)
 {
     return(this.AddAsync(appConsentRequest, CancellationToken.None));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Creates the specified AppConsentRequestObject using POST.
        /// </summary>
        /// <param name="appConsentRequestObjectToCreate">The AppConsentRequestObject to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created AppConsentRequestObject.</returns>
        public async System.Threading.Tasks.Task <AppConsentRequestObject> CreateAsync(AppConsentRequestObject appConsentRequestObjectToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <AppConsentRequestObject>(appConsentRequestObjectToCreate, cancellationToken).ConfigureAwait(false);

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

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