Skip to content

Commit 183038b

Browse files
4ndrej4ndrej
authored andcommitted
Improved documentation.
1 parent 342b247 commit 183038b

File tree

2 files changed

+52
-24
lines changed

2 files changed

+52
-24
lines changed

README.md

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
nameapi-client-java
22
===================
33

4-
Java Client for the NameAPI Web Service at https://www.nameapi.org
4+
Java Client for the NameAPI Web Services at https://www.nameapi.org
55

6-
There are functional tests (in test/functional) that demonstrate how to use this library.
6+
There are functional tests that demonstrate how to use this library.
77

8-
All you need to send requests is your own api key, get it from nameapi.org.
8+
All you need to send requests is your own api key which you can get from nameapi.org.
99

1010
This library requires at least Java 8.
1111

@@ -27,8 +27,13 @@ Or you can download the jar, or check out the source code from this GitHub proje
2727

2828
## Setup code
2929

30-
At first you need one single include, the one to the nameapi service factory:
30+
At first you need some includes, to the context information:
3131

32+
```java
33+
import org.nameapi.ontology5.input.context.Context;
34+
import org.nameapi.ontology5.input.context.ContextBuilder;
35+
import org.nameapi.ontology5.input.context.Priority;
36+
```
3237

3338
You need a Context that explains a bit your working environment, something like:
3439

@@ -41,13 +46,21 @@ Context context = new ContextBuilder()
4146
Then you need an executor and a mode:
4247

4348
```java
49+
import com.optimaize.anythingworks.common.host.Host;
50+
import com.optimaize.anythingworks.common.host.Protocol;
51+
import com.optimaize.command4j.CommandExecutor;
52+
import com.optimaize.command4j.Mode;
53+
import org.nameapi.client.lib.NameApiModeFactory;
54+
import org.nameapi.client.lib.NameApiPortUrlFactory;
55+
import org.nameapi.client.lib.NameApiRemoteExecutors;
56+
4457
CommandExecutor executor = NameApiRemoteExecutors.get();
45-
Mode mode = NameApiModeFactory.withContext(
58+
Mode mode = NameApiModeFactory.withContext(
4659
"your-api-key",
4760
context,
4861
//the default and live server is "api.nameapi.org"
49-
new Host("api.nameapi.org", Protocol.HTTPS), NameApiPortUrlFactory.version5_3())
50-
);
62+
new Host("api.nameapi.org", Protocol.HTTPS), NameApiPortUrlFactory.version5_3()
63+
);
5164
```
5265

5366
Now you're ready to execute commands.
@@ -60,12 +73,12 @@ Now you're ready to execute commands.
6073
This code sends a simple ping to nameapi to test the connection:
6174

6275
```java
76+
import org.nameapi.client.services.system.ping.PingCommand;
77+
6378
PingCommand command = new PingCommand();
6479
executor.execute(command, mode, null).get(); //returns "pong"
6580
```
6681

67-
68-
6982
## Input / Output
7083

7184
All input objects come with builders or nicely documented setters.
@@ -88,12 +101,16 @@ and is very convenient in accepting the data however you have it at hands.
88101
Creating a simple person looks something like this:
89102

90103
```java
104+
import org.nameapi.ontology5.input.entities.person.InputPerson;
105+
import org.nameapi.ontology5.input.entities.person.NaturalInputPersonBuilder;
106+
import org.nameapi.ontology5.input.entities.person.name.InputPersonName;
107+
import org.nameapi.ontology5.input.entities.person.name.builder.NameBuilders;
108+
91109
InputPersonName name = NameBuilders.western().fullname("John F. Kennedy").build();
92110
InputPerson inputPerson = new NaturalInputPersonBuilder().name(name).build();
93111
```
94112

95113

96-
97114
## Commands
98115

99116
The web service methods are implemented as commands. This brings the advantage that the
@@ -111,6 +128,9 @@ Name parsing is the process of splitting a full name into its components.
111128
Using the objects created earlier:
112129

113130
```java
131+
import org.nameapi.client.services.parser.personnameparser.PersonNameParserCommand;
132+
import org.nameapi.ontology5.services.parser.personnameparser.PersonNameParserResult;
133+
114134
PersonNameParserCommand command = new PersonNameParserCommand();
115135
PersonNameParserResult result = executor.execute(command, mode, inputPerson).get();
116136
```
@@ -123,6 +143,9 @@ Name genderizing is the process of identifying the gender based on a person's na
123143
Using the objects created earlier:
124144

