diff --git a/gradle.properties b/gradle.properties index 81429ee..ac916c8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ id = libcvrapi group = biz.nellemann.libs -version = 1.0.4 -licenses = ['APACHE-2.0'] // or something else +version = 1.0.6 +licenses = ['APACHE-2.0'] // or something else groovyVersion = 2.5.8 slf4jVersion = 1.7.28 spockVersion = 1.3-groovy-2.5 diff --git a/src/main/java/biz/nellemann/libcvrapi/CvrApi.java b/src/main/java/biz/nellemann/libcvrapi/CvrApi.java index ed6c43a..c6001b9 100644 --- a/src/main/java/biz/nellemann/libcvrapi/CvrApi.java +++ b/src/main/java/biz/nellemann/libcvrapi/CvrApi.java @@ -94,7 +94,7 @@ public class CvrApi { */ protected String getCompanyJson(String vatNumber) throws Exception { String response = get(BASE_URL + "/company/" + vatNumber); - log.debug("getCompanyJson() response: {}", response); + log.info("getCompanyJson() response: {}", response); return response; } diff --git a/src/main/java/biz/nellemann/libcvrapi/pojo/AccountingDocumentSummary.java b/src/main/java/biz/nellemann/libcvrapi/pojo/AccountingDocumentSummary.java index 5d34344..d3e0594 100644 --- a/src/main/java/biz/nellemann/libcvrapi/pojo/AccountingDocumentSummary.java +++ b/src/main/java/biz/nellemann/libcvrapi/pojo/AccountingDocumentSummary.java @@ -20,18 +20,24 @@ package biz.nellemann.libcvrapi.pojo; import java.math.BigDecimal; +import java.math.BigInteger; public class AccountingDocumentSummary { String start; String end; - BigDecimal revenue; - BigDecimal grossprofitloss; - BigDecimal profitloss; - BigDecimal equity; - BigDecimal averagenumberofemployees; + BigInteger revenue; + BigInteger grossprofitloss; + BigInteger profitloss; + BigInteger equity; + BigInteger averagenumberofemployees; + BigInteger profitlossfromordinaryactivitiesbeforetax; + BigInteger assets; + BigDecimal liquidityratio; + BigDecimal solvencyratio; + BigDecimal equityreturn; -/* TODO: Add fields if needed + /* TODO: Add fields if needed "employeebenefitsexpense": "-27446000", "depreciationamortisationexpenseprofitorloss": null, "profitlossfromordinaryoperatingactivities": null, @@ -62,7 +68,7 @@ public class AccountingDocumentSummary { "liquidityratio": null, "solvencyratio": 7.389193752638244, "equityreturn": null, - */ + */ } diff --git a/src/test/groovy/biz/nellemann/libcvrapi/CvrApiSpec.groovy b/src/test/groovy/biz/nellemann/libcvrapi/CvrApiSpec.groovy index 0615f1e..b61d412 100644 --- a/src/test/groovy/biz/nellemann/libcvrapi/CvrApiSpec.groovy +++ b/src/test/groovy/biz/nellemann/libcvrapi/CvrApiSpec.groovy @@ -180,6 +180,23 @@ class CvrApiSpec extends Specification { Exception ex = thrown() } + void "test we can HTTP GET company with CVR 39895692 deserialized into Company"() { + + setup: + def testFile = new File(getClass().getResource('/39895692.json').toURI()) + def testJson = testFile.getText('UTF-8') + mockServer.enqueue(new MockResponse().setBody(testJson)); + HttpUrl baseUrl = mockServer.url("/v1/dk/"); + api = new CvrApi("Test User Agent", "testAuthToken", baseUrl.toString()) + + when: + def company = api.getCompanyByVatNumber("39895692") + + then: + company != null + company.vat == 39895692 + } + // TODO: Test 401, 404, timeouts, gson deserialization errors } diff --git a/src/test/resources/39895692.json b/src/test/resources/39895692.json new file mode 100644 index 0000000..1c882d0 --- /dev/null +++ b/src/test/resources/39895692.json @@ -0,0 +1,86 @@ +{ + "vat": "39895692", + "address": { + "street": "Stamholmen", + "streetcode": "7527", + "numberfrom": "193", + "numberto": null, + "letterfrom": "A", + "letterto": null, + "floor": "1", + "door": "tv", + "zipcode": "2650", + "cityname": "Hvidovre", + "altcityname": null, + "countrycode": "DK", + "coname": "Cabcon A\\/S", + "freetext": null, + "municode": "167", + "muniname": "HVIDOVRE", + "mailbox": null, + "start": "2019-06-16", + "end": null, + "timestamp": "2019-06-17" + }, + "companyform": {"code": "210", "description": "UDL", "longdescription": "Anden udenlandsk virksomhed", "holding": false}, + "companystatus": {"text": "AKTIV", "start": "2018-10-01"}, + "contact": {"email": "jag@cabcon.dk", "www": "http:\\/\\/www.cabcon.dk", "phone": "38760324", "fax": null}, + "status": {"code": null, "creditcode": null, "start": null, "end": null, "bankrupt": false}, + "industrycode": {"code": "465210", "text": "Engroshandel med elektronisk udstyr"}, + "life": {"start": "2018-10-01", "end": null, "name": "Cabcon AS", "adprotected": true}, + "accounting": { + "period": {"start": null, "end": null}, + "first": {"start": null, "end": null}, + "restructuring_period": {"start": null, "end": null}, + "revision": true, "documents": [], "tax": [] + }, + "capital": {"capital": null, "currency": null, "partial": false, "ipo": false}, + "shareholder": {"below_5_percent": false, "public": false}, + "info": { + "articles_of_association": null, + "purpose": null, + "bind": null, + "modes": {"legislation_money_laundering": false, "social_economic": false, "government": false}, + "attributes": [], + "demerges": null, + "merges": null, + "lei": {"id": null}, + "ean": [] + }, + "secondarynames": [], + "industrycodes": [], + "subsidiaries": ["1024011204"], + "employment": [], + "participants": [ + { + "participantnumber": "4007803560", + "address": { + "street": null, + "streetcode": null, + "numberfrom": null, + "numberto": null, + "letterfrom": null, + "letterto": null, + "floor": null, + "door": null, + "zipcode": null, + "cityname": null, + "altcityname": null, + "countrycode": "NO", + "coname": null, + "freetext": "Troll\\u00e5sveien 4", + "municode": null, + "muniname": null, + "mailbox": null, + "start": null, + "end": null, + "timestamp": null, + "unlisted": false + }, + "life": {"name": "Cabcon AS", "profession": null, "deceased": false}, + "participant": true, + "roles": [{"type": "fully_responsible_participant", "life": {"start": "2018-10-01", "end": null, "title": null}}] + } + ], + "participations": [] +}