/// <summary> /// Creates a new application consent. /// </summary> /// <param name="newEntity">The new application consent to be created.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>The customer information that was just created.</returns> public async Task <ApplicationConsent> CreateAsync(ApplicationConsent newEntity, CancellationToken cancellationToken = default) { newEntity.AssertNotNull(nameof(newEntity)); return(await Partner.ServiceClient.PostAsync <ApplicationConsent, ApplicationConsent>( new Uri( string.Format( CultureInfo.InvariantCulture, $"/{PartnerService.Instance.ApiVersion}/{PartnerService.Instance.Configuration.Apis.CreateCustomerApplicationConsent.Path}", Context), UriKind.Relative), newEntity, cancellationToken).ConfigureAwait(false)); }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { ApplicationConsent consent = new ApplicationConsent { ApplicationId = ApplicationId, DisplayName = DisplayName }; consent.ApplicationGrants.AddRange(ApplicationGrants); consent = Partner.Customers[CustomerId].ApplicationConsents.CreateAsync(consent).GetAwaiter().GetResult(); WriteObject(consent); }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { Scheduler.RunTask(async() => { IPartner partner = await PartnerSession.Instance.ClientFactory.CreatePartnerOperationsAsync(CorrelationId, CancellationToken).ConfigureAwait(false); ApplicationConsent consent = new ApplicationConsent { ApplicationId = ApplicationId, DisplayName = DisplayName }; consent.ApplicationGrants.AddRange(ApplicationGrants); consent = await partner.Customers[CustomerId].ApplicationConsents.CreateAsync(consent, CancellationToken).ConfigureAwait(false); WriteObject(consent); }, true); }