@@ -34,7 +34,6 @@ You need a Context that explains a bit your working environment, something like:
3434
3535``` java
3636Context context = new ContextBuilder ()
37- .apiKey(" your-api-key" )
3837 .priority(Priority . REALTIME )
3938 .build();
4039```
@@ -43,7 +42,13 @@ Then you need an executor and a mode:
4342
4443``` java
4544CommandExecutor executor = NameApiRemoteExecutors . get();
46- Mode mode = NameApiModeFactory . minimal(context);
45+ Mode mode = NameApiModeFactory . withContext(
46+ " your-api-key" ,
47+ context,
48+ // the default and live server is "api.nameapi.org"
49+ // we're using the latest release candidate with latest features here:
50+ new Host (" rc50-api.nameapi.org" , 80 ), NameApiPortUrlFactory . versionLatestStable()
51+ );
4752```
4853
4954Now you're ready to execute commands.
@@ -56,8 +61,8 @@ Now you're ready to execute commands.
5661This code sends a simple ping to nameapi to test the connection:
5762
5863``` java
59- PingerCommand command = new PingerCommand ();
60- executor. execute(command, mode, null ). get(). getPong() ; // returns "pong"
64+ PingCommand command = new PingCommand ();
65+ executor. execute(command, mode, null ). get(); // returns "pong"
6166```
6267
6368
@@ -119,7 +124,7 @@ Using the objects created earlier:
119124
120125``` java
121126PersonGenderizerCommand command = new PersonGenderizerCommand ();
122- PersonGenderizerResult result = executor. execute(command, mode, inputPerson). get();
127+ GenderizerResult result = executor. execute(command, mode, inputPerson). get();
123128```
124129
125130
@@ -145,7 +150,7 @@ The Name Formatter displays personal names in the desired form. This includes th
145150``` java
146151PersonNameFormatterCommand command = new PersonNameFormatterCommand ();
147152NaturalInputPerson person = new NaturalInputPersonBuilder (). name( NameBuilders . western(). fullname(" john f. kennedy" ). build() ). build();
148- FormatterProperties properties = new FormatterPropertiesBuilder () . build( );
153+ FormatterProperties properties = new FormatterProperties ( true );
149154PersonNameFormatterArgument argument = new PersonNameFormatterArgument (person, properties);
150155FormatterResult formatterResult = executor. execute(command, mode, argument). get();
151156```
@@ -167,7 +172,7 @@ The DEA-Detector checks email addresses against a list of known "trash domains"
167172
168173``` java
169174DisposableEmailAddressDetectorCommand command = new DisposableEmailAddressDetectorCommand ();
170- DisposableEmailAddressDetectorResult result
= executor
. execute(command, mode,
" [email protected] " );
175+ DisposableEmailAddressDetectorResult result
= executor
. execute(command, mode,
" [email protected] " )
. get() ;
171176```
172177
173178
0 commit comments