Ejemplo n.º 1
0
        /// <summary>
        /// Excluir Cupom de Assinatura - Delete Signature Coupon
        /// </summary>
        /// <param name="code">Código da Assinatura</param>
        /// <returns></returns>
        public async Task <CouponResponse> DeleteSignatureCoupon(string code)
        {
            HttpRequestMessage httpRequest = new HttpRequestMessage(HttpMethod.Delete, ClientInstance.BaseAddress + $"assinaturas/v1/subscriptions/{code}/coupon")
            {
                Content = new StringContent(string.Empty, Encoding.UTF8, "application/json")
            };
            HttpResponseMessage response = await ClientInstance.SendAsync(httpRequest);

            if (!response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();

                WirecardException.WirecardError wirecardException = WirecardException.DeserializeObject(content);
                throw new WirecardException(wirecardException, "HTTP Response Not Success", content, (int)response.StatusCode);
            }
            try
            {
                return(JsonConvert.DeserializeObject <CouponResponse>(await response.Content.ReadAsStringAsync()));
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }