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()
}
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: "java"
apply plugin: "groovy"
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'

View File

@ -1,6 +1,6 @@
id = libcvrapi
group = biz.nellemann.libs
version = 1.0.0
version = 1.0.1
licenses = ['APACHE-2.0'] // or something else
groovyVersion = 2.5.8
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;
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.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* 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;
import java.util.ArrayList;
/**
*
* @author mark
*/
public class Company {
BigDecimal vat;
Life life;
Address address;
Contact contact;
Industrycode industrycode;
Companyform compantform;
Companystatus companystatus;
Status status;
// companyform
// companystatus
// contact
// industrycode
// Accounting accounting;
// Tax tax;
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;
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;
import java.io.IOException;
import com.google.gson.Gson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import okhttp3.Credentials;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Credentials;
import com.google.gson.Gson;
public class CvrApi {
private final static Logger log = LoggerFactory.getLogger(CvrApi.class);
private final OkHttpClient client;
private final String userAgent;
private final String authenticationToken;
public CvrApi(String userAgent, String authenticationToken) {
this.userAgent = userAgent;
this.authenticationToken = authenticationToken;
client = new OkHttpClient();
}
private String get(String url) throws IOException, Exception {
String credential = Credentials.basic(authenticationToken, "");
Request request = new Request.Builder()
.url(url)
.header("User-Agent", userAgent)
.header("Authorization", credential)
.addHeader("Accept", "application/json;")
.build();
Request request = new Request.Builder().url(url).header("User-Agent", userAgent)
.header("Authorization", credential).addHeader("Accept", "application/json;").build();
Response response = client.newCall(request).execute();
switch(response.code()) {
case 200:
return response.body().string();
case 401:
throw new Exception("Access denied");
default:
throw new Exception("Unknown error, status code: " + response.code());
switch (response.code()) {
case 200:
return response.body().string();
case 401:
throw new Exception("Access denied");
default:
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
* @return
* @throws IOException
*/
protected String getCompanyJson(String vatNumber) throws IOException, Exception {
String response = get("https://rest.cvrapi.dk/v1/dk/company/"+vatNumber);
return response;
String response = get("https://rest.cvrapi.dk/v1/dk/company/" + vatNumber);
return response;
}
/**
* Use GSON to deserialize JSON into objects.
@ -74,11 +83,11 @@ public class CvrApi {
* @return
*/
protected Company parseJsonIntoCompany(String json) {
Company company;
try {
company = new Company();
company = new Gson().fromJson(json, Company.class);
company = new Gson().fromJson(json, Company.class);
} catch (Exception e) {
log.error("Error deserializing json into Company", e);
return null;
@ -86,7 +95,6 @@ public class CvrApi {
return company;
}
public Company getCompanyByVatNumber(String vatNumber) {
try {
@ -99,7 +107,7 @@ public class CvrApi {
log.error("Other Error", e);
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;
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;
public class Life {
public class Life {
String start;
String end;
String name;
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.vat == 25063864
company.life.name == 'AGILLIC A/S'
company.secondarynames.contains('Wavetech A/S')
}
}

File diff suppressed because one or more lines are too long