125145
```java
146+
import org.nameapi.client.services.genderizer.persongenderizer.PersonGenderizerCommand;
147+
import org.nameapi.ontology5.services.genderizer.GenderizerResult;
148+
126149
PersonGenderizerCommand command = new PersonGenderizerCommand();
127150
GenderizerResult result = executor.execute(command, mode, inputPerson).get();
128151
```
@@ -135,6 +158,12 @@ The Name Matcher compares names and name pairs to discover whether the people co
135158
This service takes 2 people as input:
136159

137160
```java
161+
import org.nameapi.client.services.matcher.personmatcher.PersonMatcherArgument;
162+
import org.nameapi.client.services.matcher.personmatcher.PersonMatcherCommand;
163+
import org.nameapi.ontology5.input.entities.person.NaturalInputPerson;
164+
import org.nameapi.ontology5.input.entities.person.NaturalInputPersonBuilder;
165+
import org.nameapi.ontology5.services.matcher.personmatcher.PersonMatcherResult;
166+
138167
PersonMatcherCommand command = new PersonMatcherCommand();
139168
NaturalInputPerson person1 = new NaturalInputPersonBuilder().name( NameBuilders.western().fullname("John F. Kennedy").build() ).build();
140169
NaturalInputPerson person2 = new NaturalInputPersonBuilder().name( NameBuilders.western().fullname("Jack Kennedy").build() ).build();
@@ -148,6 +177,13 @@ PersonMatcherCommand command = new PersonMatcherCommand();
148177
The Name Formatter displays personal names in the desired form. This includes the order as well as upper and lower case writing.
149178

150179
```java
180+
import org.nameapi.client.services.formatter.personnameformatter.PersonNameFormatterArgument;
181+
import org.nameapi.client.services.formatter.personnameformatter.PersonNameFormatterCommand;
182+
import org.nameapi.ontology5.input.entities.person.NaturalInputPerson;
183+
import org.nameapi.ontology5.input.entities.person.NaturalInputPersonBuilder;
184+
import org.nameapi.ontology5.services.formatter.FormatterProperties;
185+
import org.nameapi.ontology5.services.formatter.FormatterResult;
186+
151187
PersonNameFormatterCommand command = new PersonNameFormatterCommand();
152188
NaturalInputPerson person = new NaturalInputPersonBuilder().name( NameBuilders.western().fullname("john f. kennedy").build() ).build();
153189
FormatterProperties properties = new FormatterProperties(true);
@@ -161,6 +197,9 @@ PersonNameFormatterCommand command = new PersonNameFormatterCommand();
161197
The Email Name Parser extracts names out of email addresses.
162198

163199
```java
200+
import org.nameapi.client.services.email.emailnameparser.EmailNameParserCommand;
201+
import org.nameapi.ontology5.services.email.emailnameparser.EmailNameParserResult;
202+
164203
EmailNameParserCommand command = new EmailNameParserCommand();
165204
EmailNameParserResult result = executor.execute(command, mode, "[email protected]").get();
166205
```
@@ -171,6 +210,9 @@ EmailNameParserCommand command = new EmailNameParserCommand();
171210
The DEA-Detector checks email addresses against a list of known "trash domains" such as mailinator.com.
172211

173212
```java
213+
import org.nameapi.client.services.email.disposableemailaddressdetector.DisposableEmailAddressDetectorCommand;
214+
import org.nameapi.ontology5.services.email.disposableemailaddressdetector.DisposableEmailAddressDetectorResult;
215+
174216
DisposableEmailAddressDetectorCommand command = new DisposableEmailAddressDetectorCommand();
175217
DisposableEmailAddressDetectorResult result = executor.execute(command, mode, "[email protected]").get();
176218
```

pom.xml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,8 @@
4444
<ontology.version>5.3.4</ontology.version>
4545
<swagger-annotations-version>1.5.4</swagger-annotations-version>
4646
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
47-
<repo-base-url>https://artif4ctory.optimaize.com</repo-base-url>
4847
</properties>
4948

50-
<repositories>
51-
<repository>
52-
<id>optimaize-release</id>
53-
<url>${repo-base-url}/artifactory/libs-release-local</url>
54-
<releases><enabled>true</enabled></releases>
55-
</repository>
56-
<repository>
57-
<id>optimaize-snapshot</id>
58-
<url>${repo-base-url}/artifactory/libs-snapshot-local</url>
59-
<snapshots><enabled>true</enabled></snapshots>
60-
</repository>
61-
</repositories>
62-
6349
<build>
6450
<resources>
6551
<resource><!-- this is default, but because we tamper with the resources, we need to explicitly mention it. -->

0 commit comments

Comments
 (0)