/// <summary>
        ///     Revoke an existing endpoint.
        /// </summary>
        /// <param name="revokeParameters">The parameters for the revoke process.</param>
        /// <param name="privateKey">The private key.</param>
        /// <exception cref="RevokeException">Will be thrown if the revoking was not successful.</exception>
        public void Revoke(RevokeParameters revokeParameters, string privateKey)
        {
            var revokeRequest = new RevokeRequest
            {
                AccountId    = revokeParameters.AccountId,
                EndpointIds  = revokeParameters.EndpointIds,
                TimeZone     = UtcDataService.TimeZone,
                UtcTimestamp = UtcDataService.Now
            };

            var requestBody = JsonConvert.SerializeObject(revokeRequest);

            var httpRequestMessage = new HttpRequestMessage
            {
                Method     = HttpMethod.Delete,
                RequestUri = new Uri(_environment.RevokeUrl()),
                Content    = new StringContent(requestBody, Encoding.UTF8, "application/json")
            };

            httpRequestMessage.Headers.Add("X-Agrirouter-ApplicationId", revokeParameters.ApplicationId);
            httpRequestMessage.Headers.Add("X-Agrirouter-Signature",
                                           SignatureService.XAgrirouterSignature(requestBody, privateKey));

            var httpResponseMessage = _httpClient.SendAsync(httpRequestMessage).Result;

            if (!httpResponseMessage.IsSuccessStatusCode)
            {
                throw new RevokeException(httpResponseMessage.StatusCode,
                                          httpResponseMessage.Content.ReadAsStringAsync().Result);
            }
        }
        public void GivenNonExistingEndpointWhenRevokingThenTheEndpointShouldBeRevoked()
        {
            var revokeParameters = new RevokeParameters
            {
                AccountId   = AccountId,
                EndpointIds = new List <string> {
                    Guid.NewGuid().ToString()
                },
                ApplicationId = ApplicationId
            };

            var revokeService = new RevokeService(Environment, HttpClient);

            Assert.Throws <RevokeException>(() => revokeService.Revoke(revokeParameters, PrivateKey));
        }
        public void GivenExistingEndpointWhenRevokingThenTheEndpointShouldBeRevoked()
        {
            var revokeParameters = new RevokeParameters
            {
                AccountId   = AccountId,
                EndpointIds = new List <string> {
                    EndpointId
                },
                ApplicationId = ApplicationId
            };

            var revokeService = new RevokeService(Environment, HttpClient);

            revokeService.Revoke(revokeParameters, PrivateKey);
        }