public void ConsigoAssinarPessoaFisica() { var dto = new AssinaturaDTO { Nome = "Cliente Teste", Documento = "638.783.352-37", TipoPessoa = TipoPessoa.Fisica, Email = "*****@*****.**", Usuario = new UsuarioDTO() { Nome = "Cliente Teste", Email = "*****@*****.**", Senha = "Teste123." }, Endereco = new EnderecoDTO { CEP = "89110000", Bairro = "Teste", Logradouro = "Teste", Numero = "10" }, Telefones = new List<TelefoneDTO> { new TelefoneDTO { Tipo = TipoTelefone.Residencial, Numero = "(47)33331234" } }, }; var api = new AssinaturaAPI(Ambiente.Homologacao); try { var retorno = api.Assinar(dto); Assert.IsNotNull(retorno); Assert.IsTrue(retorno.Id > 0); Assert.IsTrue(!string.IsNullOrWhiteSpace(retorno.Token)); } catch (Exception) { throw; } }
public RetornoAssinaturaDTO Assinar(AssinaturaDTO assinatura) { var url = URLsBase.ASSINATURA; var httpFactory = new HttpFactory(_ambiente); using (var client = httpFactory.GetHttpClient()) { var response = httpFactory.PostAsync(client, url, assinatura).Result; if (!response.IsSuccessStatusCode) { throw new Exception(response.Content.ReadAsStringAsync().Result); } return response.Content.ReadAsAsync<RetornoAssinaturaDTO>().Result; } }