diff --git a/Faturas/Fatura.cs b/Faturas/Fatura.cs index 6bead12..4291864 100644 --- a/Faturas/Fatura.cs +++ b/Faturas/Fatura.cs @@ -54,7 +54,30 @@ namespace Faturas Agrupada_children = faturaParsed.GetProperty("children").EnumerateArray(); } } + public Fatura(string id, string fatura_path, HttpClient httpClient) + { + // Utilizado para gerar novo token + // this.token = Req_token(HttpClient).ToString(); + HttpResponseMessage fatura_response = GetStatus(httpClient, Token, id); + if (fatura_response.IsSuccessStatusCode) + { + faturaParsed = JsonDocument.Parse(fatura_response.Content.ReadAsStringAsync().Result).RootElement; + Agrupada = faturaParsed.TryGetProperty("multiple", out var _); + Status = faturaParsed.GetProperty("status").GetString(); + Arquivo = new FileInfo(fatura_path); + this.id = id; + if (faturaParsed.GetProperty("external").GetString() is not null) + { + pagina = JsonDocument.Parse(faturaParsed.GetProperty("external").GetString()!).RootElement.GetProperty("origin")[0].GetProperty("page").GetInt32(); + } + + if (Agrupada) + { + Agrupada_children = faturaParsed.GetProperty("children").EnumerateArray(); + } + } + } /// /// Initializes a new instance of the class. /// Inicializa uma nova instância da classe para faturas já processadas.