forked from loafle/openapi-generator-original
regenerated client
This commit is contained in:
parent
609cef0b65
commit
d56c5e3b44
@ -14,11 +14,7 @@
|
||||
<prerequisites>
|
||||
<maven>2.2.0</maven>
|
||||
</prerequisites>
|
||||
<parent>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
<artifactId>oss-parent</artifactId>
|
||||
<version>5</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@ -37,30 +33,6 @@
|
||||
<forkMode>pertest</forkMode>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
@ -135,6 +107,7 @@
|
||||
<plugin>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>scala-maven-plugin</artifactId>
|
||||
<version>${scala-maven-plugin-version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@ -235,6 +208,7 @@
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<junit-version>4.8.1</junit-version>
|
||||
<scala-test-version>1.6.1</scala-test-version>
|
||||
<scala-maven-plugin-version>3.1.5</scala-maven-plugin-version>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
|
@ -2,9 +2,9 @@ package com.wordnik.client.api;
|
||||
|
||||
import com.wordnik.client.common.ApiException;
|
||||
import com.wordnik.client.common.ApiInvoker;
|
||||
import com.wordnik.client.model.ApiTokenStatus;
|
||||
import com.wordnik.client.model.WordList;
|
||||
import com.wordnik.client.model.User;
|
||||
import com.wordnik.client.model.WordList;
|
||||
import com.wordnik.client.model.ApiTokenStatus;
|
||||
import com.wordnik.client.model.AuthenticationToken;
|
||||
import java.util.*;
|
||||
|
||||
@ -38,8 +38,10 @@ public class AccountApi {
|
||||
}
|
||||
if(!"null".equals(String.valueOf(password)))
|
||||
queryParams.put("password", String.valueOf(password));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (AuthenticationToken) ApiInvoker.deserialize(response, "", AuthenticationToken.class);
|
||||
}
|
||||
@ -67,8 +69,10 @@ public class AccountApi {
|
||||
if(username == null || body == null ) {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (AuthenticationToken) ApiInvoker.deserialize(response, "", AuthenticationToken.class);
|
||||
}
|
||||
@ -101,8 +105,10 @@ public class AccountApi {
|
||||
if(!"null".equals(String.valueOf(limit)))
|
||||
queryParams.put("limit", String.valueOf(limit));
|
||||
headerParams.put("auth_token", auth_token);
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<WordList>) ApiInvoker.deserialize(response, "List", WordList.class);
|
||||
}
|
||||
@ -127,8 +133,10 @@ public class AccountApi {
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
|
||||
headerParams.put("api_key", api_key);
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (ApiTokenStatus) ApiInvoker.deserialize(response, "", ApiTokenStatus.class);
|
||||
}
|
||||
@ -157,8 +165,10 @@ public class AccountApi {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
headerParams.put("auth_token", auth_token);
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (User) ApiInvoker.deserialize(response, "", User.class);
|
||||
}
|
||||
|
@ -2,16 +2,17 @@ package com.wordnik.client.api;
|
||||
|
||||
import com.wordnik.client.common.ApiException;
|
||||
import com.wordnik.client.common.ApiInvoker;
|
||||
import com.wordnik.client.model.Definition;
|
||||
import com.wordnik.client.model.TextPron;
|
||||
import com.wordnik.client.model.Example;
|
||||
import com.wordnik.client.model.Syllable;
|
||||
import com.wordnik.client.model.AudioFile;
|
||||
import com.wordnik.client.model.ExampleSearchResults;
|
||||
import com.wordnik.client.model.WordObject;
|
||||
import com.wordnik.client.model.Bigram;
|
||||
import com.wordnik.client.model.Related;
|
||||
import com.wordnik.client.model.FrequencySummary;
|
||||
import com.wordnik.client.model.Bigram;
|
||||
import com.wordnik.client.model.WordObject;
|
||||
import com.wordnik.client.model.ExampleSearchResults;
|
||||
import com.wordnik.client.model.Example;
|
||||
import com.wordnik.client.model.ScrabbleScoreResult;
|
||||
import com.wordnik.client.model.TextPron;
|
||||
import com.wordnik.client.model.Syllable;
|
||||
import com.wordnik.client.model.Related;
|
||||
import com.wordnik.client.model.Definition;
|
||||
import com.wordnik.client.model.AudioFile;
|
||||
import java.util.*;
|
||||
|
||||
public class WordApi {
|
||||
@ -50,8 +51,10 @@ public class WordApi {
|
||||
queryParams.put("skip", String.valueOf(skip));
|
||||
if(!"null".equals(String.valueOf(limit)))
|
||||
queryParams.put("limit", String.valueOf(limit));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (ExampleSearchResults) ApiInvoker.deserialize(response, "", ExampleSearchResults.class);
|
||||
}
|
||||
@ -83,8 +86,10 @@ public class WordApi {
|
||||
queryParams.put("useCanonical", String.valueOf(useCanonical));
|
||||
if(!"null".equals(String.valueOf(includeSuggestions)))
|
||||
queryParams.put("includeSuggestions", String.valueOf(includeSuggestions));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (WordObject) ApiInvoker.deserialize(response, "", WordObject.class);
|
||||
}
|
||||
@ -124,8 +129,10 @@ public class WordApi {
|
||||
queryParams.put("useCanonical", String.valueOf(useCanonical));
|
||||
if(!"null".equals(String.valueOf(includeTags)))
|
||||
queryParams.put("includeTags", String.valueOf(includeTags));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<Definition>) ApiInvoker.deserialize(response, "List", Definition.class);
|
||||
}
|
||||
@ -155,8 +162,10 @@ public class WordApi {
|
||||
}
|
||||
if(!"null".equals(String.valueOf(useCanonical)))
|
||||
queryParams.put("useCanonical", String.valueOf(useCanonical));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (Example) ApiInvoker.deserialize(response, "", Example.class);
|
||||
}
|
||||
@ -190,8 +199,10 @@ public class WordApi {
|
||||
queryParams.put("relationshipTypes", String.valueOf(relationshipTypes));
|
||||
if(!"null".equals(String.valueOf(limitPerRelationshipType)))
|
||||
queryParams.put("limitPerRelationshipType", String.valueOf(limitPerRelationshipType));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<Related>) ApiInvoker.deserialize(response, "List", Related.class);
|
||||
}
|
||||
@ -227,8 +238,10 @@ public class WordApi {
|
||||
queryParams.put("typeFormat", String.valueOf(typeFormat));
|
||||
if(!"null".equals(String.valueOf(limit)))
|
||||
queryParams.put("limit", String.valueOf(limit));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<TextPron>) ApiInvoker.deserialize(response, "List", TextPron.class);
|
||||
}
|
||||
@ -262,8 +275,10 @@ public class WordApi {
|
||||
queryParams.put("sourceDictionary", String.valueOf(sourceDictionary));
|
||||
if(!"null".equals(String.valueOf(limit)))
|
||||
queryParams.put("limit", String.valueOf(limit));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<Syllable>) ApiInvoker.deserialize(response, "List", Syllable.class);
|
||||
}
|
||||
@ -297,8 +312,10 @@ public class WordApi {
|
||||
queryParams.put("startYear", String.valueOf(startYear));
|
||||
if(!"null".equals(String.valueOf(endYear)))
|
||||
queryParams.put("endYear", String.valueOf(endYear));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (FrequencySummary) ApiInvoker.deserialize(response, "", FrequencySummary.class);
|
||||
}
|
||||
@ -332,8 +349,10 @@ public class WordApi {
|
||||
queryParams.put("wlmi", String.valueOf(wlmi));
|
||||
if(!"null".equals(String.valueOf(useCanonical)))
|
||||
queryParams.put("useCanonical", String.valueOf(useCanonical));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<Bigram>) ApiInvoker.deserialize(response, "List", Bigram.class);
|
||||
}
|
||||
@ -363,8 +382,10 @@ public class WordApi {
|
||||
}
|
||||
if(!"null".equals(String.valueOf(useCanonical)))
|
||||
queryParams.put("useCanonical", String.valueOf(useCanonical));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<String>) ApiInvoker.deserialize(response, "List", String.class);
|
||||
}
|
||||
@ -396,8 +417,10 @@ public class WordApi {
|
||||
queryParams.put("useCanonical", String.valueOf(useCanonical));
|
||||
if(!"null".equals(String.valueOf(limit)))
|
||||
queryParams.put("limit", String.valueOf(limit));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<AudioFile>) ApiInvoker.deserialize(response, "List", AudioFile.class);
|
||||
}
|
||||
@ -413,5 +436,36 @@ public class WordApi {
|
||||
}
|
||||
}
|
||||
}
|
||||
public ScrabbleScoreResult getScrabbleScore (String word) throws ApiException {
|
||||
// create path and map variables
|
||||
String path = "/word.{format}/{word}/scrabbleScore".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word.toString()));
|
||||
|
||||
// query params
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
|
||||
// verify required params are set
|
||||
if(word == null ) {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (ScrabbleScoreResult) ApiInvoker.deserialize(response, "", ScrabbleScoreResult.class);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.getCode() == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,9 @@ package com.wordnik.client.api;
|
||||
|
||||
import com.wordnik.client.common.ApiException;
|
||||
import com.wordnik.client.common.ApiInvoker;
|
||||
import com.wordnik.client.model.WordListWord;
|
||||
import com.wordnik.client.model.WordList;
|
||||
import com.wordnik.client.model.StringValue;
|
||||
import com.wordnik.client.model.WordListWord;
|
||||
import java.util.*;
|
||||
|
||||
public class WordListApi {
|
||||
@ -36,8 +36,10 @@ public class WordListApi {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
headerParams.put("auth_token", auth_token);
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams, contentType);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
@ -66,8 +68,10 @@ public class WordListApi {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
headerParams.put("auth_token", auth_token);
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
@ -96,8 +100,10 @@ public class WordListApi {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
headerParams.put("auth_token", auth_token);
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (WordList) ApiInvoker.deserialize(response, "", WordList.class);
|
||||
}
|
||||
@ -126,8 +132,10 @@ public class WordListApi {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
headerParams.put("auth_token", auth_token);
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
@ -164,8 +172,10 @@ public class WordListApi {
|
||||
if(!"null".equals(String.valueOf(limit)))
|
||||
queryParams.put("limit", String.valueOf(limit));
|
||||
headerParams.put("auth_token", auth_token);
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<WordListWord>) ApiInvoker.deserialize(response, "List", WordListWord.class);
|
||||
}
|
||||
@ -194,8 +204,10 @@ public class WordListApi {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
headerParams.put("auth_token", auth_token);
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
|
@ -34,8 +34,10 @@ public class WordListsApi {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
headerParams.put("auth_token", auth_token);
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (WordList) ApiInvoker.deserialize(response, "", WordList.class);
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package com.wordnik.client.api;
|
||||
|
||||
import com.wordnik.client.common.ApiException;
|
||||
import com.wordnik.client.common.ApiInvoker;
|
||||
import com.wordnik.client.model.WordObject;
|
||||
import com.wordnik.client.model.DefinitionSearchResults;
|
||||
import com.wordnik.client.model.WordObject;
|
||||
import com.wordnik.client.model.WordOfTheDay;
|
||||
import com.wordnik.client.model.WordSearchResults;
|
||||
import java.util.*;
|
||||
@ -58,8 +58,10 @@ public class WordsApi {
|
||||
queryParams.put("skip", String.valueOf(skip));
|
||||
if(!"null".equals(String.valueOf(limit)))
|
||||
queryParams.put("limit", String.valueOf(limit));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (WordSearchResults) ApiInvoker.deserialize(response, "", WordSearchResults.class);
|
||||
}
|
||||
@ -85,8 +87,10 @@ public class WordsApi {
|
||||
|
||||
if(!"null".equals(String.valueOf(date)))
|
||||
queryParams.put("date", String.valueOf(date));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (WordOfTheDay) ApiInvoker.deserialize(response, "", WordOfTheDay.class);
|
||||
}
|
||||
@ -146,8 +150,10 @@ public class WordsApi {
|
||||
queryParams.put("skip", String.valueOf(skip));
|
||||
if(!"null".equals(String.valueOf(limit)))
|
||||
queryParams.put("limit", String.valueOf(limit));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (DefinitionSearchResults) ApiInvoker.deserialize(response, "", DefinitionSearchResults.class);
|
||||
}
|
||||
@ -195,8 +201,10 @@ public class WordsApi {
|
||||
queryParams.put("sortOrder", String.valueOf(sortOrder));
|
||||
if(!"null".equals(String.valueOf(limit)))
|
||||
queryParams.put("limit", String.valueOf(limit));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<WordObject>) ApiInvoker.deserialize(response, "List", WordObject.class);
|
||||
}
|
||||
@ -238,8 +246,10 @@ public class WordsApi {
|
||||
queryParams.put("minLength", String.valueOf(minLength));
|
||||
if(!"null".equals(String.valueOf(maxLength)))
|
||||
queryParams.put("maxLength", String.valueOf(maxLength));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (WordObject) ApiInvoker.deserialize(response, "", WordObject.class);
|
||||
}
|
||||
|
@ -44,9 +44,8 @@ public class ApiInvoker {
|
||||
return response;
|
||||
}
|
||||
else if(String.class.equals(cls)) {
|
||||
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1) {
|
||||
if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1)
|
||||
return json.substring(1, json.length() - 2);
|
||||
}
|
||||
else
|
||||
return json;
|
||||
}
|
||||
@ -61,15 +60,17 @@ public class ApiInvoker {
|
||||
|
||||
public static String serialize(Object obj) throws ApiException {
|
||||
try {
|
||||
if (obj != null) return JsonUtil.getJsonMapper().writeValueAsString(obj);
|
||||
else return null;
|
||||
if (obj != null)
|
||||
return JsonUtil.getJsonMapper().writeValueAsString(obj);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ApiException(500, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams) throws ApiException {
|
||||
public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, String contentType) throws ApiException {
|
||||
Client client = getClient(host);
|
||||
|
||||
StringBuilder b = new StringBuilder();
|
||||
@ -77,14 +78,16 @@ public class ApiInvoker {
|
||||
for(String key : queryParams.keySet()) {
|
||||
String value = queryParams.get(key);
|
||||
if (value != null){
|
||||
if(b.toString().length() == 0) b.append("?");
|
||||
else b.append("&");
|
||||
if(b.toString().length() == 0)
|
||||
b.append("?");
|
||||
else
|
||||
b.append("&");
|
||||
b.append(escapeString(key)).append("=").append(escapeString(value));
|
||||
}
|
||||
}
|
||||
String querystring = b.toString();
|
||||
|
||||
Builder builder = client.resource(host + path + querystring).type("application/json");
|
||||
Builder builder = client.resource(host + path + querystring).accept("application/json");
|
||||
for(String key : headerParams.keySet()) {
|
||||
builder.header(key, headerParams.get(key));
|
||||
}
|
||||
@ -100,13 +103,22 @@ public class ApiInvoker {
|
||||
response = (ClientResponse) builder.get(ClientResponse.class);
|
||||
}
|
||||
else if ("POST".equals(method)) {
|
||||
if(body == null)
|
||||
response = builder.post(ClientResponse.class, serialize(body));
|
||||
else
|
||||
response = builder.type("application/json").post(ClientResponse.class, serialize(body));
|
||||
}
|
||||
else if ("PUT".equals(method)) {
|
||||
response = builder.put(ClientResponse.class, serialize(body));
|
||||
}
|
||||
if(body == null)
|
||||
response = builder.put(ClientResponse.class, serialize(body));
|
||||
else
|
||||
response = builder.type("application/json").put(ClientResponse.class, serialize(body));
|
||||
}
|
||||
else if ("DELETE".equals(method)) {
|
||||
if(body == null)
|
||||
response = builder.delete(ClientResponse.class, serialize(body));
|
||||
else
|
||||
response = builder.type("application/json").delete(ClientResponse.class, serialize(body));
|
||||
}
|
||||
else {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
@ -122,12 +134,12 @@ public class ApiInvoker {
|
||||
}
|
||||
|
||||
private Client getClient(String host) {
|
||||
if(!hostMap.containsKey(host)) {
|
||||
Client client = Client.create();
|
||||
client.addFilter(new LoggingFilter());
|
||||
hostMap.put(host, client);
|
||||
}
|
||||
return hostMap.get(host);
|
||||
if(!hostMap.containsKey(host)) {
|
||||
Client client = Client.create();
|
||||
client.addFilter(new LoggingFilter());
|
||||
hostMap.put(host, client);
|
||||
}
|
||||
return hostMap.get(host);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.wordnik.client.model;
|
||||
|
||||
import java.util.*;
|
||||
import com.wordnik.client.model.ExampleUsage;
|
||||
import com.wordnik.client.model.Note;
|
||||
import com.wordnik.client.model.Citation;
|
||||
import com.wordnik.client.model.TextPron;
|
||||
import com.wordnik.client.model.Label;
|
||||
import com.wordnik.client.model.ExampleUsage;
|
||||
import com.wordnik.client.model.TextPron;
|
||||
import com.wordnik.client.model.Citation;
|
||||
import com.wordnik.client.model.Related;
|
||||
import com.wordnik.client.model.Note;
|
||||
public class Definition {
|
||||
private String extendedText = null;
|
||||
private String text = null;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.wordnik.client.model;
|
||||
|
||||
import com.wordnik.client.model.Sentence;
|
||||
import com.wordnik.client.model.ScoredWord;
|
||||
import com.wordnik.client.model.ContentProvider;
|
||||
import com.wordnik.client.model.ScoredWord;
|
||||
public class Example {
|
||||
private Long id = null;
|
||||
private Long exampleId = null;
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.wordnik.client.model;
|
||||
|
||||
public class ScrabbleScoreResult {
|
||||
private Integer value = null;
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
public void setValue(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ScrabbleScoreResult {\n");
|
||||
sb.append(" value: ").append(value).append("\n");
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package com.wordnik.client.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
import com.wordnik.client.model.SimpleDefinition;
|
||||
import com.wordnik.client.model.SimpleExample;
|
||||
import com.wordnik.client.model.SimpleDefinition;
|
||||
import com.wordnik.client.model.ContentProvider;
|
||||
public class WordOfTheDay {
|
||||
private Long id = null;
|
||||
|
@ -5,16 +5,12 @@
|
||||
<artifactId>swagger-client</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>swagger-client</name>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0</version>
|
||||
<prerequisites>
|
||||
<maven>2.2.0</maven>
|
||||
</prerequisites>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>scala-tools.org</id>
|
||||
<name>Scala-Tools Maven2 Repository</name>
|
||||
<url>http://scala-tools.org/repo-releases</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>maven-mongodb-plugin-repo</id>
|
||||
<name>maven mongodb plugin repository</name>
|
||||
@ -113,9 +109,9 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.scala-tools</groupId>
|
||||
<artifactId>maven-scala-plugin</artifactId>
|
||||
<version>2.15.2</version>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>scala-maven-plugin</artifactId>
|
||||
<version>${scala-maven-plugin-version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>scala-compile-first</id>
|
||||
@ -160,6 +156,12 @@
|
||||
<version>${jersey-version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey.contribs</groupId>
|
||||
<artifactId>jersey-multipart</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scala-lang</groupId>
|
||||
<artifactId>scala-library</artifactId>
|
||||
@ -194,5 +196,7 @@
|
||||
<scala-test-version>1.6.1</scala-test-version>
|
||||
<junit-version>4.8.1</junit-version>
|
||||
<scala-test-version>1.6.1</scala-test-version>
|
||||
<scala-maven-plugin-version>3.1.5</scala-maven-plugin-version>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
|
@ -1,11 +1,15 @@
|
||||
package com.wordnik.client.api
|
||||
|
||||
import com.wordnik.client.model.ApiTokenStatus
|
||||
import com.wordnik.client.model.WordList
|
||||
import com.wordnik.client.model.User
|
||||
import com.wordnik.client.model.WordList
|
||||
import com.wordnik.client.model.ApiTokenStatus
|
||||
import com.wordnik.client.model.AuthenticationToken
|
||||
import com.wordnik.client.common.ApiInvoker
|
||||
import com.wordnik.client.common.ApiException
|
||||
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
|
||||
import scala.collection.mutable.HashMap
|
||||
|
||||
class AccountApi {
|
||||
@ -16,20 +20,24 @@ class AccountApi {
|
||||
|
||||
def authenticate (username: String, password: String) : Option[AuthenticationToken]= {
|
||||
// create path and map variables
|
||||
val path = "/account.{format}/authenticate/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escapeString(username))
|
||||
val path = "/account.{format}/authenticate/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(username, password) - null).size match {
|
||||
(List(username, password).filter(_ != null)).size match {
|
||||
case 2 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
if(String.valueOf(password) != "null") queryParams += "password" -> password.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[AuthenticationToken]).asInstanceOf[AuthenticationToken])
|
||||
case _ => None
|
||||
@ -41,19 +49,26 @@ class AccountApi {
|
||||
}
|
||||
def authenticatePost (username: String, body: String) : Option[AuthenticationToken]= {
|
||||
// create path and map variables
|
||||
val path = "/account.{format}/authenticate/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escapeString(username))
|
||||
val path = "/account.{format}/authenticate/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username))
|
||||
|
||||
|
||||
val contentType = {
|
||||
if(body != null && body.isInstanceOf[File] )
|
||||
"multipart/form-data"
|
||||
else "application/json"
|
||||
}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(username, body) - null).size match {
|
||||
(List(username, body).filter(_ != null)).size match {
|
||||
case 2 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[AuthenticationToken]).asInstanceOf[AuthenticationToken])
|
||||
case _ => None
|
||||
@ -65,12 +80,16 @@ class AccountApi {
|
||||
}
|
||||
def getWordListsForLoggedInUser (auth_token: String, skip: Int= 0, limit: Int= 50) : Option[List[WordList]]= {
|
||||
// create path and map variables
|
||||
val path = "/account.{format}/wordLists".replaceAll("\\{format\\}","json")// query params
|
||||
val path = "/account.{format}/wordLists".replaceAll("\\{format\\}","json")
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(auth_token) - null).size match {
|
||||
(List(auth_token).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
@ -78,7 +97,7 @@ class AccountApi {
|
||||
if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
|
||||
headerParams += "auth_token" -> auth_token
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "List", classOf[WordList]).asInstanceOf[List[WordList]])
|
||||
case _ => None
|
||||
@ -90,13 +109,17 @@ class AccountApi {
|
||||
}
|
||||
def getApiTokenStatus (api_key: String) : Option[ApiTokenStatus]= {
|
||||
// create path and map variables
|
||||
val path = "/account.{format}/apiTokenStatus".replaceAll("\\{format\\}","json")// query params
|
||||
val path = "/account.{format}/apiTokenStatus".replaceAll("\\{format\\}","json")
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
headerParams += "api_key" -> api_key
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[ApiTokenStatus]).asInstanceOf[ApiTokenStatus])
|
||||
case _ => None
|
||||
@ -108,18 +131,22 @@ class AccountApi {
|
||||
}
|
||||
def getLoggedInUser (auth_token: String) : Option[User]= {
|
||||
// create path and map variables
|
||||
val path = "/account.{format}/user".replaceAll("\\{format\\}","json")// query params
|
||||
val path = "/account.{format}/user".replaceAll("\\{format\\}","json")
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(auth_token) - null).size match {
|
||||
(List(auth_token).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
headerParams += "auth_token" -> auth_token
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[User]).asInstanceOf[User])
|
||||
case _ => None
|
||||
|
@ -1,17 +1,22 @@
|
||||
package com.wordnik.client.api
|
||||
|
||||
import com.wordnik.client.model.Definition
|
||||
import com.wordnik.client.model.TextPron
|
||||
import com.wordnik.client.model.Example
|
||||
import com.wordnik.client.model.Syllable
|
||||
import com.wordnik.client.model.AudioFile
|
||||
import com.wordnik.client.model.ExampleSearchResults
|
||||
import com.wordnik.client.model.WordObject
|
||||
import com.wordnik.client.model.Bigram
|
||||
import com.wordnik.client.model.Related
|
||||
import com.wordnik.client.model.FrequencySummary
|
||||
import com.wordnik.client.model.Bigram
|
||||
import com.wordnik.client.model.WordObject
|
||||
import com.wordnik.client.model.ExampleSearchResults
|
||||
import com.wordnik.client.model.Example
|
||||
import com.wordnik.client.model.ScrabbleScoreResult
|
||||
import com.wordnik.client.model.TextPron
|
||||
import com.wordnik.client.model.Syllable
|
||||
import com.wordnik.client.model.Related
|
||||
import com.wordnik.client.model.Definition
|
||||
import com.wordnik.client.model.AudioFile
|
||||
import com.wordnik.client.common.ApiInvoker
|
||||
import com.wordnik.client.common.ApiException
|
||||
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
|
||||
import scala.collection.mutable.HashMap
|
||||
|
||||
class WordApi {
|
||||
@ -22,14 +27,18 @@ class WordApi {
|
||||
|
||||
def getExamples (word: String, includeDuplicates: String= "false", useCanonical: String= "false", skip: Int= 0, limit: Int= 5) : Option[ExampleSearchResults]= {
|
||||
// create path and map variables
|
||||
val path = "/word.{format}/{word}/examples".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escapeString(word))
|
||||
val path = "/word.{format}/{word}/examples".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(word) - null).size match {
|
||||
(List(word).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
@ -38,7 +47,7 @@ class WordApi {
|
||||
if(String.valueOf(skip) != "null") queryParams += "skip" -> skip.toString
|
||||
if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[ExampleSearchResults]).asInstanceOf[ExampleSearchResults])
|
||||
case _ => None
|
||||
@ -50,21 +59,25 @@ class WordApi {
|
||||
}
|
||||
def getWord (word: String, useCanonical: String= "false", includeSuggestions: String= "true") : Option[WordObject]= {
|
||||
// create path and map variables
|
||||
val path = "/word.{format}/{word}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escapeString(word))
|
||||
val path = "/word.{format}/{word}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(word) - null).size match {
|
||||
(List(word).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
|
||||
if(String.valueOf(includeSuggestions) != "null") queryParams += "includeSuggestions" -> includeSuggestions.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[WordObject]).asInstanceOf[WordObject])
|
||||
case _ => None
|
||||
@ -76,14 +89,18 @@ class WordApi {
|
||||
}
|
||||
def getDefinitions (word: String, partOfSpeech: String, sourceDictionaries: String, limit: Int= 200, includeRelated: String= "false", useCanonical: String= "false", includeTags: String= "false") : Option[List[Definition]]= {
|
||||
// create path and map variables
|
||||
val path = "/word.{format}/{word}/definitions".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escapeString(word))
|
||||
val path = "/word.{format}/{word}/definitions".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(word) - null).size match {
|
||||
(List(word).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
@ -94,7 +111,7 @@ class WordApi {
|
||||
if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
|
||||
if(String.valueOf(includeTags) != "null") queryParams += "includeTags" -> includeTags.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "List", classOf[Definition]).asInstanceOf[List[Definition]])
|
||||
case _ => None
|
||||
@ -106,20 +123,24 @@ class WordApi {
|
||||
}
|
||||
def getTopExample (word: String, useCanonical: String= "false") : Option[Example]= {
|
||||
// create path and map variables
|
||||
val path = "/word.{format}/{word}/topExample".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escapeString(word))
|
||||
val path = "/word.{format}/{word}/topExample".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(word) - null).size match {
|
||||
(List(word).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[Example]).asInstanceOf[Example])
|
||||
case _ => None
|
||||
@ -131,14 +152,18 @@ class WordApi {
|
||||
}
|
||||
def getRelatedWords (word: String, relationshipTypes: String, useCanonical: String= "false", limitPerRelationshipType: Int= 10) : Option[List[Related]]= {
|
||||
// create path and map variables
|
||||
val path = "/word.{format}/{word}/relatedWords".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escapeString(word))
|
||||
val path = "/word.{format}/{word}/relatedWords".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(word) - null).size match {
|
||||
(List(word).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
@ -146,7 +171,7 @@ class WordApi {
|
||||
if(String.valueOf(relationshipTypes) != "null") queryParams += "relationshipTypes" -> relationshipTypes.toString
|
||||
if(String.valueOf(limitPerRelationshipType) != "null") queryParams += "limitPerRelationshipType" -> limitPerRelationshipType.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "List", classOf[Related]).asInstanceOf[List[Related]])
|
||||
case _ => None
|
||||
@ -158,14 +183,18 @@ class WordApi {
|
||||
}
|
||||
def getTextPronunciations (word: String, sourceDictionary: String, typeFormat: String, useCanonical: String= "false", limit: Int= 50) : Option[List[TextPron]]= {
|
||||
// create path and map variables
|
||||
val path = "/word.{format}/{word}/pronunciations".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escapeString(word))
|
||||
val path = "/word.{format}/{word}/pronunciations".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(word) - null).size match {
|
||||
(List(word).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
@ -174,7 +203,7 @@ class WordApi {
|
||||
if(String.valueOf(typeFormat) != "null") queryParams += "typeFormat" -> typeFormat.toString
|
||||
if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "List", classOf[TextPron]).asInstanceOf[List[TextPron]])
|
||||
case _ => None
|
||||
@ -186,14 +215,18 @@ class WordApi {
|
||||
}
|
||||
def getHyphenation (word: String, sourceDictionary: String, useCanonical: String= "false", limit: Int= 50) : Option[List[Syllable]]= {
|
||||
// create path and map variables
|
||||
val path = "/word.{format}/{word}/hyphenation".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escapeString(word))
|
||||
val path = "/word.{format}/{word}/hyphenation".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(word) - null).size match {
|
||||
(List(word).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
@ -201,7 +234,7 @@ class WordApi {
|
||||
if(String.valueOf(sourceDictionary) != "null") queryParams += "sourceDictionary" -> sourceDictionary.toString
|
||||
if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "List", classOf[Syllable]).asInstanceOf[List[Syllable]])
|
||||
case _ => None
|
||||
@ -213,14 +246,18 @@ class WordApi {
|
||||
}
|
||||
def getWordFrequency (word: String, useCanonical: String= "false", startYear: Int= 1800, endYear: Int= 2012) : Option[FrequencySummary]= {
|
||||
// create path and map variables
|
||||
val path = "/word.{format}/{word}/frequency".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escapeString(word))
|
||||
val path = "/word.{format}/{word}/frequency".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(word) - null).size match {
|
||||
(List(word).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
@ -228,7 +265,7 @@ class WordApi {
|
||||
if(String.valueOf(startYear) != "null") queryParams += "startYear" -> startYear.toString
|
||||
if(String.valueOf(endYear) != "null") queryParams += "endYear" -> endYear.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[FrequencySummary]).asInstanceOf[FrequencySummary])
|
||||
case _ => None
|
||||
@ -240,14 +277,18 @@ class WordApi {
|
||||
}
|
||||
def getPhrases (word: String, limit: Int= 5, wlmi: Int= 0, useCanonical: String= "false") : Option[List[Bigram]]= {
|
||||
// create path and map variables
|
||||
val path = "/word.{format}/{word}/phrases".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escapeString(word))
|
||||
val path = "/word.{format}/{word}/phrases".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(word) - null).size match {
|
||||
(List(word).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
@ -255,7 +296,7 @@ class WordApi {
|
||||
if(String.valueOf(wlmi) != "null") queryParams += "wlmi" -> wlmi.toString
|
||||
if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "List", classOf[Bigram]).asInstanceOf[List[Bigram]])
|
||||
case _ => None
|
||||
@ -267,20 +308,24 @@ class WordApi {
|
||||
}
|
||||
def getEtymologies (word: String, useCanonical: String) : Option[List[String]]= {
|
||||
// create path and map variables
|
||||
val path = "/word.{format}/{word}/etymologies".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escapeString(word))
|
||||
val path = "/word.{format}/{word}/etymologies".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(word) - null).size match {
|
||||
(List(word).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "List", classOf[String]).asInstanceOf[List[String]])
|
||||
case _ => None
|
||||
@ -292,21 +337,25 @@ class WordApi {
|
||||
}
|
||||
def getAudio (word: String, useCanonical: String= "false", limit: Int= 50) : Option[List[AudioFile]]= {
|
||||
// create path and map variables
|
||||
val path = "/word.{format}/{word}/audio".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escapeString(word))
|
||||
val path = "/word.{format}/{word}/audio".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(word) - null).size match {
|
||||
(List(word).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
if(String.valueOf(useCanonical) != "null") queryParams += "useCanonical" -> useCanonical.toString
|
||||
if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "List", classOf[AudioFile]).asInstanceOf[List[AudioFile]])
|
||||
case _ => None
|
||||
@ -316,5 +365,33 @@ class WordApi {
|
||||
case ex: ApiException => throw ex
|
||||
}
|
||||
}
|
||||
def getScrabbleScore (word: String) : Option[ScrabbleScoreResult]= {
|
||||
// create path and map variables
|
||||
val path = "/word.{format}/{word}/scrabbleScore".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}",apiInvoker.escape(word))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(List(word).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[ScrabbleScoreResult]).asInstanceOf[ScrabbleScoreResult])
|
||||
case _ => None
|
||||
}
|
||||
} catch {
|
||||
case ex: ApiException if ex.code == 404 => None
|
||||
case ex: ApiException => throw ex
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,14 @@
|
||||
package com.wordnik.client.api
|
||||
|
||||
import com.wordnik.client.model.WordListWord
|
||||
import com.wordnik.client.model.WordList
|
||||
import com.wordnik.client.model.StringValue
|
||||
import com.wordnik.client.model.WordListWord
|
||||
import com.wordnik.client.common.ApiInvoker
|
||||
import com.wordnik.client.common.ApiException
|
||||
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
|
||||
import scala.collection.mutable.HashMap
|
||||
|
||||
class WordListApi {
|
||||
@ -15,20 +19,27 @@ class WordListApi {
|
||||
|
||||
def updateWordList (permalink: String, body: WordList, auth_token: String) = {
|
||||
// create path and map variables
|
||||
val path = "/wordList.{format}/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escapeString(permalink))
|
||||
val path = "/wordList.{format}/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escape(permalink))
|
||||
|
||||
|
||||
val contentType = {
|
||||
if(body != null && body.isInstanceOf[File] )
|
||||
"multipart/form-data"
|
||||
else "application/json"
|
||||
}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(permalink, auth_token) - null).size match {
|
||||
(List(permalink, auth_token).filter(_ != null)).size match {
|
||||
case 2 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
headerParams += "auth_token" -> auth_token
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "PUT", queryParams.toMap, body, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "PUT", queryParams.toMap, body, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
case _ => None
|
||||
}
|
||||
@ -39,20 +50,24 @@ class WordListApi {
|
||||
}
|
||||
def deleteWordList (permalink: String, auth_token: String) = {
|
||||
// create path and map variables
|
||||
val path = "/wordList.{format}/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escapeString(permalink))
|
||||
val path = "/wordList.{format}/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escape(permalink))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(permalink, auth_token) - null).size match {
|
||||
(List(permalink, auth_token).filter(_ != null)).size match {
|
||||
case 2 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
headerParams += "auth_token" -> auth_token
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
case _ => None
|
||||
}
|
||||
@ -63,20 +78,24 @@ class WordListApi {
|
||||
}
|
||||
def getWordListByPermalink (permalink: String, auth_token: String) : Option[WordList]= {
|
||||
// create path and map variables
|
||||
val path = "/wordList.{format}/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escapeString(permalink))
|
||||
val path = "/wordList.{format}/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escape(permalink))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(permalink, auth_token) - null).size match {
|
||||
(List(permalink, auth_token).filter(_ != null)).size match {
|
||||
case 2 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
headerParams += "auth_token" -> auth_token
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[WordList]).asInstanceOf[WordList])
|
||||
case _ => None
|
||||
@ -86,22 +105,29 @@ class WordListApi {
|
||||
case ex: ApiException => throw ex
|
||||
}
|
||||
}
|
||||
def addWordsToWordList (permalink: String, body: Array[StringValue], auth_token: String) = {
|
||||
def addWordsToWordList (permalink: String, body: List[StringValue], auth_token: String) = {
|
||||
// create path and map variables
|
||||
val path = "/wordList.{format}/{permalink}/words".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escapeString(permalink))
|
||||
val path = "/wordList.{format}/{permalink}/words".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escape(permalink))
|
||||
|
||||
|
||||
val contentType = {
|
||||
if(body != null && body.isInstanceOf[File] )
|
||||
"multipart/form-data"
|
||||
else "application/json"
|
||||
}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(permalink, auth_token) - null).size match {
|
||||
(List(permalink, auth_token).filter(_ != null)).size match {
|
||||
case 2 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
headerParams += "auth_token" -> auth_token
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
case _ => None
|
||||
}
|
||||
@ -112,14 +138,18 @@ class WordListApi {
|
||||
}
|
||||
def getWordListWords (permalink: String, auth_token: String, sortBy: String= "createDate", sortOrder: String= "desc", skip: Int= 0, limit: Int= 100) : Option[List[WordListWord]]= {
|
||||
// create path and map variables
|
||||
val path = "/wordList.{format}/{permalink}/words".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escapeString(permalink))
|
||||
val path = "/wordList.{format}/{permalink}/words".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escape(permalink))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(permalink, auth_token) - null).size match {
|
||||
(List(permalink, auth_token).filter(_ != null)).size match {
|
||||
case 2 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
@ -129,7 +159,7 @@ class WordListApi {
|
||||
if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
|
||||
headerParams += "auth_token" -> auth_token
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "List", classOf[WordListWord]).asInstanceOf[List[WordListWord]])
|
||||
case _ => None
|
||||
@ -139,22 +169,29 @@ class WordListApi {
|
||||
case ex: ApiException => throw ex
|
||||
}
|
||||
}
|
||||
def deleteWordsFromWordList (permalink: String, body: Array[StringValue], auth_token: String) = {
|
||||
def deleteWordsFromWordList (permalink: String, body: List[StringValue], auth_token: String) = {
|
||||
// create path and map variables
|
||||
val path = "/wordList.{format}/{permalink}/deleteWords".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escapeString(permalink))
|
||||
val path = "/wordList.{format}/{permalink}/deleteWords".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}",apiInvoker.escape(permalink))
|
||||
|
||||
|
||||
val contentType = {
|
||||
if(body != null && body.isInstanceOf[File] )
|
||||
"multipart/form-data"
|
||||
else "application/json"
|
||||
}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(permalink, auth_token) - null).size match {
|
||||
(List(permalink, auth_token).filter(_ != null)).size match {
|
||||
case 2 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
headerParams += "auth_token" -> auth_token
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
case _ => None
|
||||
}
|
||||
|
@ -3,6 +3,10 @@ package com.wordnik.client.api
|
||||
import com.wordnik.client.model.WordList
|
||||
import com.wordnik.client.common.ApiInvoker
|
||||
import com.wordnik.client.common.ApiException
|
||||
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
|
||||
import scala.collection.mutable.HashMap
|
||||
|
||||
class WordListsApi {
|
||||
@ -13,18 +17,25 @@ class WordListsApi {
|
||||
|
||||
def createWordList (body: WordList, auth_token: String) : Option[WordList]= {
|
||||
// create path and map variables
|
||||
val path = "/wordLists.{format}".replaceAll("\\{format\\}","json")// query params
|
||||
val path = "/wordLists.{format}".replaceAll("\\{format\\}","json")
|
||||
val contentType = {
|
||||
if(body != null && body.isInstanceOf[File] )
|
||||
"multipart/form-data"
|
||||
else "application/json"
|
||||
}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(auth_token) - null).size match {
|
||||
(List(auth_token).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
headerParams += "auth_token" -> auth_token
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[WordList]).asInstanceOf[WordList])
|
||||
case _ => None
|
||||
|
@ -1,11 +1,15 @@
|
||||
package com.wordnik.client.api
|
||||
|
||||
import com.wordnik.client.model.WordObject
|
||||
import com.wordnik.client.model.DefinitionSearchResults
|
||||
import com.wordnik.client.model.WordObject
|
||||
import com.wordnik.client.model.WordOfTheDay
|
||||
import com.wordnik.client.model.WordSearchResults
|
||||
import com.wordnik.client.common.ApiInvoker
|
||||
import com.wordnik.client.common.ApiException
|
||||
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
|
||||
import scala.collection.mutable.HashMap
|
||||
|
||||
class WordsApi {
|
||||
@ -16,14 +20,18 @@ class WordsApi {
|
||||
|
||||
def searchWords (query: String, includePartOfSpeech: String, excludePartOfSpeech: String, caseSensitive: String= "true", minCorpusCount: Int= 5, maxCorpusCount: Int= -1, minDictionaryCount: Int= 1, maxDictionaryCount: Int= -1, minLength: Int= 1, maxLength: Int= -1, skip: Int= 0, limit: Int= 10) : Option[WordSearchResults]= {
|
||||
// create path and map variables
|
||||
val path = "/words.{format}/search/{query}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "query" + "\\}",apiInvoker.escapeString(query))
|
||||
val path = "/words.{format}/search/{query}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "query" + "\\}",apiInvoker.escape(query))
|
||||
|
||||
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(query) - null).size match {
|
||||
(List(query).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
@ -39,7 +47,7 @@ class WordsApi {
|
||||
if(String.valueOf(skip) != "null") queryParams += "skip" -> skip.toString
|
||||
if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[WordSearchResults]).asInstanceOf[WordSearchResults])
|
||||
case _ => None
|
||||
@ -51,13 +59,17 @@ class WordsApi {
|
||||
}
|
||||
def getWordOfTheDay (date: String) : Option[WordOfTheDay]= {
|
||||
// create path and map variables
|
||||
val path = "/words.{format}/wordOfTheDay".replaceAll("\\{format\\}","json")// query params
|
||||
val path = "/words.{format}/wordOfTheDay".replaceAll("\\{format\\}","json")
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
if(String.valueOf(date) != "null") queryParams += "date" -> date.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[WordOfTheDay]).asInstanceOf[WordOfTheDay])
|
||||
case _ => None
|
||||
@ -69,12 +81,16 @@ class WordsApi {
|
||||
}
|
||||
def reverseDictionary (query: String, findSenseForWord: String, includeSourceDictionaries: String, excludeSourceDictionaries: String, includePartOfSpeech: String, excludePartOfSpeech: String, expandTerms: String, sortBy: String, sortOrder: String, minCorpusCount: Int= 5, maxCorpusCount: Int= -1, minLength: Int= 1, maxLength: Int= -1, includeTags: String= "false", skip: String= "0", limit: Int= 10) : Option[DefinitionSearchResults]= {
|
||||
// create path and map variables
|
||||
val path = "/words.{format}/reverseDictionary".replaceAll("\\{format\\}","json")// query params
|
||||
val path = "/words.{format}/reverseDictionary".replaceAll("\\{format\\}","json")
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
// verify required params are set
|
||||
(Set(query) - null).size match {
|
||||
(List(query).filter(_ != null)).size match {
|
||||
case 1 => // all required values set
|
||||
case _ => throw new Exception("missing required params")
|
||||
}
|
||||
@ -95,7 +111,7 @@ class WordsApi {
|
||||
if(String.valueOf(skip) != "null") queryParams += "skip" -> skip.toString
|
||||
if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[DefinitionSearchResults]).asInstanceOf[DefinitionSearchResults])
|
||||
case _ => None
|
||||
@ -107,7 +123,11 @@ class WordsApi {
|
||||
}
|
||||
def getRandomWords (includePartOfSpeech: String, excludePartOfSpeech: String, sortBy: String, sortOrder: String, hasDictionaryDef: String= "true", minCorpusCount: Int= 0, maxCorpusCount: Int= -1, minDictionaryCount: Int= 1, maxDictionaryCount: Int= -1, minLength: Int= 5, maxLength: Int= -1, limit: Int= 10) : Option[List[WordObject]]= {
|
||||
// create path and map variables
|
||||
val path = "/words.{format}/randomWords".replaceAll("\\{format\\}","json")// query params
|
||||
val path = "/words.{format}/randomWords".replaceAll("\\{format\\}","json")
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
@ -124,7 +144,7 @@ class WordsApi {
|
||||
if(String.valueOf(sortOrder) != "null") queryParams += "sortOrder" -> sortOrder.toString
|
||||
if(String.valueOf(limit) != "null") queryParams += "limit" -> limit.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "List", classOf[WordObject]).asInstanceOf[List[WordObject]])
|
||||
case _ => None
|
||||
@ -136,7 +156,11 @@ class WordsApi {
|
||||
}
|
||||
def getRandomWord (includePartOfSpeech: String, excludePartOfSpeech: String, hasDictionaryDef: String= "true", minCorpusCount: Int= 0, maxCorpusCount: Int= -1, minDictionaryCount: Int= 1, maxDictionaryCount: Int= -1, minLength: Int= 5, maxLength: Int= -1) : Option[WordObject]= {
|
||||
// create path and map variables
|
||||
val path = "/words.{format}/randomWord".replaceAll("\\{format\\}","json")// query params
|
||||
val path = "/words.{format}/randomWord".replaceAll("\\{format\\}","json")
|
||||
val contentType = {
|
||||
"application/json"}
|
||||
|
||||
// query params
|
||||
val queryParams = new HashMap[String, String]
|
||||
val headerParams = new HashMap[String, String]
|
||||
|
||||
@ -150,7 +174,7 @@ class WordsApi {
|
||||
if(String.valueOf(minLength) != "null") queryParams += "minLength" -> minLength.toString
|
||||
if(String.valueOf(maxLength) != "null") queryParams += "maxLength" -> maxLength.toString
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap) match {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, None, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[WordObject]).asInstanceOf[WordObject])
|
||||
case _ => None
|
||||
|
@ -6,6 +6,10 @@ import com.sun.jersey.api.client.config.ClientConfig
|
||||
import com.sun.jersey.api.client.config.DefaultClientConfig
|
||||
import com.sun.jersey.api.client.filter.LoggingFilter
|
||||
|
||||
import com.sun.jersey.multipart.FormDataMultiPart
|
||||
import com.sun.jersey.multipart.file.FileDataBodyPart
|
||||
|
||||
import java.io.File
|
||||
import java.net.URLEncoder
|
||||
import javax.ws.rs.core.MediaType
|
||||
|
||||
@ -36,12 +40,16 @@ object ApiInvoker {
|
||||
val defaultHeaders: HashMap[String, String] = HashMap()
|
||||
val hostMap: HashMap[String, Client] = HashMap()
|
||||
|
||||
def escapeString(value: String): String = {
|
||||
def escape(value: String): String = {
|
||||
URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
||||
}
|
||||
|
||||
def escape(value: Long): String = value.toString
|
||||
def escape(value: Double): String = value.toString
|
||||
def escape(value: Float): String = value.toString
|
||||
|
||||
def deserialize(json: String, containerType: String, cls: Class[_]) = {
|
||||
if (cls == classOf[String] && containerType == null) {
|
||||
if (cls == classOf[String]) {
|
||||
json match {
|
||||
case s: String => {
|
||||
if (s.startsWith("\"") && s.endsWith("\"") && s.length > 1) s.substring(1, s.length - 2)
|
||||
@ -50,8 +58,13 @@ object ApiInvoker {
|
||||
case _ => null
|
||||
}
|
||||
} else {
|
||||
containerType match {
|
||||
case "List" => {
|
||||
containerType.toLowerCase match {
|
||||
case "array" => {
|
||||
val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls)
|
||||
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
|
||||
response.asScala.toList
|
||||
}
|
||||
case "list" => {
|
||||
val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls)
|
||||
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
|
||||
response.asScala.toList
|
||||
@ -75,12 +88,11 @@ object ApiInvoker {
|
||||
} else null
|
||||
}
|
||||
|
||||
def invokeApi(host: String, path: String, method: String, queryParams: Map[String, String], body: AnyRef, headerParams: Map[String, String]) = {
|
||||
def invokeApi(host: String, path: String, method: String, queryParams: Map[String, String], body: AnyRef, headerParams: Map[String, String], contentType: String): String = {
|
||||
val client = getClient(host)
|
||||
|
||||
val querystring = queryParams.filter(k => k._2 != null).map(k => (escapeString(k._1) + "=" + escapeString(k._2))).mkString("?", "&", "")
|
||||
val builder = client.resource(host + path + querystring).`type`("application/json")
|
||||
|
||||
val querystring = queryParams.filter(k => k._2 != null).map(k => (escape(k._1) + "=" + escape(k._2))).mkString("?", "&", "")
|
||||
val builder = client.resource(host + path + querystring).accept(contentType)
|
||||
headerParams.map(p => builder.header(p._1, p._2))
|
||||
defaultHeaders.map(p => {
|
||||
headerParams.contains(p._1) match {
|
||||
@ -94,22 +106,43 @@ object ApiInvoker {
|
||||
builder.get(classOf[ClientResponse]).asInstanceOf[ClientResponse]
|
||||
}
|
||||
case "POST" => {
|
||||
builder.post(classOf[ClientResponse], serialize(body))
|
||||
if(body != null && body.isInstanceOf[File]) {
|
||||
val file = body.asInstanceOf[File]
|
||||
val form = new FormDataMultiPart()
|
||||
form.field("filename", file.getName())
|
||||
form.bodyPart(new FileDataBodyPart("file", file, MediaType.MULTIPART_FORM_DATA_TYPE))
|
||||
builder.post(classOf[ClientResponse], form)
|
||||
}
|
||||
else {
|
||||
if(body == null) builder.post(classOf[ClientResponse], serialize(body))
|
||||
else builder.`type`(contentType).post(classOf[ClientResponse], serialize(body))
|
||||
}
|
||||
}
|
||||
case "PUT" => {
|
||||
builder.put(classOf[ClientResponse], serialize(body))
|
||||
if(body == null) builder.put(classOf[ClientResponse], null)
|
||||
else builder.`type`(contentType).put(classOf[ClientResponse], serialize(body))
|
||||
}
|
||||
case "DELETE" => {
|
||||
builder.delete(classOf[ClientResponse])
|
||||
}
|
||||
case _ => null
|
||||
}
|
||||
response.getClientResponseStatus() match {
|
||||
case ClientResponse.Status.OK => response.getEntity(classOf[String])
|
||||
response.getClientResponseStatus().getStatusCode() match {
|
||||
case 204 => ""
|
||||
case code: Int if (Range(200, 299).contains(code)) => {
|
||||
response.hasEntity() match {
|
||||
case true => response.getEntity(classOf[String])
|
||||
case false => ""
|
||||
}
|
||||
}
|
||||
case _ => {
|
||||
val entity = response.hasEntity() match {
|
||||
case true => response.getEntity(classOf[String])
|
||||
case false => "no data"
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getClientResponseStatus().getStatusCode(),
|
||||
response.getEntity(classOf[String]))
|
||||
entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -127,11 +160,6 @@ object ApiInvoker {
|
||||
}
|
||||
}
|
||||
|
||||
class ApiException extends Exception {
|
||||
var code = 0
|
||||
class ApiException(val code: Int, msg: String) extends RuntimeException(msg)
|
||||
|
||||
def this(code: Int, msg: String) = {
|
||||
this()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.wordnik.client.model
|
||||
|
||||
import com.wordnik.client.model.ExampleUsage
|
||||
import com.wordnik.client.model.Note
|
||||
import com.wordnik.client.model.Citation
|
||||
import com.wordnik.client.model.TextPron
|
||||
import com.wordnik.client.model.Label
|
||||
import com.wordnik.client.model.ExampleUsage
|
||||
import com.wordnik.client.model.TextPron
|
||||
import com.wordnik.client.model.Citation
|
||||
import com.wordnik.client.model.Related
|
||||
import com.wordnik.client.model.Note
|
||||
case class Definition (
|
||||
extendedText: String,
|
||||
text: String,
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.wordnik.client.model
|
||||
|
||||
import com.wordnik.client.model.Sentence
|
||||
import com.wordnik.client.model.ScoredWord
|
||||
import com.wordnik.client.model.ContentProvider
|
||||
import com.wordnik.client.model.ScoredWord
|
||||
case class Example (
|
||||
id: Long,
|
||||
exampleId: Long,
|
||||
|
@ -0,0 +1,5 @@
|
||||
package com.wordnik.client.model
|
||||
|
||||
case class ScrabbleScoreResult (
|
||||
value: Int)
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.wordnik.client.model
|
||||
|
||||
import java.util.Date
|
||||
import com.wordnik.client.model.SimpleDefinition
|
||||
import com.wordnik.client.model.SimpleExample
|
||||
import com.wordnik.client.model.SimpleDefinition
|
||||
import com.wordnik.client.model.ContentProvider
|
||||
case class WordOfTheDay (
|
||||
id: Long,
|
||||
|
@ -63,12 +63,13 @@ class WordListApiTest extends FlatSpec with ShouldMatchers with BaseApiTest {
|
||||
}
|
||||
|
||||
it should "add words to a list" in {
|
||||
val wordsToAdd = new ListBuffer[StringValue]
|
||||
wordsToAdd += StringValue("delicious")
|
||||
wordsToAdd += StringValue("tasty")
|
||||
wordsToAdd += StringValue("scrumptious")
|
||||
val wordsToAdd = List(
|
||||
StringValue("delicious"),
|
||||
StringValue("tasty"),
|
||||
StringValue("scrumptious")
|
||||
)
|
||||
|
||||
api.addWordsToWordList(sampleList.permalink, wordsToAdd.toArray, auth.token)
|
||||
api.addWordsToWordList(sampleList.permalink, wordsToAdd, auth.token)
|
||||
}
|
||||
|
||||
it should "get word list words" in {
|
||||
@ -81,11 +82,12 @@ class WordListApiTest extends FlatSpec with ShouldMatchers with BaseApiTest {
|
||||
}
|
||||
|
||||
it should "remove words from a list" in {
|
||||
val wordsToRemove = new ListBuffer[StringValue]
|
||||
wordsToRemove += StringValue("delicious")
|
||||
wordsToRemove += StringValue("tasty")
|
||||
val wordsToRemove = List(
|
||||
StringValue("delicious"),
|
||||
StringValue("tasty")
|
||||
)
|
||||
|
||||
api.deleteWordsFromWordList(sampleList.permalink, wordsToRemove.toArray, auth.token)
|
||||
api.deleteWordsFromWordList(sampleList.permalink, wordsToRemove, auth.token)
|
||||
api.getWordListWords(sampleList.permalink, auth.token).get.size should be(1)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user