From 22866584460dc93a4eb3889822328049abc3aac2 Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Mon, 19 Aug 2019 20:58:01 +0200 Subject: [PATCH] Added more of the API JSON. --- README.md | 6 +- build.gradle | 13 +++- .../biz/nellemann/libcvrapi/Accounting.java | 28 ++++++++ .../libcvrapi/AccountingDocument.java | 32 +++++++++ .../libcvrapi/AccountingDocumentSummary.java | 68 +++++++++++++++++++ .../java/biz/nellemann/libcvrapi/Company.java | 6 +- .../biz/nellemann/libcvrapi/Companyform.java | 4 +- .../java/biz/nellemann/libcvrapi/CvrApi.java | 20 ++---- .../biz/nellemann/libcvrapi/Industrycode.java | 6 +- .../java/biz/nellemann/libcvrapi/Info.java | 4 +- .../nellemann/libcvrapi/InfoEmployment.java | 30 ++++++++ .../java/biz/nellemann/libcvrapi/Status.java | 4 +- .../biz/nellemann/libcvrapi/CvrApiSpec.groovy | 4 +- 13 files changed, 196 insertions(+), 29 deletions(-) create mode 100644 src/main/java/biz/nellemann/libcvrapi/Accounting.java create mode 100644 src/main/java/biz/nellemann/libcvrapi/AccountingDocument.java create mode 100644 src/main/java/biz/nellemann/libcvrapi/AccountingDocumentSummary.java create mode 100644 src/main/java/biz/nellemann/libcvrapi/InfoEmployment.java diff --git a/README.md b/README.md index d3c1b93..c30cc95 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ The *Company* represents most of the same properties as seen in the example JSON ### Gradle repositories { - maven { url 'https://dl.bintray.com/mnellemann/libs' } + maven { url 'https://dl.bintray.com/mnellemann/libs' } } dependencies { - compile 'biz.nellemann.libs:libcvrapi:1.0.0' - runtime "org.slf4j:slf4j-simple:1.7.25" + compile 'biz.nellemann.libs:libcvrapi:1.+' + runtime "org.slf4j:slf4j-simple:1.7.28" } ## Development diff --git a/build.gradle b/build.gradle index 76208cb..3e8b67f 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ repositories { dependencies { implementation("org.slf4j:slf4j-api:${slf4jVersion}") - implementation("org.slf4j:slf4j-simple:${slf4jVersion}") + //implementation("org.slf4j:slf4j-simple:${slf4jVersion}") implementation('com.google.code.gson:gson:2.8.5') implementation("com.squareup.okhttp3:okhttp:4.1.0") @@ -35,6 +35,17 @@ dependencies { } +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } + repositories { + mavenLocal() + } +} + bintray { user = System.getenv('BINTRAY_USER') key = System.getenv('BINTRAY_KEY') diff --git a/src/main/java/biz/nellemann/libcvrapi/Accounting.java b/src/main/java/biz/nellemann/libcvrapi/Accounting.java new file mode 100644 index 0000000..cebd3c7 --- /dev/null +++ b/src/main/java/biz/nellemann/libcvrapi/Accounting.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package biz.nellemann.libcvrapi; + +import java.util.List; + +public class Accounting { + + Boolean revision; + List documents; +} diff --git a/src/main/java/biz/nellemann/libcvrapi/AccountingDocument.java b/src/main/java/biz/nellemann/libcvrapi/AccountingDocument.java new file mode 100644 index 0000000..1968530 --- /dev/null +++ b/src/main/java/biz/nellemann/libcvrapi/AccountingDocument.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package biz.nellemann.libcvrapi; + +public class AccountingDocument { + + String url; + String type; + String start; + String end; + String publicdate; + String extension; + AccountingDocumentSummary summary; + +} diff --git a/src/main/java/biz/nellemann/libcvrapi/AccountingDocumentSummary.java b/src/main/java/biz/nellemann/libcvrapi/AccountingDocumentSummary.java new file mode 100644 index 0000000..e1b2abe --- /dev/null +++ b/src/main/java/biz/nellemann/libcvrapi/AccountingDocumentSummary.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package biz.nellemann.libcvrapi; + +import java.math.BigDecimal; + +public class AccountingDocumentSummary { + + String start; + String end; + BigDecimal revenue; + BigDecimal grossprofitloss; + BigDecimal profitloss; + BigDecimal equity; + Integer averagenumberofemployees; + +/* TODO: Add fields if needed + "employeebenefitsexpense": "-27446000", + "depreciationamortisationexpenseprofitorloss": null, + "profitlossfromordinaryoperatingactivities": null, + "incomefrominvestmentsingroupenterprises": null, + "otherfinanceincome": null, + "otherfinanceexpenses": null, + "profitlossfromordinaryactivitiesbeforetax": null, + "taxexpenseonordinaryactivities": null, + "taxexpense": null, + "assets": "47380000", + "proposeddividendrecognisedinequity": null, + "proposeddividend": null, + "dividend": null, + "noncurrentassets": "21387000", + "landandbuildings": null, + "currentassets": "25993000", + "inventories": null, + "shorttermtradereceivables": null, + "cashandcashequivalents": "12312000", + "equityloan": null, + "provisions": null, + "longtermliabilitiesotherthanprovisions": null, + "shorttermliabilitiesotherthanprovisions": null, + "liabilitiesandequity": null, + "coverage": null, + "operatingmargin": null, + "roi": null, + "liquidityratio": null, + "solvencyratio": 7.389193752638244, + "equityreturn": null, + */ +} + + diff --git a/src/main/java/biz/nellemann/libcvrapi/Company.java b/src/main/java/biz/nellemann/libcvrapi/Company.java index 97cb086..5f062d8 100644 --- a/src/main/java/biz/nellemann/libcvrapi/Company.java +++ b/src/main/java/biz/nellemann/libcvrapi/Company.java @@ -6,7 +6,7 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, @@ -30,11 +30,11 @@ public class Company { Address address; Contact contact; Industrycode industrycode; - Companyform compantform; + Companyform companyform; Companystatus companystatus; Status status; - // Accounting accounting; + Accounting accounting; // Tax tax; Capital capital; diff --git a/src/main/java/biz/nellemann/libcvrapi/Companyform.java b/src/main/java/biz/nellemann/libcvrapi/Companyform.java index d20017a..0b772e8 100644 --- a/src/main/java/biz/nellemann/libcvrapi/Companyform.java +++ b/src/main/java/biz/nellemann/libcvrapi/Companyform.java @@ -6,7 +6,7 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, @@ -21,7 +21,7 @@ package biz.nellemann.libcvrapi; public class Companyform { - String code; + Integer code; String description; String longdescription; Boolean holding; diff --git a/src/main/java/biz/nellemann/libcvrapi/CvrApi.java b/src/main/java/biz/nellemann/libcvrapi/CvrApi.java index 2cf95a6..67f21fb 100644 --- a/src/main/java/biz/nellemann/libcvrapi/CvrApi.java +++ b/src/main/java/biz/nellemann/libcvrapi/CvrApi.java @@ -6,7 +6,7 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, @@ -23,6 +23,7 @@ import java.io.IOException; import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,7 +67,7 @@ public class CvrApi { /** * https://rest.cvrapi.dk/v1/dk/company/vatNumber - * + * * @param vatNumber * @return * @throws IOException @@ -78,20 +79,13 @@ public class CvrApi { /** * Use GSON to deserialize JSON into objects. - * + * * @param json * @return */ - protected Company parseJsonIntoCompany(String json) { - - Company company; - try { - company = new Company(); - company = new Gson().fromJson(json, Company.class); - } catch (Exception e) { - log.error("Error deserializing json into Company", e); - return null; - } + protected Company parseJsonIntoCompany(String json) throws JsonSyntaxException { + Gson gson = new Gson(); + Company company = gson.fromJson(json, Company.class); return company; } diff --git a/src/main/java/biz/nellemann/libcvrapi/Industrycode.java b/src/main/java/biz/nellemann/libcvrapi/Industrycode.java index 2b4aa5e..fd1b0dc 100644 --- a/src/main/java/biz/nellemann/libcvrapi/Industrycode.java +++ b/src/main/java/biz/nellemann/libcvrapi/Industrycode.java @@ -6,7 +6,7 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, @@ -21,7 +21,7 @@ package biz.nellemann.libcvrapi; public class Industrycode { - String code; + Integer code; String text; - + } diff --git a/src/main/java/biz/nellemann/libcvrapi/Info.java b/src/main/java/biz/nellemann/libcvrapi/Info.java index 4c95d91..84428e5 100644 --- a/src/main/java/biz/nellemann/libcvrapi/Info.java +++ b/src/main/java/biz/nellemann/libcvrapi/Info.java @@ -6,7 +6,7 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, @@ -32,4 +32,6 @@ public class Info { * "intervalAmountEmployees": "ANTAL_50_99", "amountEmployeesLow": "50", * "amountEmployeesHigh": "99", "year": "2019", "month": "2" } */ + + InfoEmployment employment; } diff --git a/src/main/java/biz/nellemann/libcvrapi/InfoEmployment.java b/src/main/java/biz/nellemann/libcvrapi/InfoEmployment.java new file mode 100644 index 0000000..bcd4d19 --- /dev/null +++ b/src/main/java/biz/nellemann/libcvrapi/InfoEmployment.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package biz.nellemann.libcvrapi; + +public class InfoEmployment { + + String intervalAmountEmployees; + Integer amountEmployeesLow; + Integer amountEmployeesHigh; + Integer year; + Integer month; + +} diff --git a/src/main/java/biz/nellemann/libcvrapi/Status.java b/src/main/java/biz/nellemann/libcvrapi/Status.java index 3a3ef76..781369d 100644 --- a/src/main/java/biz/nellemann/libcvrapi/Status.java +++ b/src/main/java/biz/nellemann/libcvrapi/Status.java @@ -6,7 +6,7 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, @@ -21,7 +21,7 @@ package biz.nellemann.libcvrapi; public class Status { - String code; + Integer code; String creditcode; String start; String end; diff --git a/src/test/groovy/biz/nellemann/libcvrapi/CvrApiSpec.groovy b/src/test/groovy/biz/nellemann/libcvrapi/CvrApiSpec.groovy index c6d0e42..6329d55 100644 --- a/src/test/groovy/biz/nellemann/libcvrapi/CvrApiSpec.groovy +++ b/src/test/groovy/biz/nellemann/libcvrapi/CvrApiSpec.groovy @@ -22,10 +22,12 @@ class CvrApiSpec extends Specification { def company = api.parseJsonIntoCompany(testJson) then: - company != null + company != null company.vat == 25063864 company.life.name == 'AGILLIC A/S' company.secondarynames.contains('Wavetech A/S') + company.info.employment.amountEmployeesLow == 50 + company.info.employment.amountEmployeesHigh == 99 } }