Added more fields and license headers.

This commit is contained in:
Mark Nellemann 2019-08-19 10:00:01 +02:00
parent f17262c851
commit 52f569cf68
16 changed files with 3187 additions and 49 deletions

View File

@ -3,13 +3,14 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
} }
} }
apply plugin: "idea" apply plugin: "idea"
apply plugin: "java" apply plugin: "java"
apply plugin: "groovy" apply plugin: "groovy"
apply plugin: 'maven'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray' apply plugin: 'com.jfrog.bintray'

View File

@ -1,6 +1,6 @@
id = libcvrapi id = libcvrapi
group = biz.nellemann.libs group = biz.nellemann.libs
version = 1.0.0 version = 1.0.1
licenses = ['APACHE-2.0'] // or something else licenses = ['APACHE-2.0'] // or something else
groovyVersion = 2.5.8 groovyVersion = 2.5.8
slf4jVersion = 1.7.25 slf4jVersion = 1.7.25

View File

@ -1,3 +1,22 @@
/*
* 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; package biz.nellemann.libcvrapi;
public class Address { public class Address {

View File

@ -0,0 +1,29 @@
/*
* 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 Capital {
String capital;
String currency;
Boolean partial;
Boolean ipo;
}

View File

@ -1,28 +1,52 @@
/* /*
* To change this license header, choose License Headers in Project Properties. * Licensed to the Apache Software Foundation (ASF) under one
* To change this template file, choose Tools | Templates * or more contributor license agreements. See the NOTICE file
* and open the template in the editor. * 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; package biz.nellemann.libcvrapi;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
/**
*
* @author mark
*/
public class Company { public class Company {
BigDecimal vat; BigDecimal vat;
Life life; Life life;
Address address; Address address;
Contact contact; Contact contact;
Industrycode industrycode; Industrycode industrycode;
Companyform compantform;
Companystatus companystatus;
Status status;
// companyform // Accounting accounting;
// companystatus // Tax tax;
// contact
// industrycode Capital capital;
Shareholder shareholder;
Info info;
ArrayList<String> secondarynames;
// Ejerkredsen
// List<Participant> participants
// Ejerskab over andre selskaber
// List<Participation> participations
} }

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;
public class Companyform {
String code;
String description;
String longdescription;
Boolean holding;
}

View File

@ -0,0 +1,27 @@
/*
* 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 Companystatus {
String text;
String start;
}

View File

@ -1,3 +1,22 @@
/*
* 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; package biz.nellemann.libcvrapi;
public class Contact { public class Contact {

View File

@ -1,71 +1,80 @@
/* /*
* 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; package biz.nellemann.libcvrapi;
import java.io.IOException;
import com.google.gson.Gson;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import okhttp3.Credentials;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import okhttp3.Credentials;
import com.google.gson.Gson;
public class CvrApi { public class CvrApi {
private final static Logger log = LoggerFactory.getLogger(CvrApi.class); private final static Logger log = LoggerFactory.getLogger(CvrApi.class);
private final OkHttpClient client; private final OkHttpClient client;
private final String userAgent; private final String userAgent;
private final String authenticationToken; private final String authenticationToken;
public CvrApi(String userAgent, String authenticationToken) { public CvrApi(String userAgent, String authenticationToken) {
this.userAgent = userAgent; this.userAgent = userAgent;
this.authenticationToken = authenticationToken; this.authenticationToken = authenticationToken;
client = new OkHttpClient(); client = new OkHttpClient();
} }
private String get(String url) throws IOException, Exception { private String get(String url) throws IOException, Exception {
String credential = Credentials.basic(authenticationToken, ""); String credential = Credentials.basic(authenticationToken, "");
Request request = new Request.Builder() Request request = new Request.Builder().url(url).header("User-Agent", userAgent)
.url(url) .header("Authorization", credential).addHeader("Accept", "application/json;").build();
.header("User-Agent", userAgent)
.header("Authorization", credential)
.addHeader("Accept", "application/json;")
.build();
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
switch(response.code()) { switch (response.code()) {
case 200: case 200:
return response.body().string(); return response.body().string();
case 401: case 401:
throw new Exception("Access denied"); throw new Exception("Access denied");
default: default:
throw new Exception("Unknown error, status code: " + response.code()); throw new Exception("Unknown error, status code: " + response.code());
} }
} }
/** /**
* https://rest.cvrapi.dk/v1/dk/company/vatNumber * https://rest.cvrapi.dk/v1/dk/company/vatNumber
* *
* @param vatNumber * @param vatNumber
* @return * @return
* @throws IOException * @throws IOException
*/ */
protected String getCompanyJson(String vatNumber) throws IOException, Exception { protected String getCompanyJson(String vatNumber) throws IOException, Exception {
String response = get("https://rest.cvrapi.dk/v1/dk/company/"+vatNumber); String response = get("https://rest.cvrapi.dk/v1/dk/company/" + vatNumber);
return response; return response;
} }
/** /**
* Use GSON to deserialize JSON into objects. * Use GSON to deserialize JSON into objects.
@ -74,11 +83,11 @@ public class CvrApi {
* @return * @return
*/ */
protected Company parseJsonIntoCompany(String json) { protected Company parseJsonIntoCompany(String json) {
Company company; Company company;
try { try {
company = new Company(); company = new Company();
company = new Gson().fromJson(json, Company.class); company = new Gson().fromJson(json, Company.class);
} catch (Exception e) { } catch (Exception e) {
log.error("Error deserializing json into Company", e); log.error("Error deserializing json into Company", e);
return null; return null;
@ -86,7 +95,6 @@ public class CvrApi {
return company; return company;
} }
public Company getCompanyByVatNumber(String vatNumber) { public Company getCompanyByVatNumber(String vatNumber) {
try { try {
@ -99,7 +107,7 @@ public class CvrApi {
log.error("Other Error", e); log.error("Other Error", e);
return null; return null;
} }
} }
} }

View File

@ -1,3 +1,22 @@
/*
* 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; package biz.nellemann.libcvrapi;
public class Industrycode { public class Industrycode {

View File

@ -0,0 +1,35 @@
/*
* 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 Info {
String articles_of_association;
String purpose;
String bind;
/*
* "modes": { "legislation_money_laundering": false, "social_economic": false,
* "government": false }, "attributes": {
* "management_recognized_as_beneficial_owners": true }, "demerges": null,
* "merges": null, "lei": { "id": "894500WP4D8JDZ88S128" }, "employment": {
* "intervalAmountEmployees": "ANTAL_50_99", "amountEmployeesLow": "50",
* "amountEmployeesHigh": "99", "year": "2019", "month": "2" }
*/
}

View File

@ -1,10 +1,29 @@
/*
* 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; package biz.nellemann.libcvrapi;
public class Life { public class Life {
String start; String start;
String end; String end;
String name; String name;
Boolean adprotected; Boolean adprotected;
} }

View File

@ -0,0 +1,27 @@
/*
* 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 Shareholder {
Boolean below_5_percent;
Boolean isPublic;
}

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 Status {
String code;
String creditcode;
String start;
String end;
Boolean bankrupt;
}

View File

@ -25,6 +25,7 @@ class CvrApiSpec extends Specification {
company != null company != null
company.vat == 25063864 company.vat == 25063864
company.life.name == 'AGILLIC A/S' company.life.name == 'AGILLIC A/S'
company.secondarynames.contains('Wavetech A/S')
} }
} }

File diff suppressed because one or more lines are too long