Added more of the API JSON.

This commit is contained in:
Mark Nellemann 2019-08-19 20:58:01 +02:00
parent 0fc5ebec08
commit 2286658446
13 changed files with 196 additions and 29 deletions

View File

@ -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

View File

@ -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')

View File

@ -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<AccountingDocument> documents;
}

View File

@ -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;
}

View File

@ -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,
*/
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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
}
}