-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dodanie testów jednostkowych + refactoring kodu
- Loading branch information
Showing
18 changed files
with
365 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
TBD | ||
### Changelog | ||
|
||
#### Wersja 1.7.0 | ||
- [x] Refactoring kodu | ||
- [x] Fix i stabilizacja w obrębie funkcji `IsActive` | ||
- [x] Dodanie testów jednostkowych | ||
|
||
#### Wersja 1.1.0 - 1.6.0 | ||
- [x] Wprowadzenie do nuget.org i ustabilizowanie paczki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using REGON.Client.Enums; | ||
using REGON.Client.Models; | ||
|
||
namespace REGON.Client; | ||
|
||
public partial class Client | ||
{ | ||
private async Task<AdvanceReportData> GetAdvanceReportData(LegalForm legalForm, string regon) | ||
{ | ||
switch (legalForm) | ||
{ | ||
case LegalForm.JDG: | ||
case LegalForm.SC: | ||
return await GetReportForPhyisicalPerson(regon); | ||
case LegalForm.SPZOO: | ||
case LegalForm.SA: | ||
case LegalForm.SPZOOSK: | ||
case LegalForm.SJ: | ||
case LegalForm.SKA: | ||
case LegalForm.SK: | ||
return await GetReportForLegalPerson(regon); | ||
case LegalForm.ERROR: | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
private async Task<AdvanceReportData> GetReportForPhyisicalPerson(string regon) | ||
{ | ||
var fullReport = await _httpClient.PobierzPelnyRaportCeidg(regon); | ||
|
||
return new AdvanceReportData | ||
{ | ||
StartDate = ClientHelpers.GetDate(fullReport.Dane.FizDataPowstania), | ||
EndDate = ClientHelpers.GetDate(fullReport.Dane.FizDataZakonczeniaDzialalnosci), | ||
IsSuspended = ClientHelpers.IsHappened(fullReport.Dane.FizDataZawieszeniaDzialalnosci), | ||
PhoneNumber = ClientHelpers.ValueOrNull(fullReport.Dane.FizNumerTelefonu), | ||
WebsiteUrl = ClientHelpers.ValueOrNull(fullReport.Dane.FizAdresStronyinternetowej), | ||
Email = ClientHelpers.ValueOrNull(fullReport.Dane.FizAdresEmail) | ||
}; | ||
} | ||
|
||
private async Task<AdvanceReportData> GetReportForLegalPerson(string regon) | ||
{ | ||
var fullReport = await _httpClient.PobierzPelnyRaportPrawna(regon); | ||
|
||
return new AdvanceReportData | ||
{ | ||
StartDate = ClientHelpers.GetDate(fullReport.Dane.PrawDataPowstania), | ||
EndDate = ClientHelpers.GetDate(fullReport.Dane.PrawDataZakonczeniaDzialalnosci), | ||
IsSuspended = ClientHelpers.IsHappened(fullReport.Dane.PrawDataZawieszeniaDzialalnosci), | ||
PhoneNumber = ClientHelpers.ValueOrNull(fullReport.Dane.PrawNumerTelefonu), | ||
WebsiteUrl = ClientHelpers.ValueOrNull(fullReport.Dane.PrawAdresStronyinternetowej), | ||
Email = ClientHelpers.ValueOrNull(fullReport.Dane.PrawAdresEmail) | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using REGON.Client.Enums; | ||
using REGON.Client.Models; | ||
|
||
namespace REGON.Client; | ||
|
||
public partial class Client | ||
{ | ||
private async Task<PkdModel> GetPkdForPhysicalPerson(string regon) | ||
{ | ||
var pkds = await _httpClient.PobierzPkdFizyczna(regon); | ||
|
||
var result = new PkdModel(); | ||
var pkdList = new List<Pkd>(); | ||
|
||
foreach (var pkd in pkds.Dane) | ||
{ | ||
if (pkd.FizPkdPrzewazajace == 1) | ||
{ | ||
result.MainPkd = new Pkd { Value = pkd.FizPkdKod, Name = pkd.FizPkdNazwa }; | ||
} | ||
|
||
pkdList.Add(new Pkd { Value = pkd.FizPkdKod, Name = pkd.FizPkdNazwa }); | ||
} | ||
|
||
result.RestPkds = pkdList; | ||
|
||
return result; | ||
} | ||
|
||
private async Task<PkdModel> GetPkdForLegalPerson(string regon) | ||
{ | ||
var pkds = await _httpClient.PobierzPKDPrawna(regon); | ||
|
||
var result = new PkdModel(); | ||
var pkdList = new List<Pkd>(); | ||
|
||
foreach (var pkd in pkds.Dane) | ||
{ | ||
if (pkd.PrawPkdPrzewazajace == 1) | ||
{ | ||
result.MainPkd = new Pkd { Value = pkd.PrawPkdKod, Name = pkd.PrawPkdNazwa }; | ||
} | ||
|
||
pkdList.Add(new Pkd { Value = pkd.PrawPkdKod, Name = pkd.PrawPkdNazwa }); | ||
} | ||
|
||
result.RestPkds = pkdList; | ||
|
||
return result; | ||
} | ||
|
||
private async Task<PkdModel> GetPkds(LegalForm legalForm, string regon) | ||
{ | ||
switch (legalForm) | ||
{ | ||
case LegalForm.JDG: | ||
case LegalForm.SC: | ||
return await GetPkdForPhysicalPerson(regon); | ||
case LegalForm.SPZOO: | ||
case LegalForm.SA: | ||
case LegalForm.SPZOOSK: | ||
case LegalForm.SJ: | ||
case LegalForm.SKA: | ||
case LegalForm.SK: | ||
return await GetPkdForLegalPerson(regon); | ||
case LegalForm.ERROR: | ||
default: | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.