diff --git a/samples/client/wordnik-api/java/JavaWordnikApiCodegen.scala b/samples/client/wordnik-api/java/JavaWordnikApiCodegen.scala new file mode 100644 index 00000000000..4e102b21854 --- /dev/null +++ b/samples/client/wordnik-api/java/JavaWordnikApiCodegen.scala @@ -0,0 +1,47 @@ +/** + * Copyright 2012 Wordnik, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.wordnik.swagger.codegen.BasicJavaGenerator + +import com.wordnik.swagger.core._ + +object JavaWordnikApiCodegen extends BasicJavaGenerator { + def main(args: Array[String]) = generateClient(args) + + // location of templates + override def templateDir = "Java" + + def destinationRoot = "samples/client/wordnik-api/java" + + // where to write generated code + override def destinationDir = destinationRoot + "/src/main/java" + + // package for api invoker, error files + override def invokerPackage = Some("com.wordnik.client.common") + + // package for models + override def modelPackage = Some("com.wordnik.client.model") + + // package for api classes + override def apiPackage = Some("com.wordnik.client.api") + + // supporting classes + override def supportingFiles = + List( + ("apiInvoker.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replaceAll("\\.", java.io.File.separator) + java.io.File.separator, "ApiInvoker.java"), + ("apiException.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replaceAll("\\.", java.io.File.separator) + java.io.File.separator, "ApiException.java"), + ("pom.mustache", destinationRoot, "pom.xml")) +} \ No newline at end of file diff --git a/samples/client/wordnik-api/java/pom.xml b/samples/client/wordnik-api/java/pom.xml new file mode 100644 index 00000000000..d5cf5b6024b --- /dev/null +++ b/samples/client/wordnik-api/java/pom.xml @@ -0,0 +1,225 @@ + + 4.0.0 + com.wordnik + swagger-client + jar + swagger-client + 1.0 + + scm:git:git@github.com:wordnik/swagger-mustache.git + scm:git:git@github.com:wordnik/swagger-mustache.git + https://github.com/wordnik/swagger-mustache + + + 2.2.0 + + + + + scala-tools.org + Scala-Tools Maven2 Repository + http://scala-tools.org/repo-releases + + + maven-mongodb-plugin-repo + maven mongodb plugin repository + http://maven-mongodb-plugin.googlecode.com/svn/maven/repo + default + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + pertest + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add_sources + generate-sources + + add-source + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + org.scala-tools + maven-scala-plugin + 2.15.2 + + + scala-compile-first + process-resources + + add-source + compile + + + + scala-test-compile + process-test-resources + + testCompile + + + + + + -Xms128m + -Xmx1500m + + + + + + + + + org.scala-tools + maven-scala-plugin + + ${scala-version} + + + + + + + com.sun.jersey + jersey-client + ${jersey-version} + compile + + + org.scala-lang + scala-library + ${scala-version} + compile + + + com.wordnik + swagger-core_2.9.1 + ${swagger-core-version} + compile + + + org.scalatest + scalatest_2.9.1 + ${scala-test-version} + test + + + junit + junit + ${junit-version} + test + + + + + scala-tools.org + Scala-Tools Maven2 Repository + http://scala-tools.org/repo-releases + + + wordnik-ci-aws + https://ci.aws.wordnik.com/artifactory/libs-snapshots/ + + + wordnik-ci-aws-maven + https://ci.aws.wordnik.com/artifactory/m2-snapshots/ + + + wordnik-ci-aws-remote + https://ci.aws.wordnik.com/artifactory/remote-repos/ + + + + + 1.7 + 1.1.0 + 2.9.1-1 + 4.8.1 + 1.0.0 + 1.6.1 + 4.8.1 + 1.6.1 + + + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/AccountApi.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/AccountApi.java new file mode 100644 index 00000000000..7529fa32a19 --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/AccountApi.java @@ -0,0 +1,178 @@ +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.AuthenticationToken; +import java.util.*; + +public class AccountApi { + String basePath = "http://api.wordnik.com/v4"; + ApiInvoker apiInvoker = ApiInvoker.getInstance(); + + public ApiInvoker getInvoker() { + return apiInvoker; + } + + public void setBasePath(String basePath) { + this.basePath = basePath; + } + + public String getBasePath() { + return basePath; + } + + public AuthenticationToken authenticate (String username, String password) throws ApiException { + // create path and map variables + String path = "/account.{format}/authenticate/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(username == null || password == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(password))) + queryParams.put("password", String.valueOf(password)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (AuthenticationToken) ApiInvoker.deserialize(response, "", AuthenticationToken.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public AuthenticationToken authenticatePost (String username, String body) throws ApiException { + // create path and map variables + String path = "/account.{format}/authenticate/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(username == null || body == null ) { + throw new ApiException(400, "missing required params"); + } + try { + String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams); + if(response != null){ + return (AuthenticationToken) ApiInvoker.deserialize(response, "", AuthenticationToken.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public List getWordListsForLoggedInUser (String auth_token, Integer skip, Integer limit) throws ApiException { + // create path and map variables + String path = "/account.{format}/wordLists".replaceAll("\\{format\\}","json"); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(auth_token == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(skip))) + queryParams.put("skip", String.valueOf(skip)); + if(!"null".equals(String.valueOf(limit))) + queryParams.put("limit", String.valueOf(limit)); + headerParams.put("auth_token", auth_token); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (List) ApiInvoker.deserialize(response, "List", WordList.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public ApiTokenStatus getApiTokenStatus (String api_key) throws ApiException { + // create path and map variables + String path = "/account.{format}/apiTokenStatus".replaceAll("\\{format\\}","json"); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + headerParams.put("api_key", api_key); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (ApiTokenStatus) ApiInvoker.deserialize(response, "", ApiTokenStatus.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public User getLoggedInUser (String auth_token) throws ApiException { + // create path and map variables + String path = "/account.{format}/user".replaceAll("\\{format\\}","json"); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(auth_token == null ) { + throw new ApiException(400, "missing required params"); + } + headerParams.put("auth_token", auth_token); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (User) ApiInvoker.deserialize(response, "", User.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + } + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordApi.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordApi.java new file mode 100644 index 00000000000..6aa63839bbb --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordApi.java @@ -0,0 +1,417 @@ +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 java.util.*; + +public class WordApi { + String basePath = "http://api.wordnik.com/v4"; + ApiInvoker apiInvoker = ApiInvoker.getInstance(); + + public ApiInvoker getInvoker() { + return apiInvoker; + } + + public void setBasePath(String basePath) { + this.basePath = basePath; + } + + public String getBasePath() { + return basePath; + } + + public ExampleSearchResults getExamples (String word, String includeDuplicates, String useCanonical, Integer skip, Integer limit) throws ApiException { + // create path and map variables + String path = "/word.{format}/{word}/examples".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(includeDuplicates))) + queryParams.put("includeDuplicates", String.valueOf(includeDuplicates)); + if(!"null".equals(String.valueOf(useCanonical))) + queryParams.put("useCanonical", String.valueOf(useCanonical)); + if(!"null".equals(String.valueOf(skip))) + queryParams.put("skip", String.valueOf(skip)); + if(!"null".equals(String.valueOf(limit))) + queryParams.put("limit", String.valueOf(limit)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (ExampleSearchResults) ApiInvoker.deserialize(response, "", ExampleSearchResults.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public WordObject getWord (String word, String useCanonical, String includeSuggestions) throws ApiException { + // create path and map variables + String path = "/word.{format}/{word}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(useCanonical))) + queryParams.put("useCanonical", String.valueOf(useCanonical)); + if(!"null".equals(String.valueOf(includeSuggestions))) + queryParams.put("includeSuggestions", String.valueOf(includeSuggestions)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (WordObject) ApiInvoker.deserialize(response, "", WordObject.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public List getDefinitions (String word, String partOfSpeech, String sourceDictionaries, Integer limit, String includeRelated, String useCanonical, String includeTags) throws ApiException { + // create path and map variables + String path = "/word.{format}/{word}/definitions".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(limit))) + queryParams.put("limit", String.valueOf(limit)); + if(!"null".equals(String.valueOf(partOfSpeech))) + queryParams.put("partOfSpeech", String.valueOf(partOfSpeech)); + if(!"null".equals(String.valueOf(includeRelated))) + queryParams.put("includeRelated", String.valueOf(includeRelated)); + if(!"null".equals(String.valueOf(sourceDictionaries))) + queryParams.put("sourceDictionaries", String.valueOf(sourceDictionaries)); + if(!"null".equals(String.valueOf(useCanonical))) + queryParams.put("useCanonical", String.valueOf(useCanonical)); + if(!"null".equals(String.valueOf(includeTags))) + queryParams.put("includeTags", String.valueOf(includeTags)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (List) ApiInvoker.deserialize(response, "List", Definition.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public Example getTopExample (String word, String useCanonical) throws ApiException { + // create path and map variables + String path = "/word.{format}/{word}/topExample".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(useCanonical))) + queryParams.put("useCanonical", String.valueOf(useCanonical)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (Example) ApiInvoker.deserialize(response, "", Example.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public List getRelatedWords (String word, String relationshipTypes, String useCanonical, Integer limitPerRelationshipType) throws ApiException { + // create path and map variables + String path = "/word.{format}/{word}/relatedWords".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(useCanonical))) + queryParams.put("useCanonical", String.valueOf(useCanonical)); + if(!"null".equals(String.valueOf(relationshipTypes))) + queryParams.put("relationshipTypes", String.valueOf(relationshipTypes)); + if(!"null".equals(String.valueOf(limitPerRelationshipType))) + queryParams.put("limitPerRelationshipType", String.valueOf(limitPerRelationshipType)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (List) ApiInvoker.deserialize(response, "List", Related.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public List getTextPronunciations (String word, String sourceDictionary, String typeFormat, String useCanonical, Integer limit) throws ApiException { + // create path and map variables + String path = "/word.{format}/{word}/pronunciations".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(useCanonical))) + queryParams.put("useCanonical", String.valueOf(useCanonical)); + if(!"null".equals(String.valueOf(sourceDictionary))) + queryParams.put("sourceDictionary", String.valueOf(sourceDictionary)); + if(!"null".equals(String.valueOf(typeFormat))) + queryParams.put("typeFormat", String.valueOf(typeFormat)); + if(!"null".equals(String.valueOf(limit))) + queryParams.put("limit", String.valueOf(limit)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (List) ApiInvoker.deserialize(response, "List", TextPron.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public List getHyphenation (String word, String sourceDictionary, String useCanonical, Integer limit) throws ApiException { + // create path and map variables + String path = "/word.{format}/{word}/hyphenation".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(useCanonical))) + queryParams.put("useCanonical", String.valueOf(useCanonical)); + if(!"null".equals(String.valueOf(sourceDictionary))) + queryParams.put("sourceDictionary", String.valueOf(sourceDictionary)); + if(!"null".equals(String.valueOf(limit))) + queryParams.put("limit", String.valueOf(limit)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (List) ApiInvoker.deserialize(response, "List", Syllable.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public FrequencySummary getWordFrequency (String word, String useCanonical, Integer startYear, Integer endYear) throws ApiException { + // create path and map variables + String path = "/word.{format}/{word}/frequency".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(useCanonical))) + queryParams.put("useCanonical", String.valueOf(useCanonical)); + if(!"null".equals(String.valueOf(startYear))) + queryParams.put("startYear", String.valueOf(startYear)); + if(!"null".equals(String.valueOf(endYear))) + queryParams.put("endYear", String.valueOf(endYear)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (FrequencySummary) ApiInvoker.deserialize(response, "", FrequencySummary.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public List getPhrases (String word, Integer limit, Integer wlmi, String useCanonical) throws ApiException { + // create path and map variables + String path = "/word.{format}/{word}/phrases".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(limit))) + queryParams.put("limit", String.valueOf(limit)); + if(!"null".equals(String.valueOf(wlmi))) + queryParams.put("wlmi", String.valueOf(wlmi)); + if(!"null".equals(String.valueOf(useCanonical))) + queryParams.put("useCanonical", String.valueOf(useCanonical)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (List) ApiInvoker.deserialize(response, "List", Bigram.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public List getEtymologies (String word, String useCanonical) throws ApiException { + // create path and map variables + String path = "/word.{format}/{word}/etymologies".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(useCanonical))) + queryParams.put("useCanonical", String.valueOf(useCanonical)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (List) ApiInvoker.deserialize(response, "List", String.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public List getAudio (String word, String useCanonical, Integer limit) throws ApiException { + // create path and map variables + String path = "/word.{format}/{word}/audio".replaceAll("\\{format\\}","json").replaceAll("\\{" + "word" + "\\}", apiInvoker.escapeString(word)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(word == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(useCanonical))) + queryParams.put("useCanonical", String.valueOf(useCanonical)); + if(!"null".equals(String.valueOf(limit))) + queryParams.put("limit", String.valueOf(limit)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (List) ApiInvoker.deserialize(response, "List", AudioFile.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + } + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListApi.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListApi.java new file mode 100644 index 00000000000..df5c0c36969 --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListApi.java @@ -0,0 +1,215 @@ +package com.wordnik.client.api; + +import com.wordnik.client.common.ApiException; +import com.wordnik.client.common.ApiInvoker; +import com.wordnik.client.model.WordList; +import com.wordnik.client.model.StringValue; +import com.wordnik.client.model.WordListWord; +import java.util.*; + +public class WordListApi { + String basePath = "http://api.wordnik.com/v4"; + ApiInvoker apiInvoker = ApiInvoker.getInstance(); + + public ApiInvoker getInvoker() { + return apiInvoker; + } + + public void setBasePath(String basePath) { + this.basePath = basePath; + } + + public String getBasePath() { + return basePath; + } + + public void updateWordList (String permalink, WordList body, String auth_token) throws ApiException { + // create path and map variables + String path = "/wordList.{format}/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}", apiInvoker.escapeString(permalink)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(permalink == null || auth_token == null ) { + throw new ApiException(400, "missing required params"); + } + headerParams.put("auth_token", auth_token); + try { + String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams); + if(response != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return ; + } + else { + throw ex; + } + } + } + public void deleteWordList (String permalink, String auth_token) throws ApiException { + // create path and map variables + String path = "/wordList.{format}/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}", apiInvoker.escapeString(permalink)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(permalink == null || auth_token == null ) { + throw new ApiException(400, "missing required params"); + } + headerParams.put("auth_token", auth_token); + try { + String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams); + if(response != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return ; + } + else { + throw ex; + } + } + } + public WordList getWordListByPermalink (String permalink, String auth_token) throws ApiException { + // create path and map variables + String path = "/wordList.{format}/{permalink}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}", apiInvoker.escapeString(permalink)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(permalink == null || auth_token == null ) { + throw new ApiException(400, "missing required params"); + } + headerParams.put("auth_token", auth_token); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (WordList) ApiInvoker.deserialize(response, "", WordList.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public void addWordsToWordList (String permalink, List body, String auth_token) throws ApiException { + // create path and map variables + String path = "/wordList.{format}/{permalink}/words".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}", apiInvoker.escapeString(permalink)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(permalink == null || auth_token == null ) { + throw new ApiException(400, "missing required params"); + } + headerParams.put("auth_token", auth_token); + try { + String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams); + if(response != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return ; + } + else { + throw ex; + } + } + } + public List getWordListWords (String permalink, String auth_token, String sortBy, String sortOrder, Integer skip, Integer limit) throws ApiException { + // create path and map variables + String path = "/wordList.{format}/{permalink}/words".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}", apiInvoker.escapeString(permalink)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(permalink == null || auth_token == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(sortBy))) + queryParams.put("sortBy", String.valueOf(sortBy)); + if(!"null".equals(String.valueOf(sortOrder))) + queryParams.put("sortOrder", String.valueOf(sortOrder)); + if(!"null".equals(String.valueOf(skip))) + queryParams.put("skip", String.valueOf(skip)); + if(!"null".equals(String.valueOf(limit))) + queryParams.put("limit", String.valueOf(limit)); + headerParams.put("auth_token", auth_token); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (List) ApiInvoker.deserialize(response, "List", WordListWord.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public void deleteWordsFromWordList (String permalink, List body, String auth_token) throws ApiException { + // create path and map variables + String path = "/wordList.{format}/{permalink}/deleteWords".replaceAll("\\{format\\}","json").replaceAll("\\{" + "permalink" + "\\}", apiInvoker.escapeString(permalink)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(permalink == null || auth_token == null ) { + throw new ApiException(400, "missing required params"); + } + headerParams.put("auth_token", auth_token); + try { + String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams); + if(response != null){ + return ; + } + else { + return ; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return ; + } + else { + throw ex; + } + } + } + } + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListsApi.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListsApi.java new file mode 100644 index 00000000000..b7544882efd --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordListsApi.java @@ -0,0 +1,55 @@ +package com.wordnik.client.api; + +import com.wordnik.client.common.ApiException; +import com.wordnik.client.common.ApiInvoker; +import com.wordnik.client.model.WordList; +import java.util.*; + +public class WordListsApi { + String basePath = "http://api.wordnik.com/v4"; + ApiInvoker apiInvoker = ApiInvoker.getInstance(); + + public ApiInvoker getInvoker() { + return apiInvoker; + } + + public void setBasePath(String basePath) { + this.basePath = basePath; + } + + public String getBasePath() { + return basePath; + } + + public WordList createWordList (WordList body, String auth_token) throws ApiException { + // create path and map variables + String path = "/wordLists.{format}".replaceAll("\\{format\\}","json"); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(auth_token == null ) { + throw new ApiException(400, "missing required params"); + } + headerParams.put("auth_token", auth_token); + try { + String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, body, headerParams); + if(response != null){ + return (WordList) ApiInvoker.deserialize(response, "", WordList.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + } + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordsApi.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordsApi.java new file mode 100644 index 00000000000..119fac75822 --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/api/WordsApi.java @@ -0,0 +1,259 @@ +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.WordOfTheDay; +import com.wordnik.client.model.WordSearchResults; +import java.util.*; + +public class WordsApi { + String basePath = "http://api.wordnik.com/v4"; + ApiInvoker apiInvoker = ApiInvoker.getInstance(); + + public ApiInvoker getInvoker() { + return apiInvoker; + } + + public void setBasePath(String basePath) { + this.basePath = basePath; + } + + public String getBasePath() { + return basePath; + } + + public WordSearchResults searchWords (String query, String includePartOfSpeech, String excludePartOfSpeech, String caseSensitive, Integer minCorpusCount, Integer maxCorpusCount, Integer minDictionaryCount, Integer maxDictionaryCount, Integer minLength, Integer maxLength, Integer skip, Integer limit) throws ApiException { + // create path and map variables + String path = "/words.{format}/search/{query}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "query" + "\\}", apiInvoker.escapeString(query)); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(query == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(caseSensitive))) + queryParams.put("caseSensitive", String.valueOf(caseSensitive)); + if(!"null".equals(String.valueOf(includePartOfSpeech))) + queryParams.put("includePartOfSpeech", String.valueOf(includePartOfSpeech)); + if(!"null".equals(String.valueOf(excludePartOfSpeech))) + queryParams.put("excludePartOfSpeech", String.valueOf(excludePartOfSpeech)); + if(!"null".equals(String.valueOf(minCorpusCount))) + queryParams.put("minCorpusCount", String.valueOf(minCorpusCount)); + if(!"null".equals(String.valueOf(maxCorpusCount))) + queryParams.put("maxCorpusCount", String.valueOf(maxCorpusCount)); + if(!"null".equals(String.valueOf(minDictionaryCount))) + queryParams.put("minDictionaryCount", String.valueOf(minDictionaryCount)); + if(!"null".equals(String.valueOf(maxDictionaryCount))) + queryParams.put("maxDictionaryCount", String.valueOf(maxDictionaryCount)); + if(!"null".equals(String.valueOf(minLength))) + queryParams.put("minLength", String.valueOf(minLength)); + if(!"null".equals(String.valueOf(maxLength))) + queryParams.put("maxLength", String.valueOf(maxLength)); + if(!"null".equals(String.valueOf(skip))) + queryParams.put("skip", String.valueOf(skip)); + if(!"null".equals(String.valueOf(limit))) + queryParams.put("limit", String.valueOf(limit)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (WordSearchResults) ApiInvoker.deserialize(response, "", WordSearchResults.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public WordOfTheDay getWordOfTheDay (String date) throws ApiException { + // create path and map variables + String path = "/words.{format}/wordOfTheDay".replaceAll("\\{format\\}","json"); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + if(!"null".equals(String.valueOf(date))) + queryParams.put("date", String.valueOf(date)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (WordOfTheDay) ApiInvoker.deserialize(response, "", WordOfTheDay.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public DefinitionSearchResults reverseDictionary (String query, String findSenseForWord, String includeSourceDictionaries, String excludeSourceDictionaries, String includePartOfSpeech, String excludePartOfSpeech, String expandTerms, String sortBy, String sortOrder, Integer minCorpusCount, Integer maxCorpusCount, Integer minLength, Integer maxLength, String includeTags, String skip, Integer limit) throws ApiException { + // create path and map variables + String path = "/words.{format}/reverseDictionary".replaceAll("\\{format\\}","json"); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + // verify required params are set + if(query == null ) { + throw new ApiException(400, "missing required params"); + } + if(!"null".equals(String.valueOf(query))) + queryParams.put("query", String.valueOf(query)); + if(!"null".equals(String.valueOf(findSenseForWord))) + queryParams.put("findSenseForWord", String.valueOf(findSenseForWord)); + if(!"null".equals(String.valueOf(includeSourceDictionaries))) + queryParams.put("includeSourceDictionaries", String.valueOf(includeSourceDictionaries)); + if(!"null".equals(String.valueOf(excludeSourceDictionaries))) + queryParams.put("excludeSourceDictionaries", String.valueOf(excludeSourceDictionaries)); + if(!"null".equals(String.valueOf(includePartOfSpeech))) + queryParams.put("includePartOfSpeech", String.valueOf(includePartOfSpeech)); + if(!"null".equals(String.valueOf(excludePartOfSpeech))) + queryParams.put("excludePartOfSpeech", String.valueOf(excludePartOfSpeech)); + if(!"null".equals(String.valueOf(minCorpusCount))) + queryParams.put("minCorpusCount", String.valueOf(minCorpusCount)); + if(!"null".equals(String.valueOf(maxCorpusCount))) + queryParams.put("maxCorpusCount", String.valueOf(maxCorpusCount)); + if(!"null".equals(String.valueOf(minLength))) + queryParams.put("minLength", String.valueOf(minLength)); + if(!"null".equals(String.valueOf(maxLength))) + queryParams.put("maxLength", String.valueOf(maxLength)); + if(!"null".equals(String.valueOf(expandTerms))) + queryParams.put("expandTerms", String.valueOf(expandTerms)); + if(!"null".equals(String.valueOf(includeTags))) + queryParams.put("includeTags", String.valueOf(includeTags)); + if(!"null".equals(String.valueOf(sortBy))) + queryParams.put("sortBy", String.valueOf(sortBy)); + if(!"null".equals(String.valueOf(sortOrder))) + queryParams.put("sortOrder", String.valueOf(sortOrder)); + if(!"null".equals(String.valueOf(skip))) + queryParams.put("skip", String.valueOf(skip)); + if(!"null".equals(String.valueOf(limit))) + queryParams.put("limit", String.valueOf(limit)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (DefinitionSearchResults) ApiInvoker.deserialize(response, "", DefinitionSearchResults.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public List getRandomWords (String includePartOfSpeech, String excludePartOfSpeech, String sortBy, String sortOrder, String hasDictionaryDef, Integer minCorpusCount, Integer maxCorpusCount, Integer minDictionaryCount, Integer maxDictionaryCount, Integer minLength, Integer maxLength, Integer limit) throws ApiException { + // create path and map variables + String path = "/words.{format}/randomWords".replaceAll("\\{format\\}","json"); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + if(!"null".equals(String.valueOf(hasDictionaryDef))) + queryParams.put("hasDictionaryDef", String.valueOf(hasDictionaryDef)); + if(!"null".equals(String.valueOf(includePartOfSpeech))) + queryParams.put("includePartOfSpeech", String.valueOf(includePartOfSpeech)); + if(!"null".equals(String.valueOf(excludePartOfSpeech))) + queryParams.put("excludePartOfSpeech", String.valueOf(excludePartOfSpeech)); + if(!"null".equals(String.valueOf(minCorpusCount))) + queryParams.put("minCorpusCount", String.valueOf(minCorpusCount)); + if(!"null".equals(String.valueOf(maxCorpusCount))) + queryParams.put("maxCorpusCount", String.valueOf(maxCorpusCount)); + if(!"null".equals(String.valueOf(minDictionaryCount))) + queryParams.put("minDictionaryCount", String.valueOf(minDictionaryCount)); + if(!"null".equals(String.valueOf(maxDictionaryCount))) + queryParams.put("maxDictionaryCount", String.valueOf(maxDictionaryCount)); + if(!"null".equals(String.valueOf(minLength))) + queryParams.put("minLength", String.valueOf(minLength)); + if(!"null".equals(String.valueOf(maxLength))) + queryParams.put("maxLength", String.valueOf(maxLength)); + if(!"null".equals(String.valueOf(sortBy))) + queryParams.put("sortBy", String.valueOf(sortBy)); + if(!"null".equals(String.valueOf(sortOrder))) + queryParams.put("sortOrder", String.valueOf(sortOrder)); + if(!"null".equals(String.valueOf(limit))) + queryParams.put("limit", String.valueOf(limit)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (List) ApiInvoker.deserialize(response, "List", WordObject.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + public WordObject getRandomWord (String includePartOfSpeech, String excludePartOfSpeech, String hasDictionaryDef, Integer minCorpusCount, Integer maxCorpusCount, Integer minDictionaryCount, Integer maxDictionaryCount, Integer minLength, Integer maxLength) throws ApiException { + // create path and map variables + String path = "/words.{format}/randomWord".replaceAll("\\{format\\}","json"); + + // query params + Map queryParams = new HashMap(); + Map headerParams = new HashMap(); + + if(!"null".equals(String.valueOf(hasDictionaryDef))) + queryParams.put("hasDictionaryDef", String.valueOf(hasDictionaryDef)); + if(!"null".equals(String.valueOf(includePartOfSpeech))) + queryParams.put("includePartOfSpeech", String.valueOf(includePartOfSpeech)); + if(!"null".equals(String.valueOf(excludePartOfSpeech))) + queryParams.put("excludePartOfSpeech", String.valueOf(excludePartOfSpeech)); + if(!"null".equals(String.valueOf(minCorpusCount))) + queryParams.put("minCorpusCount", String.valueOf(minCorpusCount)); + if(!"null".equals(String.valueOf(maxCorpusCount))) + queryParams.put("maxCorpusCount", String.valueOf(maxCorpusCount)); + if(!"null".equals(String.valueOf(minDictionaryCount))) + queryParams.put("minDictionaryCount", String.valueOf(minDictionaryCount)); + if(!"null".equals(String.valueOf(maxDictionaryCount))) + queryParams.put("maxDictionaryCount", String.valueOf(maxDictionaryCount)); + if(!"null".equals(String.valueOf(minLength))) + queryParams.put("minLength", String.valueOf(minLength)); + if(!"null".equals(String.valueOf(maxLength))) + queryParams.put("maxLength", String.valueOf(maxLength)); + try { + String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams); + if(response != null){ + return (WordObject) ApiInvoker.deserialize(response, "", WordObject.class); + } + else { + return null; + } + } catch (ApiException ex) { + if(ex.getCode() == 404) { + return null; + } + else { + throw ex; + } + } + } + } + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/common/ApiException.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/common/ApiException.java new file mode 100644 index 00000000000..8c96d599bb4 --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/common/ApiException.java @@ -0,0 +1,29 @@ +package com.wordnik.client.common; + +public class ApiException extends Exception { + int code = 0; + String message = null; + + public ApiException() {} + + public ApiException(int code, String message) { + this.code = code; + this.message = message; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/common/ApiInvoker.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/common/ApiInvoker.java new file mode 100644 index 00000000000..25eeed73666 --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/common/ApiInvoker.java @@ -0,0 +1,135 @@ +package com.wordnik.client.common; + +import com.wordnik.swagger.core.util.JsonUtil; + +import com.fasterxml.jackson.core.JsonGenerator.Feature; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +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.api.client.WebResource.Builder; + +import javax.ws.rs.core.MediaType; + +import java.util.Map; +import java.util.HashMap; +import java.util.List; +import java.io.IOException; + +public class ApiInvoker { + private static ApiInvoker INSTANCE = new ApiInvoker(); + private Map hostMap = new HashMap(); + private Map defaultHeaderMap = new HashMap(); + + public static ApiInvoker getInstance() { + return INSTANCE; + } + + public void addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + } + + public String escapeString(String str) { + return str; + } + + public static Object deserialize(String json, String containerType, Class cls) throws ApiException { + try{ + if("List".equals(containerType)) { + JavaType typeInfo = JsonUtil.getJsonMapper().getTypeFactory().constructCollectionType(List.class, cls); + List response = (List) JsonUtil.getJsonMapper().readValue(json, typeInfo); + return response; + } + else if(String.class.equals(cls)) { + if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1) { + return json.substring(1, json.length() - 2); + } + else + return json; + } + else { + return JsonUtil.getJsonMapper().readValue(json, cls); + } + } + catch (IOException e) { + throw new ApiException(500, e.getMessage()); + } + } + + public static String serialize(Object obj) throws ApiException { + try { + 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 queryParams, Object body, Map headerParams) throws ApiException { + Client client = getClient(host); + + StringBuilder b = new StringBuilder(); + + for(String key : queryParams.keySet()) { + String value = queryParams.get(key); + if (value != null){ + 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"); + for(String key : headerParams.keySet()) { + builder.header(key, headerParams.get(key)); + } + + for(String key : defaultHeaderMap.keySet()) { + if(!headerParams.containsKey(key)) { + builder.header(key, defaultHeaderMap.get(key)); + } + } + ClientResponse response = null; + + if("GET".equals(method)) { + response = (ClientResponse) builder.get(ClientResponse.class); + } + else if ("POST".equals(method)) { + response = builder.post(ClientResponse.class, serialize(body)); + } + else if ("PUT".equals(method)) { + response = builder.put(ClientResponse.class, serialize(body)); + } + else if ("DELETE".equals(method)) { + response = builder.delete(ClientResponse.class, serialize(body)); + } + else { + throw new ApiException(500, "unknown method type " + method); + } + if(response.getClientResponseStatus() == ClientResponse.Status.OK) { + return (String) response.getEntity(String.class); + } + else { + throw new ApiException( + response.getClientResponseStatus().getStatusCode(), + response.getEntity(String.class)); + } + } + + 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); + } +} + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/ApiTokenStatus.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/ApiTokenStatus.java new file mode 100644 index 00000000000..611c29b5248 --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/ApiTokenStatus.java @@ -0,0 +1,66 @@ +package com.wordnik.client.model; + +public class ApiTokenStatus { + private Boolean valid = null; + private String token = null; + private Long resetsInMillis = null; + private Long remainingCalls = null; + private Long expiresInMillis = null; + private Long totalRequests = null; + public Boolean getValid() { + return valid; + } + public void setValid(Boolean valid) { + this.valid = valid; + } + + public String getToken() { + return token; + } + public void setToken(String token) { + this.token = token; + } + + public Long getResetsInMillis() { + return resetsInMillis; + } + public void setResetsInMillis(Long resetsInMillis) { + this.resetsInMillis = resetsInMillis; + } + + public Long getRemainingCalls() { + return remainingCalls; + } + public void setRemainingCalls(Long remainingCalls) { + this.remainingCalls = remainingCalls; + } + + public Long getExpiresInMillis() { + return expiresInMillis; + } + public void setExpiresInMillis(Long expiresInMillis) { + this.expiresInMillis = expiresInMillis; + } + + public Long getTotalRequests() { + return totalRequests; + } + public void setTotalRequests(Long totalRequests) { + this.totalRequests = totalRequests; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiTokenStatus {\n"); + sb.append(" valid: ").append(valid).append("\n"); + sb.append(" token: ").append(token).append("\n"); + sb.append(" resetsInMillis: ").append(resetsInMillis).append("\n"); + sb.append(" remainingCalls: ").append(remainingCalls).append("\n"); + sb.append(" expiresInMillis: ").append(expiresInMillis).append("\n"); + sb.append(" totalRequests: ").append(totalRequests).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/AudioFile.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/AudioFile.java new file mode 100644 index 00000000000..8c7caf0e499 --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/AudioFile.java @@ -0,0 +1,139 @@ +package com.wordnik.client.model; + +import java.util.Date; +public class AudioFile { + private String attributionUrl = null; + private Integer commentCount = null; + private Integer voteCount = null; + private String fileUrl = null; + private String audioType = null; + private Long id = null; + private Double duration = null; + private String attributionText = null; + private String createdBy = null; + private String description = null; + private Date createdAt = null; + private Float voteWeightedAverage = null; + private Float voteAverage = null; + private String word = null; + public String getAttributionUrl() { + return attributionUrl; + } + public void setAttributionUrl(String attributionUrl) { + this.attributionUrl = attributionUrl; + } + + public Integer getCommentCount() { + return commentCount; + } + public void setCommentCount(Integer commentCount) { + this.commentCount = commentCount; + } + + public Integer getVoteCount() { + return voteCount; + } + public void setVoteCount(Integer voteCount) { + this.voteCount = voteCount; + } + + public String getFileUrl() { + return fileUrl; + } + public void setFileUrl(String fileUrl) { + this.fileUrl = fileUrl; + } + + public String getAudioType() { + return audioType; + } + public void setAudioType(String audioType) { + this.audioType = audioType; + } + + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + public Double getDuration() { + return duration; + } + public void setDuration(Double duration) { + this.duration = duration; + } + + public String getAttributionText() { + return attributionText; + } + public void setAttributionText(String attributionText) { + this.attributionText = attributionText; + } + + public String getCreatedBy() { + return createdBy; + } + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedAt() { + return createdAt; + } + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Float getVoteWeightedAverage() { + return voteWeightedAverage; + } + public void setVoteWeightedAverage(Float voteWeightedAverage) { + this.voteWeightedAverage = voteWeightedAverage; + } + + public Float getVoteAverage() { + return voteAverage; + } + public void setVoteAverage(Float voteAverage) { + this.voteAverage = voteAverage; + } + + public String getWord() { + return word; + } + public void setWord(String word) { + this.word = word; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AudioFile {\n"); + sb.append(" attributionUrl: ").append(attributionUrl).append("\n"); + sb.append(" commentCount: ").append(commentCount).append("\n"); + sb.append(" voteCount: ").append(voteCount).append("\n"); + sb.append(" fileUrl: ").append(fileUrl).append("\n"); + sb.append(" audioType: ").append(audioType).append("\n"); + sb.append(" id: ").append(id).append("\n"); + sb.append(" duration: ").append(duration).append("\n"); + sb.append(" attributionText: ").append(attributionText).append("\n"); + sb.append(" createdBy: ").append(createdBy).append("\n"); + sb.append(" description: ").append(description).append("\n"); + sb.append(" createdAt: ").append(createdAt).append("\n"); + sb.append(" voteWeightedAverage: ").append(voteWeightedAverage).append("\n"); + sb.append(" voteAverage: ").append(voteAverage).append("\n"); + sb.append(" word: ").append(word).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/AuthenticationToken.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/AuthenticationToken.java new file mode 100644 index 00000000000..55ec81c9ee5 --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/AuthenticationToken.java @@ -0,0 +1,39 @@ +package com.wordnik.client.model; + +public class AuthenticationToken { + private String token = null; + private Long userId = null; + private String userSignature = null; + public String getToken() { + return token; + } + public void setToken(String token) { + this.token = token; + } + + public Long getUserId() { + return userId; + } + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getUserSignature() { + return userSignature; + } + public void setUserSignature(String userSignature) { + this.userSignature = userSignature; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AuthenticationToken {\n"); + sb.append(" token: ").append(token).append("\n"); + sb.append(" userId: ").append(userId).append("\n"); + sb.append(" userSignature: ").append(userSignature).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/Bigram.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/Bigram.java new file mode 100644 index 00000000000..6333ec40341 --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/Bigram.java @@ -0,0 +1,57 @@ +package com.wordnik.client.model; + +public class Bigram { + private Long count = null; + private String gram2 = null; + private String gram1 = null; + private Double wlmi = null; + private Double mi = null; + public Long getCount() { + return count; + } + public void setCount(Long count) { + this.count = count; + } + + public String getGram2() { + return gram2; + } + public void setGram2(String gram2) { + this.gram2 = gram2; + } + + public String getGram1() { + return gram1; + } + public void setGram1(String gram1) { + this.gram1 = gram1; + } + + public Double getWlmi() { + return wlmi; + } + public void setWlmi(Double wlmi) { + this.wlmi = wlmi; + } + + public Double getMi() { + return mi; + } + public void setMi(Double mi) { + this.mi = mi; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Bigram {\n"); + sb.append(" count: ").append(count).append("\n"); + sb.append(" gram2: ").append(gram2).append("\n"); + sb.append(" gram1: ").append(gram1).append("\n"); + sb.append(" wlmi: ").append(wlmi).append("\n"); + sb.append(" mi: ").append(mi).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/Citation.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/Citation.java new file mode 100644 index 00000000000..a61e60ce76b --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/Citation.java @@ -0,0 +1,30 @@ +package com.wordnik.client.model; + +public class Citation { + private String cite = null; + private String source = null; + public String getCite() { + return cite; + } + public void setCite(String cite) { + this.cite = cite; + } + + public String getSource() { + return source; + } + public void setSource(String source) { + this.source = source; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Citation {\n"); + sb.append(" cite: ").append(cite).append("\n"); + sb.append(" source: ").append(source).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/ContentProvider.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/ContentProvider.java new file mode 100644 index 00000000000..7068c9756a0 --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/ContentProvider.java @@ -0,0 +1,30 @@ +package com.wordnik.client.model; + +public class ContentProvider { + private Integer id = null; + private String name = null; + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ContentProvider {\n"); + sb.append(" id: ").append(id).append("\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} + diff --git a/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/Definition.java b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/Definition.java new file mode 100644 index 00000000000..0a729b15808 --- /dev/null +++ b/samples/client/wordnik-api/java/src/main/java/com/wordnik/client/model/Definition.java @@ -0,0 +1,163 @@ +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.Related; +public class Definition { + private String extendedText = null; + private String text = null; + private String sourceDictionary = null; + private List citations = new ArrayList(); + private List