diff --git a/.swagger-codegen-ignore b/.swagger-codegen-ignore new file mode 100644 index 0000000..716bcf1 --- /dev/null +++ b/.swagger-codegen-ignore @@ -0,0 +1,32 @@ +# Swagger Codegen Ignore + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md + +# Swagger and Git files +.swagger-codegen-ignore +git_push.sh + +# Project files +LICENSE +gradle* +build.sbt +.travis.yml diff --git a/.swagger-codegen/VERSION b/.swagger-codegen/VERSION new file mode 100644 index 0000000..19244e8 --- /dev/null +++ b/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.4.21 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..27bab52 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +sudo: required +dist: trusty +install: true + +branches: + only: + - master + +language: java + +notifications: + email: + recipients: + - devcenter@docusign.com + on_success: never + on_failure: change + +jdk: + - oraclejdk11 + - oraclejdk12 + - oraclejdk13 + +script: mvn -X clean test + +after_failure: "cat /home/travis/build/docusign/docusign-java-client/target/surefire-reports/SdkUnitTests.txt && cat /home/travis/build/docusign/docusign-java-client/target/surefire-reports/TEST-SdkUnitTests.xml" + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f17a7fc --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,24 @@ +## [v1.0.2-RC12] - WebForms API v1.1.0-1.0.2 - 2024-02-09 +### Breaking Changes + +- **`baseUrl` Defaulting to DEMO URL:** + - The `baseUrl` now defaults to the DEMO URL if not provided. Please update your configurations accordingly. + +### Other Changes + +- Updated the SDK release version +## [v1.0.2-RC11] - WebForms API v1.1.0-1.0.2 - 2024-02-08 +### Changed +- Added support for version v1.1.0-1.0.2 of the DocuSign WebForms API. +- Updated the SDK release version. + +## [v1.0.1-RC9] - WebForms API v1.1.0-1.0.1 - 2024-02-05 +### Changed +- Added support for version v1.1.0-1.0.1 of the DocuSign WebForms API. +- Updated the SDK release version. + +## [v1.0.0] - WebForms API v1.1-1.1.1 - 2023-11-27 +### Changed +- Added support for version v1.1-1.1.1 of the DocuSign WebForms API. +- Updated the SDK release version. + diff --git a/LICENSE b/LICENSE index 71a5961..95b3f89 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2024 DocuSign Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +The MIT License + +Copyright (c) 2023- DocuSign, Inc. (https://www.docusign.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 5d4b02c..aea4cd0 100644 --- a/README.md +++ b/README.md @@ -1 +1,78 @@ -# docusign-webforms-java-client \ No newline at end of file +# The Official DocuSign WebForms Java Client SDK + +[![Build status][travis-image]][travis-url] +[![Maven Central status][maven-image]][maven-url] + +## Requirements +* Java 1.9+ +* Free [developer account](https://go.docusign.com/sandbox/productshot/?elqCampaignId=16531) + +## Compatibility +* Java 1.9+ +## Note + +This open-source SDK is provided for cases where you would like to make additional changes that the SDK does not + provide out-of-the-box. If you simply want to use the SDK with any of the examples shown in the [Developer Center ](https://developers.docusign.com/docs/webforms-api), follow the installation instructions below. + +## Installation + +Note: DocuSign uses **Eclipse** with **Maven** for testing purposes. + +### Maven: +1. In Eclipse, create a new project by selecting **File** -> **New** -> **Project**. +2. In the **New Project Wizard** , expand **Maven** , then select **Maven Project.** +3. Leave **Create a simple project** unchecked. +4. Select **Next** , then provide a unique **Group** and **Artifact Id**. +5. In the directory where you've saved your project, open the _pom.xml_ file. +6. In the _pom.xml_ file, locate the **dependencies** node. +7. Add: + +``` + + com.docusign + docusign-admin-java + 1.1.0 + +``` + +8. If your project is still open, restart **Eclipse**. + +## Dependencies +This client has the following external dependencies: +* io.swagger:swagger-annotations:jar:1.5.17 +* org.glassfish.jersey.core:jersey-client:jar:2.29.1 +* org.glassfish.jersey.media:jersey-media-multipart:jar:2.29.1 +* org.glassfish.jersey.media:jersey-media-json-jackson:2.29.1 +* com.fasterxml.jackson.core:jackson-core:jar:2.12.1 +* com.fasterxml.jackson.core:jackson-annotations:jar:2.12.1 +* com.fasterxml.jackson.core:jackson-databind:2.12.1 +- com.brsanthu:migbase64:2.2 +* junit:junit:jar:4.13.1 +* com.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.2 +* com.auth0:java-jwt:3.4.1 +* org.bouncycastle:bcprov-jdk15on:1.60 + +## Code examples +You can find on our GitHub a self-executing package of code examples for the WebForms Java SDK, called a [Launcher](https://github.com/docusign/code-examples-java/blob/master/README.md), that demonstrates common use cases. You can also download a version preconfigured for your DocuSign developer account from [Quickstart](https://developers.docusign.com/docs/webforms-rest-api/quickstart/). These examples can use either the [Authorization Code Grant](https://developers.docusign.com/webforms-rest-api/guides/authentication/oauth2-code-grant) or [JSON Web Token (JWT)](https://developers.docusign.com/webforms-rest-api/guides/authentication/oauth2-jsonwebtoken) authentication workflows. + +## OAuth implementations +For details regarding which type of OAuth grant will work best for your DocuSign integration, see [Choose OAuth Type](https://developers.docusign.com/platform/auth/choose/) in the [DocuSign Developer Center](https://developers.docusign.com/). + +For security purposes, DocuSign recommends using the [Authorization Code Grant](https://developers.docusign.com/webforms-rest-api/guides/authentication/oauth2-code-grant) flow. + +## Support +Log issues against this client through GitHub. We also have an [active developer community on Stack Overflow](https://stackoverflow.com/questions/tagged/docusignapi). + +## License +The DocuSign WebForms Java Client SDK is licensed under the [MIT License](https://github.com/docusign/docusign-java-client/blob/master/LICENSE). + +### Additional resources +* [DocuSign Developer Center](https://developers.docusign.com/) +* [DocuSign API on Twitter](https://twitter.com/docusignapi) +* [DocuSign For Developers on LinkedIn](https://www.linkedin.com/showcase/docusign-for-developers/) +* [DocuSign For Developers on YouTube](https://www.youtube.com/channel/UCJSJ2kMs_qeQotmw4-lX2NQ) + +[travis-image]: https://api.travis-ci.com/docusign/docusign-webforms-java-client.svg?branch=master +[travis-url]: https://app.travis-ci.com/github/docusign/docusign-webforms-java-client +[maven-image]: https://img.shields.io/maven-central/v/com.docusign/docusign-webforms-java.svg?style=flat +[maven-url]: https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.docusign%22 diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..4653fd6 --- /dev/null +++ b/build.gradle @@ -0,0 +1,144 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' + +group = 'com.docusign' +version = '1.0.0' + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.3.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' + classpath 'ch.raffael.pegdown-doclet:pegdown-doclet:1.3' + } +} + +repositories { + jcenter() +} + +apply plugin: 'ch.raffael.pegdown-doclet' + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 25 + buildToolsVersion '25.0.2' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 25 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + + dependencies { + provided 'javax.annotation:jsr250-api:1.0' + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file("${project.buildDir}/outputs/jar") + task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task); + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven' + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + + install { + repositories.mavenInstaller { + pom.artifactId = 'docusign-webforms-java' + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } + + task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource + } + + task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir + } + + artifacts { + archives sourcesJar + archives javadocJar + } +} + +task getDeps(type: Copy) { + from sourceSets.main.runtimeClasspath + into 'target/lib' +} + +ext { + swagger_annotations_version = "1.5.17" + jackson_version = "2.10.1" + jersey_version = "2.29.1" + junit_version = "4.12" + oltu_version = "1.0.2" + jwt_version = "3.4.1" + bouncy_version = "1.60" +} + +dependencies { + compile "io.swagger:swagger-annotations:$swagger_annotations_version" + compile "org.glassfish.jersey.core:jersey-client:$jersey_version" + compile "org.glassfish.jersey.media:jersey-media-multipart:$jersey_version" + compile "org.glassfish.jersey.media:jersey-media-json-jackson:$jersey_version" + compile group: "org.glassfish.jersey.inject", name: "jersey-hk2", version: "2.26" + compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" + compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" + compile "org.glassfish.jersey.inject:jersey-hk2:$jersey_version" + compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version" + testCompile "junit:junit:$junit_version" + compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version" + compile "com.auth0:java-jwt:$jwt_version" + compile "org.bouncycastle:bcprov-jdk15on:$bouncy_version" +} + diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 0000000..ab16788 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,328 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..b7a3647 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue May 17 23:08:05 CST 2016 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..7c353ce --- /dev/null +++ b/pom.xml @@ -0,0 +1,403 @@ + + 4.0.0 + com.docusign + docusign-webforms-java + jar + docusign-webforms-java + 1.0.2-RC12 + https://developers.docusign.com + The DocuSign NuGet package makes integrating DocuSign into your apps and websites a super fast and painless process. The library is open sourced on GitHub, look for the docusign-webforms-csharp-client repository. + + + 2.2.0 + + + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + ossrh2 + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + scm:git:git@github.com:docusign/docusign-webforms-java-client.git + scm:git:git@github.com:docusign/docusign-webforms-java-client.git + git@github.com:docusign/docusign-webforms-java-client.git + + + + + DocuSign WebForms Java Client License + https://raw.githubusercontent.com/docusign/docusign-webforms-java-client/master/LICENSE + repo + + + + + + DocuSign Developer Center + devcenter@docusign.com + DocuSign + https://developers.docusign.com + + + + + + + com.diffplug.spotless + spotless-maven-plugin + 2.12.1 + + + + + src/main/java/**/*.java + src/test/java/**/*.java + + + + + + + + 1.7 + + + + + + + + apply + + compile + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.1.2 + + ${project.basedir}/checkstyle.xml + + + + + checkstyle + + compile + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M1 + + + enforce-maven + + enforce + + + + + 2.2.0 + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M3 + + alphabetical + -Xms512m -Xmx1500m + methods + true + 1 + false + 1 + false + + **/*Tests.java + + + + + org.apache.maven.surefire + surefire-junit47 + 3.0.0-M3 + + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.1 + + + + test-jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.10 + + + 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 + 3.6.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.4 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.3.0 + + + package + + shade + + + true + shaded + + + junit:junit:jar: + org.hamcrest:hamcrest-core:jar + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + --pinentry-mode + loopback + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + + ossrh + https://s01.oss.sonatype.org/ + true + + + + + + + + io.swagger.core.v3 + swagger-annotations + ${swagger-core-version} + + + + + org.glassfish.jersey.core + jersey-client + ${jersey-version} + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey-version} + + + org.glassfish.jersey.media + jersey-media-json-jackson + ${jersey-version} + + + + org.glassfish.jersey.inject + jersey-hk2 + ${jersey-version} + + + + com.fasterxml.jackson.jakarta.rs + jackson-jakarta-rs-base + ${jackson-version} + + + org.apache.oltu.oauth2 + org.apache.oltu.oauth2.client + ${oltu-version} + + + + com.auth0 + java-jwt + 3.4.1 + + + org.bouncycastle + bcprov-jdk15on + 1.69 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-csv + ${jackson-version} + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson-version} + + + + junit + junit + ${junit-version} + test + + + com.brsanthu + migbase64 + 2.2 + compile + + + jakarta.ws.rs + jakarta.ws.rs-api + 3.1.0 + compile + + + com.brsanthu + migbase64 + 2.2 + + + + UTF-8 + 2.2.8 + 3.0.9 + 2.14.2 + 4.13.1 + 1.0.2 + + diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..904b4f4 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "docusign-webforms-java" \ No newline at end of file diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml new file mode 100644 index 0000000..bb051f6 --- /dev/null +++ b/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/src/main/java/com/docusign/webforms/api/FormInstanceManagementApi.java b/src/main/java/com/docusign/webforms/api/FormInstanceManagementApi.java new file mode 100644 index 0000000..b47fd62 --- /dev/null +++ b/src/main/java/com/docusign/webforms/api/FormInstanceManagementApi.java @@ -0,0 +1,394 @@ + +package com.docusign.webforms.api; + +import jakarta.ws.rs.core.GenericType; + +import com.docusign.webforms.client.ApiException; +import com.docusign.webforms.client.ApiClient; +import com.docusign.webforms.client.Configuration; +import com.docusign.webforms.model.*; +import com.docusign.webforms.client.Pair; +import com.docusign.webforms.client.ApiResponse; + + + + +/** + * FormInstanceManagementApi class. + * + **/ +public class FormInstanceManagementApi { + private ApiClient apiClient; + + /** + * FormInstanceManagementApi. + * + **/ + public FormInstanceManagementApi() { + this(Configuration.getDefaultApiClient()); + } + + /** + * FormInstanceManagementApi. + * + **/ + public FormInstanceManagementApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * getApiClient Method. + * + * @return ApiClient + **/ + public ApiClient getApiClient() { + return apiClient; + } + + /** + * setApiClient Method. + * + **/ + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + + /** + * Creates an instance of the web form. + * Creates an instance of the web form. + * @param accountId Account identifier in which the web form resides (required) + * @param formId Unique identifier for a web form entity that is consistent for it's lifetime (required) + * @param createInstanceBody Request body containing properties that will be used to create instance. (required) + * @return WebFormInstance + * @throws ApiException if fails to make API call + */ + public WebFormInstance createInstance(String accountId, String formId, CreateInstanceRequestBody createInstanceBody) throws ApiException { + ApiResponse localVarResponse = createInstanceWithHttpInfo(accountId, formId, createInstanceBody); + return localVarResponse.getData(); + } + + /** + * Creates an instance of the web form + * Creates an instance of the web form. + * @param accountId Account identifier in which the web form resides (required) + * @param formId Unique identifier for a web form entity that is consistent for it's lifetime (required) + * @param createInstanceBody Request body containing properties that will be used to create instance. (required) + * @return WebFormInstance + * @throws ApiException if fails to make API call + */ + public ApiResponse createInstanceWithHttpInfo(String accountId, String formId, CreateInstanceRequestBody createInstanceBody) throws ApiException { + Object localVarPostBody = createInstanceBody; + + // verify the required parameter 'accountId' is set + if (accountId == null) { + throw new ApiException(400, "Missing the required parameter 'accountId' when calling createInstance"); + } + + // verify the required parameter 'formId' is set + if (formId == null) { + throw new ApiException(400, "Missing the required parameter 'formId' when calling createInstance"); + } + + // verify the required parameter 'createInstanceBody' is set + if (createInstanceBody == null) { + throw new ApiException(400, "Missing the required parameter 'createInstanceBody' when calling createInstance"); + } + + // create path and map variables + String localVarPath = "/accounts/{account_id}/forms/{form_id}/instances" + .replaceAll("\\{" + "account_id" + "\\}", apiClient.escapeString(accountId.toString())) + .replaceAll("\\{" + "form_id" + "\\}", apiClient.escapeString(formId.toString())); + + // query params + java.util.List localVarQueryParams = new java.util.ArrayList(); + java.util.List localVarCollectionQueryParams = new java.util.ArrayList(); + java.util.Map localVarHeaderParams = new java.util.HashMap(); + java.util.Map localVarFormParams = new java.util.HashMap(); + + + + + + + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "docusignAccessCode" }; + + GenericType localVarReturnType = new GenericType() {}; + WebFormInstance localVarResponse = apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + return new ApiResponse(apiClient.getStatusCode(), apiClient.getResponseHeaders(), localVarResponse); + } + + /** + * Get form instance. + * Retrieves instance information filter by instance id + * @param accountId Account identifier in which the web form resides (required) + * @param formId Unique identifier for a web form entity that is consistent for it's lifetime (required) + * @param instanceId Unique identifier for a Web Form Instance that is consistent until its expiration (required) + * @return WebFormInstance + * @throws ApiException if fails to make API call + */ + public WebFormInstance getInstance(String accountId, String formId, String instanceId) throws ApiException { + ApiResponse localVarResponse = getInstanceWithHttpInfo(accountId, formId, instanceId); + return localVarResponse.getData(); + } + + /** + * Get form instance + * Retrieves instance information filter by instance id + * @param accountId Account identifier in which the web form resides (required) + * @param formId Unique identifier for a web form entity that is consistent for it's lifetime (required) + * @param instanceId Unique identifier for a Web Form Instance that is consistent until its expiration (required) + * @return WebFormInstance + * @throws ApiException if fails to make API call + */ + public ApiResponse getInstanceWithHttpInfo(String accountId, String formId, String instanceId) throws ApiException { + Object localVarPostBody = "{}"; + + // verify the required parameter 'accountId' is set + if (accountId == null) { + throw new ApiException(400, "Missing the required parameter 'accountId' when calling getInstance"); + } + + // verify the required parameter 'formId' is set + if (formId == null) { + throw new ApiException(400, "Missing the required parameter 'formId' when calling getInstance"); + } + + // verify the required parameter 'instanceId' is set + if (instanceId == null) { + throw new ApiException(400, "Missing the required parameter 'instanceId' when calling getInstance"); + } + + // create path and map variables + String localVarPath = "/accounts/{account_id}/forms/{form_id}/instances/{instance_id}" + .replaceAll("\\{" + "account_id" + "\\}", apiClient.escapeString(accountId.toString())) + .replaceAll("\\{" + "form_id" + "\\}", apiClient.escapeString(formId.toString())) + .replaceAll("\\{" + "instance_id" + "\\}", apiClient.escapeString(instanceId.toString())); + + // query params + java.util.List localVarQueryParams = new java.util.ArrayList(); + java.util.List localVarCollectionQueryParams = new java.util.ArrayList(); + java.util.Map localVarHeaderParams = new java.util.HashMap(); + java.util.Map localVarFormParams = new java.util.HashMap(); + + + + + + + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "docusignAccessCode" }; + + GenericType localVarReturnType = new GenericType() {}; + WebFormInstance localVarResponse = apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + return new ApiResponse(apiClient.getStatusCode(), apiClient.getResponseHeaders(), localVarResponse); + } + /// + /// List instances List all the instances of a web form in an account. When filtered by clientUserId, it will return instances having same clientUserId + /// + + /** + * ListInstancesOptions Class. + * + **/ + public class ListInstancesOptions + { + private String clientUserId = null; + + /** + * setClientUserId method. + */ + public void setClientUserId(String clientUserId) { + this.clientUserId = clientUserId; + } + + /** + * getClientUserId method. + * + * @return String + */ + public String getClientUserId() { + return this.clientUserId; + } + } + + /** + * List instances. + * List all the instances of a web form in an account. When filtered by clientUserId, it will return instances having same clientUserId + * @param accountId Account identifier in which the web form resides (required) + * @param formId Unique identifier for a web form that is consistent for it's lifetime (required) + * @return WebFormInstanceList + */ + public WebFormInstanceList listInstances(String accountId, String formId) throws ApiException { + return listInstances(accountId, formId, null); + } + + /** + * List instances. + * List all the instances of a web form in an account. When filtered by clientUserId, it will return instances having same clientUserId + * @param accountId Account identifier in which the web form resides (required) + * @param formId Unique identifier for a web form that is consistent for it's lifetime (required) + * @param options for modifying the method behavior. + * @return WebFormInstanceList + * @throws ApiException if fails to make API call + */ + public WebFormInstanceList listInstances(String accountId, String formId, FormInstanceManagementApi.ListInstancesOptions options) throws ApiException { + ApiResponse localVarResponse = listInstancesWithHttpInfo(accountId, formId, options); + return localVarResponse.getData(); + } + + /** + * List instances + * List all the instances of a web form in an account. When filtered by clientUserId, it will return instances having same clientUserId + * @param accountId Account identifier in which the web form resides (required) + * @param formId Unique identifier for a web form that is consistent for it's lifetime (required) + * @param options for modifying the method behavior. + * @return WebFormInstanceList + * @throws ApiException if fails to make API call + */ + public ApiResponse listInstancesWithHttpInfo(String accountId, String formId, FormInstanceManagementApi.ListInstancesOptions options) throws ApiException { + Object localVarPostBody = "{}"; + + // verify the required parameter 'accountId' is set + if (accountId == null) { + throw new ApiException(400, "Missing the required parameter 'accountId' when calling listInstances"); + } + + // verify the required parameter 'formId' is set + if (formId == null) { + throw new ApiException(400, "Missing the required parameter 'formId' when calling listInstances"); + } + + // create path and map variables + String localVarPath = "/accounts/{account_id}/forms/{form_id}/instances" + .replaceAll("\\{" + "account_id" + "\\}", apiClient.escapeString(accountId.toString())) + .replaceAll("\\{" + "form_id" + "\\}", apiClient.escapeString(formId.toString())); + + // query params + java.util.List localVarQueryParams = new java.util.ArrayList(); + java.util.List localVarCollectionQueryParams = new java.util.ArrayList(); + java.util.Map localVarHeaderParams = new java.util.HashMap(); + java.util.Map localVarFormParams = new java.util.HashMap(); + + if (options != null) { + localVarQueryParams.addAll(apiClient.parameterToPair("client_user_id", options.clientUserId)); + } + + + + + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "docusignAccessCode" }; + + GenericType localVarReturnType = new GenericType() {}; + WebFormInstanceList localVarResponse = apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + return new ApiResponse(apiClient.getStatusCode(), apiClient.getResponseHeaders(), localVarResponse); + } + + /** + * Refreshes the instance token. + * Generates new instance token for the existing Web Form Instance. + * @param accountId Account identifier in which the web form resides (required) + * @param formId Unique identifier for a web form entity that is consistent for it's lifetime (required) + * @param instanceId Unique identifier for a Web Form Instance that is consistent until its expiration (required) + * @return WebFormInstance + * @throws ApiException if fails to make API call + */ + public WebFormInstance refreshToken(String accountId, String formId, String instanceId) throws ApiException { + ApiResponse localVarResponse = refreshTokenWithHttpInfo(accountId, formId, instanceId); + return localVarResponse.getData(); + } + + /** + * Refreshes the instance token + * Generates new instance token for the existing Web Form Instance. + * @param accountId Account identifier in which the web form resides (required) + * @param formId Unique identifier for a web form entity that is consistent for it's lifetime (required) + * @param instanceId Unique identifier for a Web Form Instance that is consistent until its expiration (required) + * @return WebFormInstance + * @throws ApiException if fails to make API call + */ + public ApiResponse refreshTokenWithHttpInfo(String accountId, String formId, String instanceId) throws ApiException { + Object localVarPostBody = "{}"; + + // verify the required parameter 'accountId' is set + if (accountId == null) { + throw new ApiException(400, "Missing the required parameter 'accountId' when calling refreshToken"); + } + + // verify the required parameter 'formId' is set + if (formId == null) { + throw new ApiException(400, "Missing the required parameter 'formId' when calling refreshToken"); + } + + // verify the required parameter 'instanceId' is set + if (instanceId == null) { + throw new ApiException(400, "Missing the required parameter 'instanceId' when calling refreshToken"); + } + + // create path and map variables + String localVarPath = "/accounts/{account_id}/forms/{form_id}/instances/{instance_id}/refresh" + .replaceAll("\\{" + "account_id" + "\\}", apiClient.escapeString(accountId.toString())) + .replaceAll("\\{" + "form_id" + "\\}", apiClient.escapeString(formId.toString())) + .replaceAll("\\{" + "instance_id" + "\\}", apiClient.escapeString(instanceId.toString())); + + // query params + java.util.List localVarQueryParams = new java.util.ArrayList(); + java.util.List localVarCollectionQueryParams = new java.util.ArrayList(); + java.util.Map localVarHeaderParams = new java.util.HashMap(); + java.util.Map localVarFormParams = new java.util.HashMap(); + + + + + + + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "docusignAccessCode" }; + + GenericType localVarReturnType = new GenericType() {}; + WebFormInstance localVarResponse = apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + return new ApiResponse(apiClient.getStatusCode(), apiClient.getResponseHeaders(), localVarResponse); + } +} diff --git a/src/main/java/com/docusign/webforms/api/FormManagementApi.java b/src/main/java/com/docusign/webforms/api/FormManagementApi.java new file mode 100644 index 0000000..52ba32c --- /dev/null +++ b/src/main/java/com/docusign/webforms/api/FormManagementApi.java @@ -0,0 +1,383 @@ + +package com.docusign.webforms.api; + +import jakarta.ws.rs.core.GenericType; + +import com.docusign.webforms.client.ApiException; +import com.docusign.webforms.client.ApiClient; +import com.docusign.webforms.client.Configuration; +import com.docusign.webforms.model.*; +import com.docusign.webforms.client.Pair; +import com.docusign.webforms.client.ApiResponse; + + + + +/** + * FormManagementApi class. + * + **/ +public class FormManagementApi { + private ApiClient apiClient; + + /** + * FormManagementApi. + * + **/ + public FormManagementApi() { + this(Configuration.getDefaultApiClient()); + } + + /** + * FormManagementApi. + * + **/ + public FormManagementApi(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /** + * getApiClient Method. + * + * @return ApiClient + **/ + public ApiClient getApiClient() { + return apiClient; + } + + /** + * setApiClient Method. + * + **/ + public void setApiClient(ApiClient apiClient) { + this.apiClient = apiClient; + } + + /// + /// Get Form Retrieves form information filter by form id and state. The `state` parameter is optional and can accept value from `draft, active`. + /// + + /** + * GetFormOptions Class. + * + **/ + public class GetFormOptions + { + private String state = null; + + /** + * setState method. + */ + public void setState(String state) { + this.state = state; + } + + /** + * getState method. + * + * @return String + */ + public String getState() { + return this.state; + } + } + + /** + * Get Form. + * Retrieves form information filter by form id and state. The `state` parameter is optional and can accept value from `draft, active`. + * @param accountId Account identifier in which the web form resides (required) + * @param formId Unique identifier for a web form that is consistent for it's lifetime (required) + * @return WebForm + */ + public WebForm getForm(String accountId, String formId) throws ApiException { + return getForm(accountId, formId, null); + } + + /** + * Get Form. + * Retrieves form information filter by form id and state. The `state` parameter is optional and can accept value from `draft, active`. + * @param accountId Account identifier in which the web form resides (required) + * @param formId Unique identifier for a web form that is consistent for it's lifetime (required) + * @param options for modifying the method behavior. + * @return WebForm + * @throws ApiException if fails to make API call + */ + public WebForm getForm(String accountId, String formId, FormManagementApi.GetFormOptions options) throws ApiException { + ApiResponse localVarResponse = getFormWithHttpInfo(accountId, formId, options); + return localVarResponse.getData(); + } + + /** + * Get Form + * Retrieves form information filter by form id and state. The `state` parameter is optional and can accept value from `draft, active`. + * @param accountId Account identifier in which the web form resides (required) + * @param formId Unique identifier for a web form that is consistent for it's lifetime (required) + * @param options for modifying the method behavior. + * @return WebForm + * @throws ApiException if fails to make API call + */ + public ApiResponse getFormWithHttpInfo(String accountId, String formId, FormManagementApi.GetFormOptions options) throws ApiException { + Object localVarPostBody = "{}"; + + // verify the required parameter 'accountId' is set + if (accountId == null) { + throw new ApiException(400, "Missing the required parameter 'accountId' when calling getForm"); + } + + // verify the required parameter 'formId' is set + if (formId == null) { + throw new ApiException(400, "Missing the required parameter 'formId' when calling getForm"); + } + + // create path and map variables + String localVarPath = "/accounts/{account_id}/forms/{form_id}" + .replaceAll("\\{" + "account_id" + "\\}", apiClient.escapeString(accountId.toString())) + .replaceAll("\\{" + "form_id" + "\\}", apiClient.escapeString(formId.toString())); + + // query params + java.util.List localVarQueryParams = new java.util.ArrayList(); + java.util.List localVarCollectionQueryParams = new java.util.ArrayList(); + java.util.Map localVarHeaderParams = new java.util.HashMap(); + java.util.Map localVarFormParams = new java.util.HashMap(); + + if (options != null) { + localVarQueryParams.addAll(apiClient.parameterToPair("state", options.state)); + } + + + + + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "docusignAccessCode" }; + + GenericType localVarReturnType = new GenericType() {}; + WebForm localVarResponse = apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + return new ApiResponse(apiClient.getStatusCode(), apiClient.getResponseHeaders(), localVarResponse); + } + /// + /// List Forms List all the forms for the active user that can be in an active or draft state + /// + + /** + * ListFormsOptions Class. + * + **/ + public class ListFormsOptions + { + private String userFilter = null; + private Boolean isStandalone = null; + private Boolean isPublished = null; + private String sortBy = null; + private String search = null; + private String startPosition = null; + private String count = null; + + /** + * setUserFilter method. + */ + public void setUserFilter(String userFilter) { + this.userFilter = userFilter; + } + + /** + * getUserFilter method. + * + * @return String + */ + public String getUserFilter() { + return this.userFilter; + } + + /** + * setIsStandalone method. + */ + public void setIsStandalone(Boolean isStandalone) { + this.isStandalone = isStandalone; + } + + /** + * getIsStandalone method. + * + * @return Boolean + */ + public Boolean getIsStandalone() { + return this.isStandalone; + } + + /** + * setIsPublished method. + */ + public void setIsPublished(Boolean isPublished) { + this.isPublished = isPublished; + } + + /** + * getIsPublished method. + * + * @return Boolean + */ + public Boolean getIsPublished() { + return this.isPublished; + } + + /** + * setSortBy method. + */ + public void setSortBy(String sortBy) { + this.sortBy = sortBy; + } + + /** + * getSortBy method. + * + * @return String + */ + public String getSortBy() { + return this.sortBy; + } + + /** + * setSearch method. + */ + public void setSearch(String search) { + this.search = search; + } + + /** + * getSearch method. + * + * @return String + */ + public String getSearch() { + return this.search; + } + + /** + * setStartPosition method. + */ + public void setStartPosition(String startPosition) { + this.startPosition = startPosition; + } + + /** + * getStartPosition method. + * + * @return String + */ + public String getStartPosition() { + return this.startPosition; + } + + /** + * setCount method. + */ + public void setCount(String count) { + this.count = count; + } + + /** + * getCount method. + * + * @return String + */ + public String getCount() { + return this.count; + } + } + + /** + * List Forms. + * List all the forms for the active user that can be in an active or draft state + * @param accountId Account identifier in which the webform resides (required) + * @return WebFormSummaryList + */ + public WebFormSummaryList listForms(String accountId) throws ApiException { + return listForms(accountId, null); + } + + /** + * List Forms. + * List all the forms for the active user that can be in an active or draft state + * @param accountId Account identifier in which the webform resides (required) + * @param options for modifying the method behavior. + * @return WebFormSummaryList + * @throws ApiException if fails to make API call + */ + public WebFormSummaryList listForms(String accountId, FormManagementApi.ListFormsOptions options) throws ApiException { + ApiResponse localVarResponse = listFormsWithHttpInfo(accountId, options); + return localVarResponse.getData(); + } + + /** + * List Forms + * List all the forms for the active user that can be in an active or draft state + * @param accountId Account identifier in which the webform resides (required) + * @param options for modifying the method behavior. + * @return WebFormSummaryList + * @throws ApiException if fails to make API call + */ + public ApiResponse listFormsWithHttpInfo(String accountId, FormManagementApi.ListFormsOptions options) throws ApiException { + Object localVarPostBody = "{}"; + + // verify the required parameter 'accountId' is set + if (accountId == null) { + throw new ApiException(400, "Missing the required parameter 'accountId' when calling listForms"); + } + + // create path and map variables + String localVarPath = "/accounts/{account_id}/forms" + .replaceAll("\\{" + "account_id" + "\\}", apiClient.escapeString(accountId.toString())); + + // query params + java.util.List localVarQueryParams = new java.util.ArrayList(); + java.util.List localVarCollectionQueryParams = new java.util.ArrayList(); + java.util.Map localVarHeaderParams = new java.util.HashMap(); + java.util.Map localVarFormParams = new java.util.HashMap(); + + if (options != null) { + localVarQueryParams.addAll(apiClient.parameterToPair("user_filter", options.userFilter)); + }if (options != null) { + localVarQueryParams.addAll(apiClient.parameterToPair("is_standalone", options.isStandalone)); + }if (options != null) { + localVarQueryParams.addAll(apiClient.parameterToPair("is_published", options.isPublished)); + }if (options != null) { + localVarQueryParams.addAll(apiClient.parameterToPair("sort_by", options.sortBy)); + }if (options != null) { + localVarQueryParams.addAll(apiClient.parameterToPair("search", options.search)); + }if (options != null) { + localVarQueryParams.addAll(apiClient.parameterToPair("start_position", options.startPosition)); + }if (options != null) { + localVarQueryParams.addAll(apiClient.parameterToPair("count", options.count)); + } + + + + + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "docusignAccessCode" }; + + GenericType localVarReturnType = new GenericType() {}; + WebFormSummaryList localVarResponse = apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + return new ApiResponse(apiClient.getStatusCode(), apiClient.getResponseHeaders(), localVarResponse); + } +} diff --git a/src/main/java/com/docusign/webforms/client/ApiClient.java b/src/main/java/com/docusign/webforms/client/ApiClient.java new file mode 100644 index 0000000..a838a17 --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/ApiClient.java @@ -0,0 +1,1845 @@ +package com.docusign.webforms.client; + + + +import com.docusign.webforms.client.auth.*; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.csv.CsvMapper; +import com.fasterxml.jackson.dataformat.csv.CsvSchema; +import com.migcomponents.migbase64.Base64; +import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder; +import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder; +import org.apache.oltu.oauth2.common.exception.OAuthSystemException; +import org.glassfish.jersey.client.ClientConfig; +import org.glassfish.jersey.client.ClientProperties; +import org.glassfish.jersey.client.HttpUrlConnectorProvider; +import org.glassfish.jersey.client.spi.Connector; +import org.glassfish.jersey.client.spi.ConnectorProvider; +import org.glassfish.jersey.jackson.JacksonFeature; +import org.glassfish.jersey.logging.LoggingFeature; +import org.glassfish.jersey.media.multipart.*; + +import javax.net.ssl.*; +import jakarta.ws.rs.client.*; +import jakarta.ws.rs.core.*; +import jakarta.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.Response.Status.Family; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.*; + +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; +import org.glassfish.jersey.logging.LoggingFeature; +import java.security.SecureRandom; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.security.NoSuchAlgorithmException; +import java.text.DateFormat; +import java.util.*; +import java.util.Map.Entry; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + + + +/** + * ApiClient class. + * + **/ + +public class ApiClient { + protected Map defaultHeaderMap = new HashMap(); + // Rest API base path constants + /** live/production base path. */ + public final static String PRODUCTION_REST_BASEPATH = "https://us.services.docusign.net/webforms/v1.1"; + /** sandbox/demo base path. */ + public final static String DEMO_REST_BASEPATH = "https://apps-d.docusign.com/api/webforms/v1.1"; + /** stage base path. */ + public final static String STAGE_REST_BASEPATH = "https://apps-s.docusign.com/api/webforms/v1.1"; + + private String basePath = DEMO_REST_BASEPATH; + private String oAuthBasePath = OAuth.PRODUCTION_OAUTH_BASEPATH; + protected boolean debugging = false; + protected int connectionTimeout = 0; + private int readTimeout = 0; + + protected Client httpClient; + protected JSON json; + protected String tempFolderPath = null; + + protected Map authentications; + + private int statusCode; + private Map> responseHeaders; + + protected DateFormat dateFormat; + private SSLContext sslContext = null; + + /** + * ApiClient constructor. + * + **/ + public ApiClient() { + json = new JSON(); + httpClient = buildHttpClient(debugging); + + this.dateFormat = new RFC3339DateFormat(); + String javaVersion = System.getProperty("java.version"); + + // Set default User-Agent. + setUserAgent("Swagger-Codegen/1.1.0/1.0.2-RC12/Java/" + javaVersion); + + // Setup authentications (key: authentication name, value: authentication). + authentications = new HashMap(); + authentications.put("docusignAccessCode", new OAuth()); + + // Derive the OAuth base path from the Rest API base url + this.deriveOAuthBasePathFromRestBasePath(); + } + + /** + * buildDefaultDateFormat method. + * + * @return DateFormat + **/ + public static DateFormat buildDefaultDateFormat() { + return new RFC3339DateFormat(); + } + + /** + * ApiClient constructor. + * + * @param basePath The base path to create the client with + **/ + public ApiClient(String basePath) { + this(); + this.basePath = basePath; + this.deriveOAuthBasePathFromRestBasePath(); + } + + /** + * ApiClient constructor. + * + * @param oAuthBasePath The base path to create the client with + * @param authNames The authentication names + **/ + public ApiClient(String oAuthBasePath, String[] authNames) { + this(); + this.setOAuthBasePath(oAuthBasePath); + for(String authName : authNames) { + Authentication auth; + if ("docusignAccessCode".equals(authName)) { + auth = new OAuth(httpClient, OAuthFlow.accessCode, oAuthBasePath + "/oauth/auth", oAuthBasePath + "/oauth/token", "all"); + } else if ("docusignApiKey".equals(authName)) { + auth = new ApiKeyAuth("header", "docusignApiKey"); + } else { + throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); + } + addAuthorization(authName, auth); + } + } + + /** + * Basic constructor for single auth name. + * @param oAuthBasePath the basepath + * @param authName the auth name + */ + public ApiClient(String oAuthBasePath, String authName) { + this(oAuthBasePath, new String[]{authName}); + } + + /** + * Helper constructor for OAuth2. + * @param oAuthBasePath The API base path + * @param authName the authentication method name ("oauth" or "api_key") + * @param clientId OAuth2 Client ID + * @param secret OAuth2 Client secret + */ + public ApiClient(String oAuthBasePath, String authName, String clientId, String secret) { + this(oAuthBasePath, authName); + this.getTokenEndPoint() + .setClientId(clientId) + .setClientSecret(secret); + } + + /** + * Build the Client used to make HTTP requests with the latest settings, + * i.e. objectMapper and debugging. + * TODO: better to use the Builder Pattern? + * @return API client + */ + public ApiClient rebuildHttpClient() { + return setDebugging(debugging); + } + + /** + * Returns the current object mapper used for JSON serialization/deserialization. + *

+ * Note: If you make changes to the object mapper, remember to set it back via + * setObjectMapper in order to trigger HTTP client rebuilding. + *

+ * @return Object mapper + */ + public ObjectMapper getObjectMapper() { + return json.getObjectMapper(); + } + + /** + * Set the object mapper of client. + * + * @return API client + */ + public ApiClient setObjectMapper(ObjectMapper objectMapper) { + json.setObjectMapper(objectMapper); + // Need to rebuild the Client as it depends on object mapper. + rebuildHttpClient(); + return this; + } + + /** + * Gets the JSON instance to do JSON serialization and deserialization. + * @return JSON + */ + public JSON getJSON() { + return json; + } + + /** + * Gets the API client. + * + * @return Client + */ + public Client getHttpClient() { + return httpClient; + } + + /** + * Sets the API client. + * + * @return ApiClient + */ + public ApiClient setHttpClient(Client httpClient) { + this.httpClient = httpClient; + return this; + } + + /** + * Gets the basepath. + * + * @return String + */ + public String getBasePath() { + return basePath; + } + + /** + * Sets the basepath. + * + * @return ApiClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + this.deriveOAuthBasePathFromRestBasePath(); + return this; + } + + /** + * Gets the status code of the previous request. + * @return Status code + */ + public int getStatusCode() { + return statusCode; + } + + /** + * Gets the response headers of the previous request. + * @return Response headers + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get authentications (key: authentication name, value: authentication). + * @return Map of authentication object + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + /** + * Adds authorization. + */ + public void addAuthorization(String authName, Authentication auth) { + authentications.put(authName, auth); + } + + /** + * Helper method to set username for the first HTTP basic authentication. + * @param username Username + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + * @param password Password + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + * @param apiKey API key + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + * @param apiKeyPrefix API key prefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set access token for the first OAuth2 authentication. + */ + public void updateAccessToken() { + for (Authentication auth : authentications.values()) { + if (auth instanceof OAuth) { + try { + ((OAuth) auth).updateAccessToken(); + } catch (ApiException e) { + throw new RuntimeException(e.getMessage()); + } + return; + } + } + throw new RuntimeException("No OAuth2 authentication configured!"); + } + + /** + * Helper method to preset the OAuth access token of the first OAuth found in the apiAuthorizations (there should be only one). + * @param accessToken OAuth access token + * @param expiresIn Validity period of the access token in seconds + */ + public void setAccessToken(final String accessToken, final Long expiresIn) { + for (Authentication auth : authentications.values()) { + if (auth instanceof OAuth) { + ((OAuth) auth).setAccessToken(accessToken, expiresIn); + return; + } + } + OAuth oAuth = new OAuth(null, null, null); + oAuth.setAccessToken(accessToken, expiresIn); + addAuthorization("docusignAccessCode", oAuth); + } + + /** + * Gets the access token. + * + * @return String + */ + public String getAccessToken() { + for (Authentication auth : authentications.values()) { + if (auth instanceof OAuth) { + return ((OAuth) auth).getAccessToken(); + } + } + return null; + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * @param userAgent Http user agent + * @return API client + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + * @return API client + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * @return True if debugging is switched on + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + * @return API client + */ + public ApiClient setDebugging(boolean debugging) { + this.debugging = debugging; + // Rebuild HTTP Client according to the new "debugging" value. + this.httpClient = buildHttpClient(debugging); + return this; + } + + /** + * The path of temporary folder used to store downloaded files from endpoints + * with file response. The default value is null, i.e. using + * the system's default tempopary folder. + * + * @return Temp folder path + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + /** + * Set temp folder path. + * @param tempFolderPath Temp folder path + * @return API client + */ + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + + /** + * Connect timeout (in milliseconds). + * @return Connection timeout + */ + public int getConnectTimeout() { + return connectionTimeout; + } + + /** + * Set the connect timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link Integer#MAX_VALUE}. + * @param connectionTimeout Connection timeout in milliseconds + * @return API client + */ + public ApiClient setConnectTimeout(int connectionTimeout) { + this.connectionTimeout = connectionTimeout; + httpClient.property(ClientProperties.CONNECT_TIMEOUT, connectionTimeout); + return this; + } + + /** + * read timeout (in milliseconds). + * @return Read timeout + */ + public int getReadTimeout() { + return readTimeout; + } + + /** + * Set the read timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link Integer#MAX_VALUE}. + * @param readTimeout Read timeout in milliseconds + * @return API client + */ + public ApiClient setReadTimeout(int readTimeout) { + this.readTimeout = readTimeout; + httpClient.property(ClientProperties.READ_TIMEOUT, readTimeout); + return this; + } + + /** + * Get the date format used to parse/format date parameters. + * @return Date format + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + * Set the date format used to parse/format date parameters. + * @param dateFormat Date format + * @return API client + */ + public ApiClient setDateFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + // also set the date format for model (de)serialization with Date properties + this.json.setDateFormat((DateFormat) dateFormat.clone()); + return this; + } + + /** + * Helper method to configure the token endpoint of the first oauth found in the authentications (there should be only one). + * @return + */ + public TokenRequestBuilder getTokenEndPoint() { + for(Authentication auth : getAuthentications().values()) { + if (auth instanceof OAuth) { + OAuth oauth = (OAuth) auth; + return oauth.getTokenRequestBuilder(); + } + } + return null; + } + + + /** + * Helper method to configure authorization endpoint of the first oauth found in the authentications (there should be only one). + * @return + */ + public AuthenticationRequestBuilder getAuthorizationEndPoint() { + for(Authentication auth : authentications.values()) { + if (auth instanceof OAuth) { + OAuth oauth = (OAuth) auth; + return oauth.getAuthenticationRequestBuilder(); + } + } + return null; + } + + /** + * Helper method to configure the OAuth accessCode/implicit flow parameters. + * @param clientId OAuth2 client ID + * @param clientSecret OAuth2 client secret + * @param redirectURI OAuth2 redirect uri + */ + public void configureAuthorizationFlow(String clientId, String clientSecret, String redirectURI) { + for(Authentication auth : authentications.values()) { + if (auth instanceof OAuth) { + OAuth oauth = (OAuth) auth; + oauth.getTokenRequestBuilder() + .setClientId(clientId) + .setClientSecret(clientSecret) + .setRedirectURI(redirectURI); + oauth.getAuthenticationRequestBuilder() + .setClientId(clientId) + .setRedirectURI(redirectURI); + return; + } + } + } + + public String getAuthorizationUri() throws OAuthSystemException { + return getAuthorizationEndPoint().buildQueryMessage().getLocationUri(); + } + + /** + * Helper method to configure the OAuth accessCode/implicit flow parameters. + * + * @param clientId OAuth2 client ID: Identifies the client making the request. + * Client applications may be scoped to a limited set of system access. + * @param scopes the list of requested scopes. Values include {@link OAuth#Scope_SIGNATURE}, {@link OAuth#Scope_EXTENDED}, {@link OAuth#Scope_IMPERSONATION}. You can also pass any advanced scope. + * @param redirectUri this determines where to deliver the response containing the authorization code or access token. + * @param responseType determines the response type of the authorization request. + *
Note: these response types are mutually exclusive for a client application. + * A public/native client application may only request a response type of "token"; + * a private/trusted client application may only request a response type of "code". + * @param state Allows for arbitrary state that may be useful to your application. + * The value in this parameter will be round-tripped along with the response so you can make sure it didn't change. + */ + public URI getAuthorizationUri(String clientId, java.util.List scopes, String redirectUri, String responseType, String state) throws IllegalArgumentException, UriBuilderException { + String formattedScopes = (scopes == null || scopes.size() < 1) ? "" : scopes.get(0); + StringBuilder sb = new StringBuilder(formattedScopes); + for (int i = 1; i < scopes.size(); i++) { + sb.append("%20" + scopes.get(i)); + } + + UriBuilder builder = UriBuilder.fromUri(getOAuthBasePath()) + .scheme("https") + .path("/oauth/auth") + .queryParam("response_type", responseType) + .queryParam("scope", sb.toString()) + .queryParam("client_id", clientId) + .queryParam("redirect_uri", redirectUri); + if (state != null) { + builder = builder.queryParam("state", state); + } + return builder.build(); + } + + /** + * Helper method to configure the OAuth accessCode/implicit flow parameters. + * + * @param clientId OAuth2 client ID: Identifies the client making the request. + * Client applications may be scoped to a limited set of system access. + * @param scopes the list of requested scopes. Values include {@link OAuth#Scope_SIGNATURE}, {@link OAuth#Scope_EXTENDED}, {@link OAuth#Scope_IMPERSONATION}. You can also pass any advanced scope. + * @param redirectUri this determines where to deliver the response containing the authorization code or access token. + * @param responseType determines the response type of the authorization request. + *
Note: these response types are mutually exclusive for a client application. + * A public/native client application may only request a response type of "token"; + * a private/trusted client application may only request a response type of "code". + */ + public URI getAuthorizationUri(String clientId, java.util.List scopes, String redirectUri, String responseType) throws IllegalArgumentException, UriBuilderException { + return this.getAuthorizationUri(clientId, scopes, redirectUri, responseType, null); + } + + private void deriveOAuthBasePathFromRestBasePath() { + if (this.basePath == null) { // this case should not happen but just in case + this.oAuthBasePath = OAuth.DEMO_OAUTH_BASEPATH; + } else if (this.basePath.startsWith("https://demo") || this.basePath.startsWith("http://demo") || this.basePath.startsWith("https://apps-d") || this.basePath.startsWith("http://apps-d")) { + this.oAuthBasePath = OAuth.DEMO_OAUTH_BASEPATH; + } else if (this.basePath.startsWith("https://stage") || this.basePath.startsWith("http://stage") || this.basePath.startsWith("https://apps-s") || this.basePath.startsWith("http://apps-s")) { + this.oAuthBasePath = OAuth.STAGE_OAUTH_BASEPATH; + } else { + this.oAuthBasePath = OAuth.PRODUCTION_OAUTH_BASEPATH; + } + } + + private String getOAuthBasePath() { + return this.oAuthBasePath; + } + + /** + * Sets the OAuth base path. Values include {@link OAuth#PRODUCTION_OAUTH_BASEPATH}, {@link OAuth#DEMO_OAUTH_BASEPATH} and custom (e.g. "account-s.docusign.com"). + * @param oAuthBasePath the new value for the OAuth base path + * @return this instance of the ApiClient updated with the new OAuth base path + */ + public ApiClient setOAuthBasePath(String oAuthBasePath) { + this.oAuthBasePath = oAuthBasePath; + return this; + } + + /** + * Helper method to configure the OAuth accessCode/implicit flow parameters. + * + * @param clientId OAuth2 client ID: Identifies the client making the request. + * Client applications may be scoped to a limited set of system access. + * @param clientSecret the secret key you generated when you set up the integration in DocuSign Admin console. + * @param code The authorization code that you received from the getAuthorizationUri callback. + * @return OAuth.OAuthToken object. + * @throws ApiException if the HTTP call status is different than 2xx. + * @throws IOException if there is a problem while parsing the reponse object. + * @see OAuth.OAuthToken + */ + public OAuth.OAuthToken generateAccessToken(String clientId, String clientSecret, String code) throws ApiException, IOException { + String clientStr = (clientId == null ? "" : clientId) + ":" + (clientSecret == null ? "" : clientSecret); + java.util.Map form = new java.util.HashMap<>(); + form.put("code", code); + form.put("grant_type", "authorization_code"); + + Client client = buildHttpClient(debugging); + WebTarget target = client.target("https://" + getOAuthBasePath() + "/oauth/token"); + + Invocation.Builder invocationBuilder = target.request(); + invocationBuilder = invocationBuilder + .header("Authorization", "Basic " + Base64.encodeToString(clientStr.getBytes("UTF-8"), false)) + .header("Cache-Control", "no-store") + .header("Pragma", "no-cache"); + + Entity entity = serialize(null, form, MediaType.APPLICATION_FORM_URLENCODED); + + Response response = null; + + try { + response = invocationBuilder.post(entity); + + if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) { + String message = "error"; + String respBody = null; + if (response.hasEntity()) { + try { + respBody = String.valueOf(response.readEntity(String.class)); + message = "Error while requesting server, received a non successful HTTP code " + response.getStatusInfo().getStatusCode() + " with response Body: '" + respBody + "'"; + } catch (RuntimeException e) { + // e.printStackTrace(); + } + } + throw new ApiException( + response.getStatusInfo().getStatusCode(), + message, + buildResponseHeaders(response), + respBody); + } + + GenericType returnType = new GenericType() {}; + return deserialize(response, returnType); + } finally { + try { + if (response != null) { + response.close(); + } + } catch (Exception e) { + // it's not critical, since the response object is local in method invokeAPI; that's fine, just continue + } + } + } + + /** + * Gets the user info. + * + * @param accessToken the bearer token to use to authenticate for this call. + * @return OAuth UserInfo model + * @throws ApiException if the HTTP call status is different than 2xx. + * @see OAuth.UserInfo + */ + public OAuth.UserInfo getUserInfo(String accessToken) throws IllegalArgumentException, ApiException { + if (accessToken == null || "".equals(accessToken)) { + throw new IllegalArgumentException("Cannot find a valid access token. Make sure OAuth is configured before you try again."); + } + + Client client = buildHttpClient(debugging); + WebTarget target = client.target("https://" + getOAuthBasePath() + "/oauth/userinfo"); + Invocation.Builder invocationBuilder = target.request(); + invocationBuilder = invocationBuilder + .header("Authorization", "Bearer " + accessToken) + .header("Cache-Control", "no-store") + .header("Pragma", "no-cache"); + + Response response = null; + + try { + response = invocationBuilder.get(); + + if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) { + String message = "error"; + String respBody = null; + if (response.hasEntity()) { + try { + respBody = String.valueOf(response.readEntity(String.class)); + message = "Error while requesting server, received a non successful HTTP code " + response.getStatusInfo().getStatusCode() + " with response Body: '" + respBody + "'"; + } catch (RuntimeException e) { + // e.printStackTrace(); + } + } + throw new ApiException( + response.getStatusInfo().getStatusCode(), + message, + buildResponseHeaders(response), + respBody); + } + + GenericType returnType = new GenericType() {}; + return deserialize(response, returnType); + } finally { + try { + if (response != null) { + response.close(); + } + } catch (Exception e) { + // it's not critical, since the response object is local in method invokeAPI; that's fine, just continue + } + } + } + + /** + * Configures a listener which is notified when a new access token is received. + * @param accessTokenListener access token listener + */ + public void registerAccessTokenListener(AccessTokenListener accessTokenListener) { + for(Authentication auth : authentications.values()) { + if (auth instanceof OAuth) { + OAuth oauth = (OAuth) auth; + oauth.registerAccessTokenListener(accessTokenListener); + return; + } + } + } + + /** + * Helper method to build the OAuth JWT grant uri (used once to get a user consent for impersonation). + * @param clientId OAuth2 client ID + * @param redirectURI OAuth2 redirect uri + * @return the OAuth JWT grant uri as a String + */ + public String getJWTUri(String clientId, String redirectURI, String oAuthBasePath) { + return UriBuilder.fromUri(oAuthBasePath) + .scheme("https") + .path("/oauth/auth") + .queryParam("response_type", "code") + .queryParam("scope", "signature%20impersonation") + .queryParam("client_id", clientId) + .queryParam("redirect_uri", redirectURI) + .build().toString(); + } + + /** + * Configures the current instance of ApiClient with a fresh OAuth JWT access token from DocuSign. + * @param publicKeyFilename the filename of the RSA public key + * @param privateKeyFilename the filename of the RSA private key + * @param oAuthBasePath DocuSign OAuth base path (account-d.docusign.com for the developer sandbox + and account.docusign.com for the production platform) + * @param clientId DocuSign OAuth Client Id (AKA Integrator Key) + * @param userId DocuSign user Id to be impersonated (This is a UUID) + * @param expiresIn number of seconds remaining before the JWT assertion is considered as invalid + * @throws ApiException if there is an error while exchanging the JWT with an access token + * @throws IOException if there is an issue with either the public or private file + * @deprecated As of release 2.7.0, replaced by {@link #requestJWTUserToken(String, String, List, byte[], long)} ()} and {@link #requestJWTApplicationToken(String, List, byte[], long)} + */ + @Deprecated public void configureJWTAuthorizationFlow(String publicKeyFilename, String privateKeyFilename, String oAuthBasePath, String clientId, String userId, long expiresIn) throws ApiException, IOException { + String assertion = JWTUtils.generateJWTAssertion(publicKeyFilename, privateKeyFilename, oAuthBasePath, clientId, userId, expiresIn); + java.util.Map form = new java.util.HashMap<>(); + form.put("assertion", assertion); + form.put("grant_type", OAuth.GRANT_TYPE_JWT); + + Client client = buildHttpClient(debugging); + WebTarget target = client.target("https://" + oAuthBasePath + "/oauth/token"); + Invocation.Builder invocationBuilder = target.request(); + invocationBuilder = invocationBuilder + .header("Cache-Control", "no-store") + .header("Pragma", "no-cache"); + + Entity entity = serialize(null, form, MediaType.APPLICATION_FORM_URLENCODED); + + Response response = null; + + try { + response = invocationBuilder.post(entity); + + if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) { + String message = "error"; + String respBody = null; + if (response.hasEntity()) { + try { + respBody = String.valueOf(response.readEntity(String.class)); + message = "Error while requesting server, received a non successful HTTP code " + response.getStatusInfo().getStatusCode() + " with response Body: '" + respBody + "'"; + } catch (RuntimeException e) { + // e.printStackTrace(); + } + } + throw new ApiException( + response.getStatusInfo().getStatusCode(), + message, + buildResponseHeaders(response), + respBody); + } + + GenericType returnType = new GenericType() {}; + JsonNode responseJson = deserialize(response, returnType); + if (!responseJson.has("access_token") || !responseJson.has("expires_in")) { + throw new ApiException("Error while requesting an access token: " + responseJson); + } + String accessToken = responseJson.get("access_token").asText(); + expiresIn = responseJson.get("expires_in").asLong(); + setAccessToken(accessToken, expiresIn); + } finally { + try { + if (response != null) { + response.close(); + } + } catch (Exception e) { + // it's not critical, since the response object is local in method invokeAPI; that's fine, just continue + } + } + } + + /** + * Configures the current instance of ApiClient with a fresh OAuth JWT access token from DocuSign. + * @param clientId DocuSign OAuth Client Id (AKA Integrator Key) + * @param userId DocuSign user Id to be impersonated (This is a UUID) + * @param scopes the list of requested scopes. Values include {@link OAuth#Scope_SIGNATURE}, {@link OAuth#Scope_EXTENDED}, {@link OAuth#Scope_IMPERSONATION}. You can also pass any advanced scope. + * @param rsaPrivateKey the byte contents of the RSA private key + * @param expiresIn number of seconds remaining before the JWT assertion is considered as invalid + * @return OAuth.OAuthToken object. + * @throws IllegalArgumentException if one of the arguments is invalid + * @throws ApiException if there is an error while exchanging the JWT with an access token + * @throws IOException if there is an issue with either the public or private file + */ + public OAuth.OAuthToken requestJWTUserToken(String clientId, String userId, java.util.Listscopes, byte[] rsaPrivateKey, long expiresIn) throws IllegalArgumentException, ApiException, IOException { + String formattedScopes = (scopes == null || scopes.size() < 1) ? "" : scopes.get(0); + StringBuilder sb = new StringBuilder(formattedScopes); + for (int i = 1; i < scopes.size(); i++) { + sb.append(" " + scopes.get(i)); + } + + String assertion = JWTUtils.generateJWTAssertionFromByteArray(rsaPrivateKey, getOAuthBasePath(), clientId, userId, expiresIn, sb.toString()); + java.util.Map form = new java.util.HashMap<>(); + form.put("assertion", assertion); + form.put("grant_type", OAuth.GRANT_TYPE_JWT); + + Client client = buildHttpClient(debugging); + WebTarget target = client.target("https://" + getOAuthBasePath() + "/oauth/token"); + Invocation.Builder invocationBuilder = target.request(); + invocationBuilder = invocationBuilder + .header("Cache-Control", "no-store") + .header("Pragma", "no-cache"); + + Entity entity = serialize(null, form, MediaType.APPLICATION_FORM_URLENCODED); + + Response response = null; + + try { + response = invocationBuilder.post(entity); + + if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) { + String message = "error"; + String respBody = null; + if (response.hasEntity()) { + try { + respBody = String.valueOf(response.readEntity(String.class)); + message = "Error while requesting server, received a non successful HTTP code " + response.getStatusInfo().getStatusCode() + " with response Body: '" + respBody + "'"; + } catch (RuntimeException e) { + // e.printStackTrace(); + } + } + throw new ApiException( + response.getStatusInfo().getStatusCode(), + message, + buildResponseHeaders(response), + respBody); + } + + GenericType returnType = new GenericType() {}; + OAuth.OAuthToken oAuthToken = deserialize(response, returnType); + if (oAuthToken.getAccessToken() == null || "".equals(oAuthToken.getAccessToken()) || oAuthToken.getExpiresIn() <= 0) { + throw new ApiException("Error while requesting an access token: " + response.toString()); + } + return oAuthToken; + } finally { + try { + if (response != null) { + response.close(); + } + } catch (Exception e) { + // it's not critical, since the response object is local in method invokeAPI; that's fine, just continue + } + } + } + + /** + * RESERVED FOR PARTNERS Request JWT Application Token. + * Configures the current instance of ApiClient with a fresh OAuth JWT access token from DocuSign + * @param clientId DocuSign OAuth Client Id (AKA Integrator Key) + * @param scopes the list of requested scopes. Values include {@link OAuth#Scope_SIGNATURE}, {@link OAuth#Scope_EXTENDED}, {@link OAuth#Scope_IMPERSONATION}. You can also pass any advanced scope. + * @param rsaPrivateKey the byte contents of the RSA private key + * @param expiresIn number of seconds remaining before the JWT assertion is considered as invalid + * @return OAuth.OAuthToken object. + * @throws IllegalArgumentException if one of the arguments is invalid + * @throws IOException if there is an issue with either the public or private file + * @throws ApiException if there is an error while exchanging the JWT with an access token + */ + public OAuth.OAuthToken requestJWTApplicationToken(String clientId, java.util.Listscopes, byte[] rsaPrivateKey, long expiresIn) throws IllegalArgumentException, IOException, ApiException { + return this.requestJWTUserToken(clientId, null, scopes, rsaPrivateKey, expiresIn); + } + + /** + * Parse the given string into Date object. + * @param str String + * @return Date + */ + public Date parseDate(String str) { + try { + return dateFormat.parse(str); + } catch (java.text.ParseException e) { + throw new RuntimeException(e); + } + } + + /** + * Format the given Date object into string. + * @param date Date + * @return Date in string format + */ + public String formatDate(Date date) { + return dateFormat.format(date); + } + + /** + * Format the given parameter object into string. + * @param param Object + * @return Object in string format + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date) { + return formatDate((Date) param); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for(Object o : (Collection)param) { + if(b.length() > 0) { + b.append(','); + } + b.append(String.valueOf(o)); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} object. + * + * Note that {@code value} must not be a collection. + * + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list containing a single {@code Pair} object. + */ + public List parameterToPair(String name, Object value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value instanceof Collection) { + return params; + } + + params.add(new Pair(name, parameterToString(value))); + return params; + } + + /** + * Formats the specified collection query parameters to a list of {@code Pair} objects. + * + * Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Collection value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null) { + return params; + } + + // create the params based on the collection format + if ("multi".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if ("ssv".equals(collectionFormat)) { + delimiter = escapeString(" "); + } else if ("tsv".equals(collectionFormat)) { + delimiter = escapeString("\t"); + } else if ("pipes".equals(collectionFormat)) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Format to {@code Pair} objects. + * @param collectionFormat Collection format + * @param name Name + * @param value Value + * @return List of pairs + */ + public List parameterToPairs(String collectionFormat, String name, Object value){ + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null) { + return params; + } + + Collection valueCollection; + if (value instanceof Collection) { + valueCollection = (Collection) value; + } else { + params.add(new Pair(name, parameterToString(value))); + return params; + } + + if (valueCollection.isEmpty()){ + return params; + } + + // get the collection format (default: csv) + String format = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); + + // create the params based on the collection format + if ("multi".equals(format)) { + for (Object item : valueCollection) { + params.add(new Pair(name, parameterToString(item))); + } + + return params; + } + + String delimiter = ","; + + if ("csv".equals(format)) { + delimiter = ","; + } else if ("ssv".equals(format)) { + delimiter = " "; + } else if ("tsv".equals(format)) { + delimiter = "\t"; + } else if ("pipes".equals(format)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : valueCollection) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + params.add(new Pair(name, sb.substring(1))); + + return params; + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * "* / *" is also default to JSON + * @param mime MIME + * @return True if the MIME type is JSON + */ + public boolean isJsonMime(String mime) { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: + * if JSON exists in the given array, use it; + * otherwise use all of them (joining into a string). + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, + * null will be returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array. + * if JSON exists in the given array, use it; + * otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, + * JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0 || contentTypes[0].equals("*/*")) { + return "application/json"; + } + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * @param str String + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Serialize the given Java object into string according the given + * Content-Type (only JSON is supported for now). + * @param obj Object + * @param contentType Content type + * @param formParams Form parameters + * @return Object + * @throws ApiException API exception + */ + public Object serialize(Object obj, String contentType, Map formParams) throws ApiException { + return serialize(obj, formParams, contentType).getEntity(); + } + + /** + * Serialize the given Java object into string entity according the given + * Content-Type (only JSON is supported for now). + * @param obj Object + * @param formParams Form parameters + * @param contentType Context type + * @return Entity + * @throws ApiException API exception + */ + public Entity serialize(Object obj, Map formParams, String contentType) throws ApiException { + Entity entity; + if (contentType.startsWith("multipart/form-data")) { + MultiPart multiPart = new MultiPart(); + for (Entry param: formParams.entrySet()) { + if (param.getValue() instanceof byte[]) { + byte[] bytes = (byte[]) param.getValue(); + FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey()) + .fileName(param.getKey()).size(bytes.length).build(); + + multiPart.bodyPart(new FormDataBodyPart(contentDisp, bytes, MediaType.APPLICATION_OCTET_STREAM_TYPE)); + } else if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey()) + .fileName(file.getName()).size(file.length()).build(); + multiPart.bodyPart(new FormDataBodyPart(contentDisp, file, MediaType.APPLICATION_OCTET_STREAM_TYPE)); + } else { + FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey()).build(); + multiPart.bodyPart(new FormDataBodyPart(contentDisp, parameterToString(param.getValue()))); + } + } + entity = Entity.entity(multiPart, MediaType.MULTIPART_FORM_DATA_TYPE); + } else if (contentType.startsWith("application/x-www-form-urlencoded")) { + Form form = new Form(); + for (Entry param: formParams.entrySet()) { + form.param(param.getKey(), parameterToString(param.getValue())); + } + entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE); + } else if (contentType.startsWith("text/csv")) { + return this.serializeToCsv(obj); + } else { + // We let jersey handle the serialization + entity = Entity.entity(obj, contentType); + } + return entity; + } + + /** + * Deserialize response body to Java object according to the Content-Type. + * @param Type + * @param response Response + * @param returnType Return type + * @return Deserialize object + * @throws ApiException API exception + */ + @SuppressWarnings("unchecked") + public T deserialize(Response response, GenericType returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if ("byte[]".equals(returnType.toString())) { + // Handle binary response (byte array). + return (T) response.readEntity(byte[].class); + } else if (returnType.getRawType() == File.class) { + // Handle file downloading. + T file = (T) downloadFileFromResponse(response); + return file; + } + + String contentType = null; + List contentTypes = response.getHeaders().get("Content-Type"); + if (contentTypes != null && !contentTypes.isEmpty()) { + contentType = String.valueOf(contentTypes.get(0)); + } + + return response.readEntity(returnType); + } + + /** + * Download file from the given response. + * @param response Response + * @return File + * @throws ApiException If fail to read file content from response and write to disk + */ + public File downloadFileFromResponse(Response response) throws ApiException { + try { + File file = prepareDownloadFile(response); + Files.copy(response.readEntity(InputStream.class), file.toPath(), StandardCopyOption.REPLACE_EXISTING); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Prepare to downloand file. + * @param response Response + * @return File + * @throws ApiException If fail to read file content from response and write to disk + */ + public File prepareDownloadFile(Response response) throws IOException { + String filename = null; + String contentDisposition = (String) response.getHeaders().getFirst("Content-Disposition"); + if (contentDisposition != null && !"".equals(contentDisposition)) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + filename = matcher.group(1); + } + } + + String prefix; + String suffix = null; + if (filename == null) { + prefix = "download-"; + suffix = ""; + } else { + int pos = filename.lastIndexOf('.'); + if (pos == -1) { + prefix = filename + "-"; + } else { + prefix = filename.substring(0, pos) + "-"; + suffix = filename.substring(pos); + } + // File.createTempFile requires the prefix to be at least three characters long + if (prefix.length() < 3) { + prefix = "download-"; + } + } + + if (tempFolderPath == null) { + return File.createTempFile(prefix, suffix); + } + else { + return File.createTempFile(prefix, suffix, new File(tempFolderPath)); + } + } + + /** + * Invoke API by sending HTTP request with the given options. + * + * @param Type + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param formParams The form parameters + * @param accept The request's Accept header + * @param contentType The request's Content-Type header + * @param authNames The authentications to apply + * @param returnType The return type into which to deserialize the response + * @return The response body in type of string + * @throws ApiException API exception + */ + public T invokeAPI(String path, String method, List queryParams, List collectionQueryParams, Object + body, Map headerParams, Map formParams, String accept, String contentType, String[] authNames, GenericType returnType) throws ApiException { + updateParamsForAuth(authNames, queryParams, headerParams); + + // Not using `.target(this.basePath).path(path)` below, + // to support (constant) query string in `path`, e.g. "/posts?draft=1" + WebTarget target = httpClient.target(this.basePath + path); + + if (queryParams != null) { + for (Pair queryParam : queryParams) { + if (queryParam.getValue() != null) { + target = target.queryParam(queryParam.getName(), queryParam.getValue()); + } + } + } + + if (collectionQueryParams != null) { + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + target = target.queryParam(param.getName(), param.getValue()); + } + } + } + + Invocation.Builder invocationBuilder = target.request().accept(accept); + + for (Entry entry : headerParams.entrySet()) { + String value = entry.getValue(); + if (value != null) { + invocationBuilder = invocationBuilder.header(entry.getKey(), value); + } + } + + for (Entry entry : defaultHeaderMap.entrySet()) { + String key = entry.getKey(); + if (!headerParams.containsKey(key)) { + String value = entry.getValue(); + if (value != null) { + invocationBuilder = invocationBuilder.header(key, value); + } + } + } + + Entity entity = (body == null && formParams.isEmpty()) ? Entity.json("{}") : serialize(body, formParams, contentType); + + // Generate and add Content-Disposition header as per RFC 6266 + if (contentType.startsWith("multipart/form-data")) { + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof byte[]) { + MultiPart mp = ((MultiPart) entity.getEntity()); + List bodyParts = mp.getBodyParts(); + if (!bodyParts.isEmpty()) { + BodyPart bodyPart = bodyParts.get(0); + if (bodyPart.getContentDisposition() != null) { + String contentDispositionValue = bodyPart.getContentDisposition().toString(); + invocationBuilder = invocationBuilder.header("Content-Disposition", contentDispositionValue); + entity = Entity.entity(param.getValue(), "application/octet-stream"); + } + } + } + } + } + + // Add DocuSign Tracking Header + invocationBuilder = invocationBuilder.header("X-DocuSign-SDK", "Java"); + + if (body == null && formParams.isEmpty()) { + invocationBuilder = invocationBuilder.header("Content-Length", "0"); + } + + Response response = null; + String message = "error"; + String respBody = null; + + try { + if ("GET".equals(method)) { + response = invocationBuilder.get(); + } else if ("POST".equals(method)) { + response = invocationBuilder.post(entity); + } else if ("PUT".equals(method)) { + response = invocationBuilder.put(entity); + } else if ("DELETE".equals(method)) { + response = invocationBuilder.method("DELETE", entity); + } else if ("PATCH".equals(method)) { + response = invocationBuilder.method("PATCH", entity); + } else if ("HEAD".equals(method)) { + response = invocationBuilder.head(); + } else { + throw new ApiException(500, "unknown method type " + method); + } + + statusCode = response.getStatusInfo().getStatusCode(); + responseHeaders = buildResponseHeaders(response); + + if (response.getStatusInfo().getFamily() != Family.SUCCESSFUL) { + if (response.hasEntity()) { + try { + respBody = String.valueOf(response.readEntity(String.class)); + message = "Error while requesting server, received a non successful HTTP code " + response.getStatusInfo().getStatusCode() + " with response Body: '" + respBody + "'"; + } catch (RuntimeException e) { + // e.printStackTrace(); + } + } + throw new ApiException( + response.getStatusInfo().getStatusCode(), + message, + buildResponseHeaders(response), + respBody); + } + + if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) { + return null; + } else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) { + if (returnType == null) { + return null; + } + else { + return deserialize(response, returnType); + } + } else { + if (response.hasEntity()) { + try { + respBody = String.valueOf(response.readEntity(String.class)); + message = respBody; + } catch (RuntimeException e) { + // e.printStackTrace(); + } + } + throw new ApiException( + response.getStatus(), + message, + buildResponseHeaders(response), + respBody); + } + } finally { + try { + response.close(); + } catch (Exception e) { + // it's not critical, since the response object is local in method invokeAPI; that's fine, just continue + } + } + } + + /** + * Encode the given form parameters as request body. + * @param formParams Form parameters + * @return HTTP form encoded parameters + */ + private String getXWWWFormUrlencodedParams(Map formParams) { + StringBuilder formParamBuilder = new StringBuilder(); + + for (Entry param : formParams.entrySet()) { + String valueStr = parameterToString(param.getValue()); + try { + formParamBuilder.append(URLEncoder.encode(param.getKey(), "utf8")) + .append("=") + .append(URLEncoder.encode(valueStr, "utf8")); + formParamBuilder.append("&"); + } catch (UnsupportedEncodingException e) { + // move on to next + } + } + + String encodedFormParams = formParamBuilder.toString(); + if (encodedFormParams.endsWith("&")) { + encodedFormParams = encodedFormParams.substring(0, encodedFormParams.length() - 1); + } + + return encodedFormParams; + } + + + + /** + * Encode the given request object in CSV format. + */ + private Entity serializeToCsv(Object obj) { + if(obj == null) { + return Entity.text(""); + } else if (obj.getClass() == byte[].class) { + return Entity.entity(new String((byte[]) obj), new MediaType("text", "csv")); + } + + for (Method method: obj.getClass().getMethods()) { + if ("java.util.List".equals(method.getReturnType().getName())) { + try { + @SuppressWarnings("rawtypes") + java.util.List itemList = (java.util.List) method.invoke(obj); + Object entry = itemList.get(0); + + List stringList = new ArrayList(); + char delimiter = ','; + String lineSep = "\n"; + + CsvMapper mapper = new CsvMapper(); + mapper.enable(JsonGenerator.Feature.IGNORE_UNKNOWN); + CsvSchema schema = mapper.schemaFor(entry.getClass()); + for (int i = 0; i < itemList.size(); i++) { + if (i == 0) { + schema = schema.withHeader(); + } else { + schema = schema.withoutHeader(); + } + String csv = mapper.writer(schema + .withColumnSeparator(delimiter) + .withoutQuoteChar() + .withLineSeparator(lineSep)).writeValueAsString(itemList.get(i)); + + stringList.add(csv); + } + return Entity.entity(StringUtil.join(stringList.toArray(new String[0]), ""), new MediaType("text", "csv")); + } catch (JsonProcessingException e) { + System.out.println(e); + } catch (IllegalAccessException e) { + System.out.println(e); + } catch (IllegalArgumentException e) { + System.out.println(e); + } catch (InvocationTargetException e) { + System.out.println(e); + } + } + } + + return Entity.entity("", new MediaType("text", "csv")); + } + + /** + * Build the Client used to make HTTP requests. + * @param debugging Debug setting + * @return Client + */ + protected Client buildHttpClient(boolean debugging) { + final ClientConfig clientConfig = new ClientConfig(); + clientConfig.register(MultiPartFeature.class); + clientConfig.register(json); + clientConfig.register(JacksonFeature.class); + clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true); + // turn off compliance validation to be able to send payloads with DELETE calls + clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true); + if (debugging) { + clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */)); + clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY); + // Set logger to ALL + java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL); + } else { + // suppress warnings for payloads with DELETE calls: + java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE); + } + performAdditionalClientConfiguration(clientConfig); + + // Check for required TLS v1.2 + try { + String[] supportedProtocols = SSLContext.getDefault().createSSLEngine().getEnabledProtocols(); + if (!Arrays.asList(supportedProtocols).contains("TLSv1.2")) { + throw new SecurityException("Docusign Java SDK requires TLSv1.2 Protocol"); + } + } catch (SecurityException se) { + System.err.println(se.getMessage()); + } catch (NoSuchAlgorithmException nsae) { + System.err.println(nsae.getMessage()); + } + + // Setup the SSLContext object to use for HTTPS connections to the API + if (sslContext == null) { + try { + sslContext = SSLContext.getInstance("TLSv1.2"); + sslContext.init(null, new TrustManager[] { new SecureTrustManager() }, new SecureRandom()); + } catch (final Exception ex) { + System.err.println("failed to initialize SSL context"); + } + HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory()); + } + + clientConfig.connectorProvider(new ConnectorProvider() { + Proxy p = null; + + /* + * Returns whether the host is part of the list of hosts that should be accessed without going through the proxy + */ + private boolean isNonProxyHost(String host, String nonProxyHosts) { + if (null == host || null == nonProxyHosts) { + return false; + } + + for (String spec : nonProxyHosts.split("\\|")) { + int length = spec.length(); + StringBuilder sb = new StringBuilder(length); + for (int i = 0; i < length; i++) { + char c = spec.charAt(i); + switch (c) { + case '*': + sb.append(".*"); + break; + case '.': + sb.append("\\."); + break; + default: + sb.append(c); + } + } + if (host.matches(sb.toString())) { + return true; + } + } + + return false; + } + + @Override + public Connector getConnector(Client client, jakarta.ws.rs.core.Configuration configuration) { + HttpUrlConnectorProvider customConnProv = new HttpUrlConnectorProvider(); + customConnProv.connectionFactory(new HttpUrlConnectorProvider.ConnectionFactory() { + @Override + public HttpURLConnection getConnection(java.net.URL url) throws IOException { + if (url == null) { + return null; + } + + if (isNonProxyHost(url.getHost(), System.getProperty("http.nonProxyHosts"))) { + HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(Proxy.NO_PROXY); + connection.setSSLSocketFactory(sslContext.getSocketFactory()); + return connection; + } + + // set up the proxy/no-proxy settings + if (p == null) { + if (System.getProperty("https.proxyHost") != null) { + // set up the proxy host and port + final String host = System.getProperty("https.proxyHost"); + final Integer port = Integer.getInteger("https.proxyPort"); + if (host != null && port != null) { + p = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port)); + } + // set up optional proxy authentication credentials + final String user = System.getProperty("https.proxyUser"); + final String password = System.getProperty("https.proxyPassword"); + if (user != null && password != null) { + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + if (getRequestorType() == RequestorType.PROXY && getRequestingHost().equalsIgnoreCase(host) && port == getRequestingPort()) { + return new PasswordAuthentication(user, password.toCharArray()); + } + return null; + } + }); + } + } else if (System.getProperty("http.proxyHost") != null) { + // set up the proxy host and port + final String host = System.getProperty("http.proxyHost"); + final Integer port = Integer.getInteger("http.proxyPort"); + if (host != null && port != null) { + p = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port)); + } + // set up optional proxy authentication credentials + final String user = System.getProperty("http.proxyUser"); + final String password = System.getProperty("http.proxyPassword"); + if (user != null && password != null) { + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + if (getRequestorType() == RequestorType.PROXY && getRequestingHost().equalsIgnoreCase(host) && port == getRequestingPort()) { + return new PasswordAuthentication(user, password.toCharArray()); + } + return null; + } + }); + } + } + // no-proxy fallback if the proxy settings are misconfigured in the system properties + if (p == null) { + p = Proxy.NO_PROXY; + } + } + + HostnameVerifier allHostsValid = new InsecureHostnameVerifier(); + HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(p); + connection.setSSLSocketFactory(sslContext.getSocketFactory()); + connection.setHostnameVerifier(allHostsValid); + return connection; + } + }); + return customConnProv.getConnector(client, configuration); + } + }); + + return ClientBuilder.newBuilder(). + sslContext(sslContext). + withConfig(clientConfig).build(); + } + + protected void performAdditionalClientConfiguration(ClientConfig clientConfig) { + // No-op extension point + } + + class InsecureHostnameVerifier implements HostnameVerifier { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + } + + class SecureTrustManager implements X509TrustManager { + + @Override + public void checkClientTrusted(X509Certificate[] arg0, String arg1) + throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] arg0, String arg1) + throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + + public boolean isClientTrusted(X509Certificate[] arg0) { + return true; + } + + public boolean isServerTrusted(X509Certificate[] arg0) { + return true; + } + + } + + protected Map> buildResponseHeaders(Response response) { + Map> responseHeaders = new HashMap>(); + for (Entry> entry: response.getHeaders().entrySet()) { + List values = entry.getValue(); + List headers = new ArrayList(); + for (Object o : values) { + headers.add(String.valueOf(o)); + } + responseHeaders.put(entry.getKey(), headers); + } + return responseHeaders; + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + */ + protected void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams) { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) { + throw new RuntimeException("Authentication undefined: " + authName); + } + auth.applyToParams(queryParams, headerParams); + } + } +} diff --git a/src/main/java/com/docusign/webforms/client/ApiException.java b/src/main/java/com/docusign/webforms/client/ApiException.java new file mode 100644 index 0000000..af4f43d --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/ApiException.java @@ -0,0 +1,143 @@ + + +package com.docusign.webforms.client; + +import java.util.Map; +import java.util.List; + + + +/** + * ApiException class. + */ +public class ApiException extends Exception { + private int code = 0; + private Map> responseHeaders = null; + private String responseBody = null; + + /** + * ApiException constructor. + */ + public ApiException() {} + + /** + * ApiException constructor. + * + * @param throwable The Throwable type + */ + public ApiException(Throwable throwable) { + super(throwable); + } + + /** + * ApiException constructor. + * + * @param message The string message + */ + public ApiException(String message) { + super(message); + } + + /** + * ApiException constructor. + * + * @param message The string message + * @param throwable The Throwable type + * @param code The error code + * @param responseHeaders The response headers + * @param responseBody The body of response + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * ApiException constructor. + * + * @param message The string message + * @param code The error code + * @param responseHeaders The response headers + * @param responseBody The body of response + */ + public ApiException(String message, int code, Map> responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + * ApiException constructor. + * + * @param message The string message + * @param throwable The Throwable type + * @param code The error code + * @param responseHeaders The response headers + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + /** + * ApiException constructor. + * + * @param code The error code + * @param responseHeaders The response headers + * @param responseBody The body of response + */ + public ApiException(int code, Map> responseHeaders, String responseBody) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + * ApiException constructor. + * + * @param code The error code + * @param message The string message + */ + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + /** + * ApiException constructor. + * + * @param code The error code + * @param message The string message + * @param responseHeaders The response headers + * @param responseBody The body of response + */ + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return A map of list of string + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } +} diff --git a/src/main/java/com/docusign/webforms/client/ApiResponse.java b/src/main/java/com/docusign/webforms/client/ApiResponse.java new file mode 100644 index 0000000..700f56e --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/ApiResponse.java @@ -0,0 +1,52 @@ + + +package com.docusign.webforms.client; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + * + * @param The type of data that is deserialized from response body + */ +public class ApiResponse { + private final int statusCode; + private final Map> headers; + private final T data; + + /** + * ApiResponse method. + * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * ApiResponse method. + * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/src/main/java/com/docusign/webforms/client/Configuration.java b/src/main/java/com/docusign/webforms/client/Configuration.java new file mode 100644 index 0000000..d63b3c2 --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/Configuration.java @@ -0,0 +1,32 @@ + + +package com.docusign.webforms.client; + + +/** + * Configuration class. + * + **/ +public class Configuration { + private static ApiClient defaultApiClient = new ApiClient(); + + /** + * Get the default API client, which would be used when creating API + * instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } + + /** + * Set the default API client, which would be used when creating API + * instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } +} diff --git a/src/main/java/com/docusign/webforms/client/JSON.java b/src/main/java/com/docusign/webforms/client/JSON.java new file mode 100644 index 0000000..e93ed3e --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/JSON.java @@ -0,0 +1,64 @@ +package com.docusign.webforms.client; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; + +import java.text.DateFormat; + +import jakarta.ws.rs.ext.ContextResolver; + + + +/** + * JSON Class. + * + **/ + +public class JSON implements ContextResolver { + private ObjectMapper mapper; + + /** + * JSON Class constructor doc. + * + **/ + public JSON() { + mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + mapper.setDateFormat(new RFC3339DateFormat()); + } + + /** + * Returns the current object mapper used for JSON serialization/deserialization. + *

+ * Note: If you make changes to the object mapper, remember to set it back via + * setObjectMapper in order to trigger HTTP client rebuilding. + *

+ * @return Object mapper + */ + public ObjectMapper getObjectMapper() { + return mapper; + } + + public JSON setObjectMapper(ObjectMapper mapper) { + this.mapper = mapper; + return this; + } + + /** + * Set the date format for JSON (de)serialization with Date properties. + * @param dateFormat Date format + */ + public void setDateFormat(DateFormat dateFormat) { + mapper.setDateFormat(dateFormat); + } + + @Override + public ObjectMapper getContext(Class type) { + return mapper; + } +} diff --git a/src/main/java/com/docusign/webforms/client/Pair.java b/src/main/java/com/docusign/webforms/client/Pair.java new file mode 100644 index 0000000..8f84e06 --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/Pair.java @@ -0,0 +1,70 @@ + + +package com.docusign.webforms.client; + + + +/** + * Pair class. + */ +public class Pair { + private String name = ""; + private String value = ""; + + /** + * Pair constructor. + * + * @param name The pair name + * @param value The pair value + */ + public Pair (String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) { + return; + } + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) { + return; + } + + this.value = value; + } + + /** + * getName method. + * + * @return String + */ + public String getName() { + return this.name; + } + + /** + * getValue method. + * + * @return String + */ + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + + if (arg.trim().isEmpty()) { + return false; + } + + return true; + } +} diff --git a/src/main/java/com/docusign/webforms/client/RFC3339DateFormat.java b/src/main/java/com/docusign/webforms/client/RFC3339DateFormat.java new file mode 100644 index 0000000..d0bd1a0 --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/RFC3339DateFormat.java @@ -0,0 +1,24 @@ + +package com.docusign.webforms.client; + +import com.fasterxml.jackson.databind.util.ISO8601DateFormat; +import com.fasterxml.jackson.databind.util.ISO8601Utils; + +import java.text.FieldPosition; +import java.util.Date; + +/** + * RFC3339DateFormat class. + * + **/ +public class RFC3339DateFormat extends ISO8601DateFormat { + + // Same as ISO8601DateFormat but serializing milliseconds. + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + String value = ISO8601Utils.format(date, true); + toAppendTo.append(value); + return toAppendTo; + } + +} \ No newline at end of file diff --git a/src/main/java/com/docusign/webforms/client/StringUtil.java b/src/main/java/com/docusign/webforms/client/StringUtil.java new file mode 100644 index 0000000..2e43f43 --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/StringUtil.java @@ -0,0 +1,55 @@ + + +package com.docusign.webforms.client; + + +/** + * StringUtil class. + * + **/ +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) { + return true; + } + + if (value != null && value.equalsIgnoreCase(str)) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) { + return ""; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } +} diff --git a/src/main/java/com/docusign/webforms/client/auth/AccessTokenListener.java b/src/main/java/com/docusign/webforms/client/auth/AccessTokenListener.java new file mode 100644 index 0000000..9845264 --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/auth/AccessTokenListener.java @@ -0,0 +1,7 @@ +package com.docusign.webforms.client.auth; + +import org.apache.oltu.oauth2.common.token.BasicOAuthToken; + +public interface AccessTokenListener { + void notify(BasicOAuthToken token); +} diff --git a/src/main/java/com/docusign/webforms/client/auth/ApiKeyAuth.java b/src/main/java/com/docusign/webforms/client/auth/ApiKeyAuth.java new file mode 100644 index 0000000..90b0bbe --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/auth/ApiKeyAuth.java @@ -0,0 +1,110 @@ + + +package com.docusign.webforms.client.auth; + +import com.docusign.webforms.client.Pair; + +import java.util.Map; +import java.util.List; + + +/** + * ApiKeyAuth class. + * + */ +public class ApiKeyAuth implements Authentication { + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + /** + * ApiKeyAuth constructor. + * + * @param location Sets location + * @param paramName Sets paramName + */ + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + /** + * getLocation method. + * + * @return String + */ + public String getLocation() { + return location; + } + + /** + * getParamName method. + * + * @return String + */ + public String getParamName() { + return paramName; + } + + /** + * getApiKey method. + * + * @return String + */ + public String getApiKey() { + return apiKey; + } + + /** + * setApiKey method. + * + * @param apiKey The apiKey + */ + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + /** + * getApiKeyPrefix method. + * + * @return String + */ + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + /** + * setApiKeyPrefix method. + * + * @param apiKeyPrefix The apiKeyPrefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + /** + * applyToParams method. + * + * @param queryParams The query params + * @param headerParams The header params + */ + @Override + public void applyToParams(List queryParams, Map headerParams) { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if ("query".equals(location)) { + queryParams.add(new Pair(paramName, value)); + } else if ("header".equals(location)) { + headerParams.put(paramName, value); + } + } +} diff --git a/src/main/java/com/docusign/webforms/client/auth/Authentication.java b/src/main/java/com/docusign/webforms/client/auth/Authentication.java new file mode 100644 index 0000000..0da62fd --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/auth/Authentication.java @@ -0,0 +1,18 @@ + + +package com.docusign.webforms.client.auth; + +import com.docusign.webforms.client.Pair; + +import java.util.Map; +import java.util.List; + +public interface Authentication { + /** + * Apply authentication settings to header and query params. + * + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + */ + void applyToParams(List queryParams, Map headerParams); +} diff --git a/src/main/java/com/docusign/webforms/client/auth/HttpBasicAuth.java b/src/main/java/com/docusign/webforms/client/auth/HttpBasicAuth.java new file mode 100644 index 0000000..1812d82 --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/auth/HttpBasicAuth.java @@ -0,0 +1,74 @@ + + +package com.docusign.webforms.client.auth; + +import com.docusign.webforms.client.Pair; + +import java.util.Base64; +import java.nio.charset.StandardCharsets; + +import java.util.Map; +import java.util.List; + + + + +/** + * HttpBasicAuth class. + * + */ +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + /** + * getUsername method. + * + * @return String + */ + public String getUsername() { + return username; + } + + /** + * setUsername method. + * + * @param username Sets username + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * getPassword method. + * + * @return String + */ + public String getPassword() { + return password; + } + + /** + * setPassword method. + * + * @param password Sets password + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * applyToParams method. + * + * @param queryParams The query params + * @param headerParams The header params + */ + @Override + public void applyToParams(List queryParams, Map headerParams) { + if (username == null && password == null) { + return; + } + String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); + headerParams.put("Authorization", "Basic " + Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8))); + } +} diff --git a/src/main/java/com/docusign/webforms/client/auth/JWTUtils.java b/src/main/java/com/docusign/webforms/client/auth/JWTUtils.java new file mode 100644 index 0000000..216612e --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/auth/JWTUtils.java @@ -0,0 +1,263 @@ +package com.docusign.webforms.client.auth; + +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTCreator; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.exceptions.JWTCreationException; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.StringReader; +import java.security.KeyFactory; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Security; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.EncodedKeySpec; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; +import java.util.Date; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.bouncycastle.util.io.pem.PemObject; +import org.bouncycastle.util.io.pem.PemReader; + +/** + * JWTUtils class. + * + */ +public class JWTUtils { + + /** + * Helper method to create a JWT token for the JWT flow. + * + * @param rsaPrivateKey the byte contents of the RSA private key + * @param oAuthBasePath DocuSign OAuth base path (account-d.docusign.com for the developer sandbox + * and account.docusign.com for the production platform) + * @param clientId DocuSign OAuth Client Id (AKA Integrator Key) + * @param userId DocuSign user Id to be impersonated (This is a UUID) + * @param expiresIn number of seconds remaining before the JWT assertion is considered as invalid + * @param scopes space-separated string that represents the list of scopes to grant to the OAuth + * token. + * @return a fresh JWT token + * @throws IllegalArgumentException if one of the arguments is invalid + * @throws JWTCreationException if not able to create a JWT token from the input parameters + * @throws IOException if there is an issue with either the public or private file + */ + public static String generateJWTAssertionFromByteArray( + byte[] rsaPrivateKey, + String oAuthBasePath, + String clientId, + String userId, + long expiresIn, + String scopes) + throws IllegalArgumentException, JWTCreationException, IOException { + if (expiresIn <= 0L) { + throw new IllegalArgumentException("expiresIn should be a non-negative value"); + } + if (rsaPrivateKey == null || rsaPrivateKey.length == 0) { + throw new IllegalArgumentException("rsaPrivateKey byte array is empty"); + } + if (oAuthBasePath == null + || "".equals(oAuthBasePath) + || clientId == null + || "".equals(clientId)) { + throw new IllegalArgumentException("One of the arguments is null or empty"); + } + + RSAPrivateKey privateKey = readPrivateKeyFromByteArray(rsaPrivateKey, "RSA"); + Algorithm algorithm = Algorithm.RSA256(null, privateKey); + long now = System.currentTimeMillis(); + JWTCreator.Builder builder = + JWT.create() + .withIssuer(clientId) + .withAudience(oAuthBasePath) + .withIssuedAt(new Date(now)) + .withClaim("scope", scopes) + .withExpiresAt(new Date(now + expiresIn * 1000)); + if (userId != null && userId != "") { + builder = builder.withSubject(userId); + } + return builder.sign(algorithm); + } + + /** + * Helper method to create a JWT token for the JWT flow. + * + * @param publicKeyFilename the filename of the RSA public key + * @param privateKeyFilename the filename of the RSA private key + * @param oAuthBasePath DocuSign OAuth base path (account-d.docusign.com for the developer sandbox + * and account.docusign.com for the production platform) + * @param clientId DocuSign OAuth Client Id (AKA Integrator Key) + * @param userId DocuSign user Id to be impersonated (This is a UUID) + * @param expiresIn number of seconds remaining before the JWT assertion is considered as invalid + * @return a fresh JWT token + * @throws JWTCreationException if not able to create a JWT token from the input parameters + * @throws IOException if there is an issue with either the public or private file + */ + public static String generateJWTAssertion( + String publicKeyFilename, + String privateKeyFilename, + String oAuthBasePath, + String clientId, + String userId, + long expiresIn) + throws JWTCreationException, IOException { + return generateJWTAssertion(publicKeyFilename, privateKeyFilename, oAuthBasePath, clientId, userId, expiresIn, "signature"); + } + + /** + * Helper method to create a JWT token for the JWT flow. + * + * @param publicKeyFilename the filename of the RSA public key + * @param privateKeyFilename the filename of the RSA private key + * @param oAuthBasePath DocuSign OAuth base path (account-d.docusign.com for the developer sandbox + * and account.docusign.com for the production platform) + * @param clientId DocuSign OAuth Client Id (AKA Integrator Key) + * @param userId DocuSign user Id to be impersonated (This is a UUID) + * @param expiresIn number of seconds remaining before the JWT assertion is considered as invalid + * @param scopes space-separated string that represents the list of scopes to grant to the OAuth + * token. + * @return a fresh JWT token + * @throws JWTCreationException if not able to create a JWT token from the input parameters + * @throws IOException if there is an issue with either the public or private file + */ + public static String generateJWTAssertion( + String publicKeyFilename, + String privateKeyFilename, + String oAuthBasePath, + String clientId, + String userId, + long expiresIn, + String scopes) + throws JWTCreationException, IOException { + String token = null; + if (expiresIn <= 0L) { + throw new IllegalArgumentException("expiresIn should be a non-negative value"); + } + if (publicKeyFilename == null + || "".equals(publicKeyFilename) + || privateKeyFilename == null + || "".equals(privateKeyFilename) + || oAuthBasePath == null + || "".equals(oAuthBasePath) + || clientId == null + || "".equals(clientId) + || userId == null + || "".equals(userId)) { + throw new IllegalArgumentException("One of the arguments is null or empty"); + } + + try { + RSAPublicKey publicKey = readPublicKeyFromFile(publicKeyFilename, "RSA"); + RSAPrivateKey privateKey = readPrivateKeyFromFile(privateKeyFilename, "RSA"); + Algorithm algorithm = Algorithm.RSA256(publicKey, privateKey); + long now = System.currentTimeMillis(); + token = + JWT.create() + .withIssuer(clientId) + .withSubject(userId) + .withAudience(oAuthBasePath) + .withNotBefore(new Date(now)) + .withExpiresAt(new Date(now + expiresIn * 1000)) + .withClaim("scope", scopes) + .sign(algorithm); + } catch (JWTCreationException e) { + throw e; + } catch (IOException e) { + throw e; + } + + return token; + } + + private static RSAPublicKey readPublicKeyFromFile(String filepath, String algorithm) + throws IOException { + File pemFile = new File(filepath); + if (!pemFile.isFile() || !pemFile.exists()) { + throw new FileNotFoundException( + String.format("The file '%s' doesn't exist.", pemFile.getAbsolutePath())); + } + PemReader reader = new PemReader(new FileReader(pemFile)); + try { + PemObject pemObject = reader.readPemObject(); + byte[] bytes = pemObject.getContent(); + RSAPublicKey publicKey = null; + try { + KeyFactory kf = KeyFactory.getInstance(algorithm); + EncodedKeySpec keySpec = new X509EncodedKeySpec(bytes); + publicKey = (RSAPublicKey) kf.generatePublic(keySpec); + } catch (NoSuchAlgorithmException e) { + System.out.println( + "Could not reconstruct the public key, the given algorithm could not be found."); + } catch (InvalidKeySpecException e) { + System.out.println("Could not reconstruct the public key"); + } + + return publicKey; + } finally { + reader.close(); + } + } + + private static RSAPrivateKey readPrivateKeyFromFile(String filepath, String algorithm) + throws IOException { + File pemFile = new File(filepath); + if (!pemFile.isFile() || !pemFile.exists()) { + throw new FileNotFoundException( + String.format("The file '%s' doesn't exist.", pemFile.getAbsolutePath())); + } + PemReader reader = new PemReader(new FileReader(pemFile)); + try { + PemObject pemObject = reader.readPemObject(); + byte[] bytes = pemObject.getContent(); + RSAPrivateKey privateKey = null; + try { + Security.addProvider(new BouncyCastleProvider()); + KeyFactory kf = KeyFactory.getInstance(algorithm, "BC"); + EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(bytes); + privateKey = (RSAPrivateKey) kf.generatePrivate(keySpec); + } catch (NoSuchAlgorithmException e) { + System.out.println( + "Could not reconstruct the private key, the given algorithm could not be found."); + } catch (InvalidKeySpecException e) { + System.out.println("Could not reconstruct the private key"); + } catch (NoSuchProviderException e) { + System.out.println("Could not reconstruct the private key, invalid provider."); + } + + return privateKey; + } finally { + reader.close(); + } + } + + private static RSAPrivateKey readPrivateKeyFromByteArray(byte[] privateKeyBytes, String algorithm) + throws IOException { + PemReader reader = new PemReader(new StringReader(new String(privateKeyBytes))); + try { + PemObject pemObject = reader.readPemObject(); + byte[] bytes = pemObject.getContent(); + RSAPrivateKey privateKey = null; + try { + Security.addProvider(new BouncyCastleProvider()); + KeyFactory kf = KeyFactory.getInstance(algorithm, "BC"); + EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(bytes); + privateKey = (RSAPrivateKey) kf.generatePrivate(keySpec); + } catch (NoSuchAlgorithmException e) { + System.out.println( + "Could not reconstruct the private key, the given algorithm could not be found."); + } catch (InvalidKeySpecException e) { + System.out.println("Could not reconstruct the private key"); + } catch (NoSuchProviderException e) { + System.out.println("Could not reconstruct the private key, invalid provider."); + } + + return privateKey; + } finally { + reader.close(); + } + } +} diff --git a/src/main/java/com/docusign/webforms/client/auth/OAuth.java b/src/main/java/com/docusign/webforms/client/auth/OAuth.java new file mode 100644 index 0000000..1bfc78c --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/auth/OAuth.java @@ -0,0 +1,967 @@ +package com.docusign.webforms.client.auth; + +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.core.Response; + +import com.docusign.webforms.client.ApiException; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.apache.oltu.oauth2.client.OAuthClient; +import org.apache.oltu.oauth2.client.URLConnectionClient; +import org.apache.oltu.oauth2.client.request.OAuthClientRequest; +import org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse; +import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder; +import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder; +import org.apache.oltu.oauth2.common.message.types.GrantType; +import org.apache.oltu.oauth2.common.token.BasicOAuthToken; + +import com.docusign.webforms.client.Pair; +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.ws.rs.client.Client; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * OAuth class. + * + */ +public class OAuth implements Authentication { + static final int MILLIS_PER_SECOND = 1000; + + // OAuth Scope constants + /** create and send envelopes, and obtain links for starting signing sessions. */ + public final static String Scope_SIGNATURE = "signature"; + /** obtain a refresh token with an extended lifetime. */ + public final static String Scope_EXTENDED = "extended"; + /** obtain access to the user’s account when the user is not present. */ + public final static String Scope_IMPERSONATION = "impersonation"; + + // OAuth ResponseType constants + /** used by public/native client applications. */ + public final static String CODE = "code"; + /** used by private/trusted client application. */ + public final static String TOKEN = "token"; + + // OAuth base path constants + /** live/production base path. */ + public final static String PRODUCTION_OAUTH_BASEPATH = "account.docusign.com"; + /** sandbox/demo base path. */ + public final static String DEMO_OAUTH_BASEPATH = "account-d.docusign.com"; + /** stage base path. */ + public final static String STAGE_OAUTH_BASEPATH = "account-s.docusign.com"; + + // OAuth grant types + /** JWT grant type. */ + public final static String GRANT_TYPE_JWT = "urn:ietf:params:oauth:grant-type:jwt-bearer"; + + private volatile String accessToken; + private Long expirationTimeMillis; + private OAuthClient oauthClient; + private TokenRequestBuilder tokenRequestBuilder; + private AuthenticationRequestBuilder authenticationRequestBuilder; + private AccessTokenListener accessTokenListener; + + /** + * OAuth constructor. + * + */ + public OAuth() { + this(null, null, null); + } + + /** + * OAuth constructor. + * + * @param client The client to use + * @param tokenRequestBuilder The request builder + * @param authenticationRequestBuilder The auth request builder + */ + public OAuth(Client client, TokenRequestBuilder tokenRequestBuilder, AuthenticationRequestBuilder authenticationRequestBuilder) { + this.oauthClient = new OAuthClient(new URLConnectionClient()); + this.tokenRequestBuilder = tokenRequestBuilder; + this.authenticationRequestBuilder = authenticationRequestBuilder; + } + + /** + * OAuth constructor. + * + * @param client The client to use + * @param flow The OAuth flow + * @param authorizationUrl The auth url + * @param tokenUrl The token URL + * @param scopes The scopes to use + */ + public OAuth(Client client, OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) { + this(client, OAuthClientRequest.tokenLocation(tokenUrl).setScope(scopes), OAuthClientRequest.authorizationLocation(authorizationUrl).setScope(scopes)); + + switch (flow) { + case accessCode: + tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE); + authenticationRequestBuilder.setResponseType(OAuth.CODE); + break; + case implicit: + tokenRequestBuilder.setGrantType(GrantType.IMPLICIT); + authenticationRequestBuilder.setResponseType(OAuth.TOKEN); + break; + case password: + tokenRequestBuilder.setGrantType(GrantType.PASSWORD); + break; + case application: + tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS); + break; + default: + break; + } + } + + /** + * OAuth constructor. + * + * @param flow The OAuth flow + * @param authorizationUrl The auth url + * @param tokenUrl The token URL + * @param scopes The scopes to use + */ + public OAuth(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) { + this(ClientBuilder.newBuilder().build(), flow, authorizationUrl, tokenUrl, scopes); + } + + /** + * applyToParams method. + * + * @param queryParams The query params + * @param headerParams The header params + */ + @Override + public void applyToParams(List queryParams, Map headerParams) { + // If first time, get the token + if (expirationTimeMillis == null || System.currentTimeMillis() >= expirationTimeMillis) { + try { + updateAccessToken(); + } catch (ApiException e) { + accessToken = null; + } + } + if (accessToken != null) { + headerParams.put("Authorization", "Bearer " + accessToken); + } + } + + /** + * updateAccessToken method. + * + */ + public synchronized void updateAccessToken() throws ApiException { + OAuthJSONAccessTokenResponse accessTokenResponse; + try { + accessTokenResponse = oauthClient.accessToken(tokenRequestBuilder.buildBodyMessage()); + } catch (Exception e) { + throw new ApiException(e.getMessage()); + } + if (accessTokenResponse != null) + { + // FIXME: This does not work in case of non HTTP 200 :-( oauthClient needs to return the plain HTTP resonse + if (accessTokenResponse.getResponseCode() != Response.Status.OK.getStatusCode()) + { + throw new ApiException("Error while requesting an access token, received HTTP code: " + accessTokenResponse.getResponseCode()); + } + + if (accessTokenResponse.getAccessToken() == null) { + throw new ApiException("Error while requesting an access token. No 'access_token' found."); + } + if (accessTokenResponse.getExpiresIn() == null) { + throw new ApiException("Error while requesting an access token. No 'expires_in' found."); + } + + setAccessToken(accessTokenResponse.getAccessToken(), accessTokenResponse.getExpiresIn()); + if (this.accessTokenListener != null) { + this.accessTokenListener.notify((BasicOAuthToken)accessTokenResponse.getOAuthToken()); + } + } else { + // in case of HTTP error codes accessTokenResponse is null, thus no check of accessTokenResponse.getResponseCode() possible :-( + throw new ApiException("Error while requesting an access token. No accessTokenResponse object recieved, maybe a non HTTP 200 received?"); + } + } + + /** + * registerAccessTokenListener method. + * + * @param accessTokenListener The access token listener + */ + public synchronized void registerAccessTokenListener(AccessTokenListener accessTokenListener) { + this.accessTokenListener = accessTokenListener; + } + + /** + * getAccessToken method. + * + * @return String + */ + public synchronized String getAccessToken() { + return accessToken; + } + + public synchronized void setAccessToken(String accessToken, Long expiresIn) { + this.accessToken = accessToken; + this.expirationTimeMillis = System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND; + } + + public TokenRequestBuilder getTokenRequestBuilder() { + return tokenRequestBuilder; + } + + public void setTokenRequestBuilder(TokenRequestBuilder tokenRequestBuilder) { + this.tokenRequestBuilder = tokenRequestBuilder; + } + + public AuthenticationRequestBuilder getAuthenticationRequestBuilder() { + return authenticationRequestBuilder; + } + + public void setAuthenticationRequestBuilder(AuthenticationRequestBuilder authenticationRequestBuilder) { + this.authenticationRequestBuilder = authenticationRequestBuilder; + } + + public OAuthClient getOauthClient() { + return oauthClient; + } + + public void setOauthClient(OAuthClient oauthClient) { + this.oauthClient = oauthClient; + } + + public void setOauthClient(Client client) { + this.oauthClient = new OAuthClient(new URLConnectionClient()); + } + + /** + * + * OAuthToken model with the following properties. + *
accessToken: the token you will use in the Authorization header of calls to the DocuSign API. + *
tokenType: this is the type of the accessToken. It is usually "Bearer". + *
refreshToken: a token you can use to get a new accessToken without requiring user interaction. + *
expiresIn: the number of seconds before the accessToken expires. + * + */ + @JsonIgnoreProperties(ignoreUnknown = true) + public static class OAuthToken { + @JsonProperty("access_token") + private String accessToken = null; + + @JsonProperty("token_type") + private String tokenType = null; + + @JsonProperty("refresh_token") + private String refreshToken = null; + + @JsonProperty("expires_in") + private Long expiresIn = 0L; + + public OAuthToken accessToken(String accessToken) { + this.accessToken = accessToken; + return this; + } + + /** + * Get accessToken. + * + * @return accessToken + **/ + @Schema(example = "null", description = "") + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public OAuthToken isTokenType(String tokenType) { + this.tokenType = tokenType; + return this; + } + + /** + * Get tokenType. + * + * @return tokenType + **/ + @Schema(example = "null", description = "") + public String getTokenType() { + return tokenType; + } + + public void setTokenType(String tokenType) { + this.tokenType = tokenType; + } + + public OAuthToken refreshToken(String refreshToken) { + this.refreshToken = refreshToken; + return this; + } + + /** + * Get refreshToken. + * + * @return refreshToken + **/ + @Schema(example = "null", description = "") + public String getRefreshToken() { + return refreshToken; + } + + public void setRefreshToken(String refreshToken) { + this.refreshToken = refreshToken; + } + + public OAuthToken expiresIn(Long expiresIn) { + this.expiresIn = expiresIn; + return this; + } + + /** + * Get expiresIn. + * + * @return expiresIn + **/ + @Schema(example = "3600L", description = "0L") + public Long getExpiresIn() { + return expiresIn; + } + + public void setExpiresIn(Long expiresIn) { + this.expiresIn = expiresIn; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OAuthToken oAuthToken = (OAuthToken) o; + return Objects.equals(this.accessToken, oAuthToken.accessToken) + && Objects.equals(this.tokenType, oAuthToken.tokenType) + && Objects.equals(this.refreshToken, oAuthToken.refreshToken) + && Objects.equals(this.expiresIn, oAuthToken.expiresIn); + } + + @Override + public int hashCode() { + return Objects.hash(accessToken, tokenType, refreshToken, expiresIn); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OAuthToken {\n"); + + sb.append(" accessToken: ").append(toIndentedString(accessToken)).append("\n"); + sb.append(" tokenType: ").append(toIndentedString(tokenType)).append("\n"); + sb.append(" refreshToken: ").append(toIndentedString(refreshToken)).append("\n"); + sb.append(" expiresIn: ").append(toIndentedString(expiresIn)).append("\n"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 + * spaces (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + } + + /** + * + * Link model with the below properties. + *
rel: currently the only value is "self". + *
href: the direct link of the organization. + * + */ + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Link { + @JsonProperty("rel") + private String rel = null; + + @JsonProperty("href") + private String href = null; + + public Link rel(String rel) { + this.rel = rel; + return this; + } + + /** + * Get rel. + * + * @return rel + **/ + @Schema(example = "null", description = "") + public String getRel() { + return rel; + } + + public void setRel(String rel) { + this.rel = rel; + } + + public Link href(String href) { + this.href = href; + return this; + } + + /** + * Get href. + * + * @return href + **/ + @Schema(example = "null", description = "") + public String getHref() { + return href; + } + + public void setHref(String href) { + this.href = href; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Link link = (Link) o; + return Objects.equals(this.rel, link.rel) + && Objects.equals(this.href, link.href); + } + + @Override + public int hashCode() { + return Objects.hash(rel, href); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Link {\n"); + + sb.append(" rel: ").append(toIndentedString(rel)).append("\n"); + sb.append(" href: ").append(toIndentedString(href)).append("\n"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 + * spaces (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + } + + /** + * + * Organization model with the below properties. + *
organizationId: the organization ID GUID if DocuSign Org Admin is enabled. + *
links: this is list of organization direct links associated with the DocuSign account. + * + */ + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Organization { + @JsonProperty("organization_id") + private String organizationId = null; + + @JsonProperty("links") + private java.util.List links = new java.util.ArrayList(); + + public Organization organizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + /** + * Get organizationId. + * + * @return organizationId + **/ + @Schema(example = "null", description = "") + public String getOrganizationId() { + return organizationId; + } + + public void setOrganizationId(String organizationId) { + this.organizationId = organizationId; + } + + public Organization links(java.util.List links) { + this.links = links; + return this; + } + + public Organization addLinksItem(Link linksItem) { + this.links.add(linksItem); + return this; + } + + /** + * Get links. + * + * @return links + **/ + @Schema(example = "null", description = "") + public java.util.List getLinks() { + return links; + } + + public void setLinks(java.util.List links) { + this.links = links; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Organization organization = (Organization) o; + return Objects.equals(this.organizationId, organization.organizationId) + && Objects.equals(this.links, organization.links); + } + + @Override + public int hashCode() { + return Objects.hash(organizationId, links); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Organization {\n"); + + sb.append(" organizationId: ").append(toIndentedString(organizationId)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 + * spaces (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + } + + /** + * + * Account model with the below properties. + *
accountId: the account ID GUID. + *
isDefault: whether this is the default account, when the user has access to multiple accounts. + *
accountName: the human-readable name of the account. + *
baseUri: the base URI associated with this account. + * It also tells which DocuSign data center the account is hosted on. + *
organization: If DocuSign Org Admin is enabled on this account, + * this property contains the organization information. + * + */ + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Account { + @JsonProperty("account_id") + private String accountId = null; + + @JsonProperty("is_default") + private String isDefault = null; + + @JsonProperty("account_name") + private String accountName = null; + + @JsonProperty("base_uri") + private String baseUri = null; + + @JsonProperty("organization") + private Organization organization = new Organization(); + + public Account accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Get accountId. + * + * @return accountId + **/ + @Schema(example = "null", description = "") + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public Account isDefault(String isDefault) { + this.isDefault = isDefault; + return this; + } + + /** + * Get isDefault. + * + * @return isDefault + **/ + @Schema(example = "null", description = "") + public String getIsDefault() { + return isDefault; + } + + public void setIsDefault(String isDefault) { + this.isDefault = isDefault; + } + + public Account accountName(String accountName) { + this.accountName = accountName; + return this; + } + + /** + * Get accountName. + * + * @return accountName + **/ + @Schema(example = "null", description = "") + public String getAccountName() { + return accountName; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + public Account baseUri(String baseUri) { + this.baseUri = baseUri; + return this; + } + + /** + * Get baseUri. + * + * @return baseUri + **/ + @Schema(example = "null", description = "") + public String getBaseUri() { + return baseUri; + } + + public void setBaseUri(String baseUri) { + this.baseUri = baseUri; + } + + public Account organization(Organization organization) { + this.organization = organization; + return this; + } + + /** + * Get organization. + * + * @return organization + **/ + @Schema(example = "null", description = "") + public Organization getOrganization() { + return organization; + } + + public void setOrganization(Organization organization) { + this.organization = organization; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Account account = (Account) o; + return Objects.equals(this.accountId, account.accountId) + && Objects.equals(this.isDefault, account.isDefault) + && Objects.equals(this.accountName, account.accountName) + && Objects.equals(this.baseUri, account.baseUri) + && Objects.equals(this.organization, account.organization); + } + + @Override + public int hashCode() { + return Objects.hash(accountId, isDefault, accountName, baseUri, organization); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Account {\n"); + + sb.append(" accountId: ").append(toIndentedString(accountId)).append("\n"); + sb.append(" isDefault: ").append(toIndentedString(isDefault)).append("\n"); + sb.append(" accountName: ").append(toIndentedString(accountName)).append("\n"); + sb.append(" baseUri: ").append(toIndentedString(baseUri)).append("\n"); + sb.append(" organization: ").append(toIndentedString(organization)).append("\n"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 + * spaces (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + } + + /** + * + * UserInfo model with the below properties. + *
sub: the user ID GUID. + *
accounts: this is list of DocuSign accounts associated with the current user. + *
name: the user's full name. + *
givenName: the user's given name. + *
familyName: the user's family name. + *
email: the user's email address. + *
created: the UTC DateTime when the user login was created. + * + * @see Account + * + */ + @JsonIgnoreProperties(ignoreUnknown = true) + public static class UserInfo { + + @JsonProperty("sub") + private String sub = null; + + @JsonProperty("email") + private String email = null; + + @JsonProperty("accounts") + private java.util.List accounts = new java.util.ArrayList(); + + @JsonProperty("name") + private String name = null; + + @JsonProperty("given_name") + private String givenName = null; + + @JsonProperty("family_name") + private String familyName = null; + + @JsonProperty("created") + private String created = null; + + public UserInfo sub(String sub) { + this.sub = sub; + return this; + } + + /** + * Get sub. + * + * @return sub + **/ + @Schema(example = "null", description = "") + public String getSub() { + return sub; + } + + public void setSub(String sub) { + this.sub = sub; + } + + public UserInfo email(String email) { + this.email = email; + return this; + } + + /** + * Get email. + * + * @return email + **/ + @Schema(example = "null", description = "") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public UserInfo accounts(java.util.List accounts) { + this.accounts = accounts; + return this; + } + + public UserInfo addAccountsItem(Account accountsItem) { + this.accounts.add(accountsItem); + return this; + } + + /** + * Get accounts. + * + * @return accounts + **/ + @Schema(example = "null", description = "") + public java.util.List getAccounts() { + return accounts; + } + + public void setAccounts(java.util.List accounts) { + this.accounts = accounts; + } + + public UserInfo name(String name) { + this.name = name; + return this; + } + + /** + * Get name. + * + * @return name + **/ + @Schema(example = "null", description = "") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public UserInfo givenName(String givenName) { + this.givenName = givenName; + return this; + } + + /** + * Get givenName. + * + * @return givenName + **/ + @Schema(example = "null", description = "") + public String getGivenName() { + return givenName; + } + + public void setGivenName(String givenName) { + this.givenName = givenName; + } + + public UserInfo familyName(String familyName) { + this.familyName = familyName; + return this; + } + + /** + * Get familyName. + * + * @return familyName + **/ + @Schema(example = "null", description = "") + public String getFamilyName() { + return familyName; + } + + public void setFamilyName(String familyName) { + this.familyName = familyName; + } + + public UserInfo created(String created) { + this.created = created; + return this; + } + + /** + * Get created. + * + * @return created + **/ + @Schema(example = "null", description = "") + public String getCreated() { + return created; + } + + public void setCreated(String created) { + this.created = created; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserInfo userInfo = (UserInfo) o; + return Objects.equals(this.sub, userInfo.sub) && Objects.equals(this.email, userInfo.email) + && Objects.equals(this.accounts, userInfo.accounts) && Objects.equals(this.name, userInfo.name) + && Objects.equals(this.givenName, userInfo.givenName) && Objects.equals(this.familyName, userInfo.familyName) + && Objects.equals(this.created, userInfo.created); + } + + @Override + public int hashCode() { + return Objects.hash(sub, email, accounts, name, givenName, familyName, created); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UserInfo {\n"); + + sb.append(" sub: ").append(toIndentedString(sub)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" givenName: ").append(toIndentedString(givenName)).append("\n"); + sb.append(" familyName: ").append(toIndentedString(familyName)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append(" accounts: ").append(toIndentedString(accounts)).append("\n"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + } +} diff --git a/src/main/java/com/docusign/webforms/client/auth/OAuthFlow.java b/src/main/java/com/docusign/webforms/client/auth/OAuthFlow.java new file mode 100644 index 0000000..a0817ae --- /dev/null +++ b/src/main/java/com/docusign/webforms/client/auth/OAuthFlow.java @@ -0,0 +1,12 @@ + + +package com.docusign.webforms.client.auth; + + /** + * enum. + * + */ + +public enum OAuthFlow { + accessCode, implicit, password, application +} diff --git a/src/main/java/com/docusign/webforms/model/AuthenticationMethod.java b/src/main/java/com/docusign/webforms/model/AuthenticationMethod.java new file mode 100644 index 0000000..cac6f26 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/AuthenticationMethod.java @@ -0,0 +1,77 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.v3.oas.annotations.media.Schema; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * A value that most closely matches the technique your application used to authenticate the recipient / signer. + */ +public enum AuthenticationMethod { + + BIOMETRIC("Biometric"), + + EMAIL("Email"), + + HTTPBASICAUTH("HTTPBasicAuth"), + + KERBEROS("Kerberos"), + + KNOWLEDGEBASEDAUTH("KnowledgeBasedAuth"), + + NONE("None"), + + PAPERDOCUMENTS("PaperDocuments"), + + PASSWORD("Password"), + + RSASECUREID("RSASecureID"), + + SINGLESIGNON_CASITEMINDER("SingleSignOn_CASiteminder"), + + SINGLESIGNON_INFOCARD("SingleSignOn_InfoCard"), + + SINGLESIGNON_MICROSOFTACTIVEDIRECTORY("SingleSignOn_MicrosoftActiveDirectory"), + + SINGLESIGNON_OTHER("SingleSignOn_Other"), + + SINGLESIGNON_PASSPORT("SingleSignOn_Passport"), + + SINGLESIGNON_SAML("SingleSignOn_SAML"), + + SMARTCARD("Smartcard"), + + SSLMUTUALAUTH("SSLMutualAuth"), + + X509CERTIFICATE("X509Certificate"); + + private String value; + + AuthenticationMethod(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static AuthenticationMethod fromValue(String value) { + for (AuthenticationMethod b : AuthenticationMethod.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } +} + diff --git a/src/main/java/com/docusign/webforms/model/CreateInstanceRequestBody.java b/src/main/java/com/docusign/webforms/model/CreateInstanceRequestBody.java new file mode 100644 index 0000000..4bcda92 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/CreateInstanceRequestBody.java @@ -0,0 +1,370 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.docusign.webforms.model.AuthenticationMethod; +import com.docusign.webforms.model.WebFormValues; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Request body containing properties that will be used to create instance.. + * + */ +@Schema(description = "Request body containing properties that will be used to create instance.") + +public class CreateInstanceRequestBody { + @JsonProperty("formValues") + private WebFormValues formValues = null; + + @JsonProperty("clientUserId") + private String clientUserId = null; + + @JsonProperty("authenticationInstant") + private String authenticationInstant = null; + + @JsonProperty("authenticationMethod") + private AuthenticationMethod authenticationMethod = null; + + @JsonProperty("assertionId") + private String assertionId = null; + + @JsonProperty("securityDomain") + private String securityDomain = null; + + @JsonProperty("returnUrl") + private String returnUrl = null; + + @JsonProperty("expirationOffset") + private Integer expirationOffset = null; + + @JsonProperty("tags") + private java.util.List tags = null; + + + /** + * formValues. + * + * @return CreateInstanceRequestBody + **/ + public CreateInstanceRequestBody formValues(WebFormValues formValues) { + this.formValues = formValues; + return this; + } + + /** + * Get formValues. + * @return formValues + **/ + @Schema(description = "") + public WebFormValues getFormValues() { + return formValues; + } + + /** + * setFormValues. + **/ + public void setFormValues(WebFormValues formValues) { + this.formValues = formValues; + } + + + /** + * clientUserId. + * + * @return CreateInstanceRequestBody + **/ + public CreateInstanceRequestBody clientUserId(String clientUserId) { + this.clientUserId = clientUserId; + return this; + } + + /** + * Get clientUserId. + * @return clientUserId + **/ + @Schema(required = true, description = "") + public String getClientUserId() { + return clientUserId; + } + + /** + * setClientUserId. + **/ + public void setClientUserId(String clientUserId) { + this.clientUserId = clientUserId; + } + + + /** + * authenticationInstant. + * + * @return CreateInstanceRequestBody + **/ + public CreateInstanceRequestBody authenticationInstant(String authenticationInstant) { + this.authenticationInstant = authenticationInstant; + return this; + } + + /** + * Get authenticationInstant. + * @return authenticationInstant + **/ + @Schema(description = "") + public String getAuthenticationInstant() { + return authenticationInstant; + } + + /** + * setAuthenticationInstant. + **/ + public void setAuthenticationInstant(String authenticationInstant) { + this.authenticationInstant = authenticationInstant; + } + + + /** + * authenticationMethod. + * + * @return CreateInstanceRequestBody + **/ + public CreateInstanceRequestBody authenticationMethod(AuthenticationMethod authenticationMethod) { + this.authenticationMethod = authenticationMethod; + return this; + } + + /** + * Get authenticationMethod. + * @return authenticationMethod + **/ + @Schema(description = "") + public AuthenticationMethod getAuthenticationMethod() { + return authenticationMethod; + } + + /** + * setAuthenticationMethod. + **/ + public void setAuthenticationMethod(AuthenticationMethod authenticationMethod) { + this.authenticationMethod = authenticationMethod; + } + + + /** + * assertionId. + * + * @return CreateInstanceRequestBody + **/ + public CreateInstanceRequestBody assertionId(String assertionId) { + this.assertionId = assertionId; + return this; + } + + /** + * Get assertionId. + * @return assertionId + **/ + @Schema(description = "") + public String getAssertionId() { + return assertionId; + } + + /** + * setAssertionId. + **/ + public void setAssertionId(String assertionId) { + this.assertionId = assertionId; + } + + + /** + * securityDomain. + * + * @return CreateInstanceRequestBody + **/ + public CreateInstanceRequestBody securityDomain(String securityDomain) { + this.securityDomain = securityDomain; + return this; + } + + /** + * Get securityDomain. + * @return securityDomain + **/ + @Schema(description = "") + public String getSecurityDomain() { + return securityDomain; + } + + /** + * setSecurityDomain. + **/ + public void setSecurityDomain(String securityDomain) { + this.securityDomain = securityDomain; + } + + + /** + * returnUrl. + * + * @return CreateInstanceRequestBody + **/ + public CreateInstanceRequestBody returnUrl(String returnUrl) { + this.returnUrl = returnUrl; + return this; + } + + /** + * Get returnUrl. + * @return returnUrl + **/ + @Schema(description = "") + public String getReturnUrl() { + return returnUrl; + } + + /** + * setReturnUrl. + **/ + public void setReturnUrl(String returnUrl) { + this.returnUrl = returnUrl; + } + + + /** + * expirationOffset. + * + * @return CreateInstanceRequestBody + **/ + public CreateInstanceRequestBody expirationOffset(Integer expirationOffset) { + this.expirationOffset = expirationOffset; + return this; + } + + /** + * Get expirationOffset. + * @return expirationOffset + **/ + @Schema(description = "") + public Integer getExpirationOffset() { + return expirationOffset; + } + + /** + * setExpirationOffset. + **/ + public void setExpirationOffset(Integer expirationOffset) { + this.expirationOffset = expirationOffset; + } + + + /** + * tags. + * + * @return CreateInstanceRequestBody + **/ + public CreateInstanceRequestBody tags(java.util.List tags) { + this.tags = tags; + return this; + } + + /** + * addTagsItem. + * + * @return CreateInstanceRequestBody + **/ + public CreateInstanceRequestBody addTagsItem(String tagsItem) { + if (this.tags == null) { + this.tags = new java.util.ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * List of tags provided by the user with each request. This field is optional.. + * @return tags + **/ + @Schema(example = "[\"loan_application\",\"finance_dept\"]", description = "List of tags provided by the user with each request. This field is optional.") + public java.util.List getTags() { + return tags; + } + + /** + * setTags. + **/ + public void setTags(java.util.List tags) { + this.tags = tags; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateInstanceRequestBody createInstanceRequestBody = (CreateInstanceRequestBody) o; + return Objects.equals(this.formValues, createInstanceRequestBody.formValues) && + Objects.equals(this.clientUserId, createInstanceRequestBody.clientUserId) && + Objects.equals(this.authenticationInstant, createInstanceRequestBody.authenticationInstant) && + Objects.equals(this.authenticationMethod, createInstanceRequestBody.authenticationMethod) && + Objects.equals(this.assertionId, createInstanceRequestBody.assertionId) && + Objects.equals(this.securityDomain, createInstanceRequestBody.securityDomain) && + Objects.equals(this.returnUrl, createInstanceRequestBody.returnUrl) && + Objects.equals(this.expirationOffset, createInstanceRequestBody.expirationOffset) && + Objects.equals(this.tags, createInstanceRequestBody.tags); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(formValues, clientUserId, authenticationInstant, authenticationMethod, assertionId, securityDomain, returnUrl, expirationOffset, tags); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateInstanceRequestBody {\n"); + + sb.append(" formValues: ").append(toIndentedString(formValues)).append("\n"); + sb.append(" clientUserId: ").append(toIndentedString(clientUserId)).append("\n"); + sb.append(" authenticationInstant: ").append(toIndentedString(authenticationInstant)).append("\n"); + sb.append(" authenticationMethod: ").append(toIndentedString(authenticationMethod)).append("\n"); + sb.append(" assertionId: ").append(toIndentedString(assertionId)).append("\n"); + sb.append(" securityDomain: ").append(toIndentedString(securityDomain)).append("\n"); + sb.append(" returnUrl: ").append(toIndentedString(returnUrl)).append("\n"); + sb.append(" expirationOffset: ").append(toIndentedString(expirationOffset)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/HttpError.java b/src/main/java/com/docusign/webforms/model/HttpError.java new file mode 100644 index 0000000..f38a841 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/HttpError.java @@ -0,0 +1,131 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * An error occurred while processing a request. Source - https://www.baeldung.com/rest-api-error-handling-best-practices. + * + */ +@Schema(description = "An error occurred while processing a request. Source - https://www.baeldung.com/rest-api-error-handling-best-practices") + +public class HttpError { + @JsonProperty("errorCode") + private String errorCode = null; + + @JsonProperty("message") + private String message = null; + + + /** + * errorCode. + * + * @return HttpError + **/ + public HttpError errorCode(String errorCode) { + this.errorCode = errorCode; + return this; + } + + /** + * A granular, human and computer readable code indicating more deeply what error occurred.. + * @return errorCode + **/ + @Schema(description = "A granular, human and computer readable code indicating more deeply what error occurred.") + public String getErrorCode() { + return errorCode; + } + + /** + * setErrorCode. + **/ + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + + /** + * message. + * + * @return HttpError + **/ + public HttpError message(String message) { + this.message = message; + return this; + } + + /** + * A human-readable description of the error, meant for developers to store for their review.. + * @return message + **/ + @Schema(description = "A human-readable description of the error, meant for developers to store for their review.") + public String getMessage() { + return message; + } + + /** + * setMessage. + **/ + public void setMessage(String message) { + this.message = message; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HttpError httpError = (HttpError) o; + return Objects.equals(this.errorCode, httpError.errorCode) && + Objects.equals(this.message, httpError.message); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(errorCode, message); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HttpError {\n"); + + sb.append(" errorCode: ").append(toIndentedString(errorCode)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/HttpSuccess.java b/src/main/java/com/docusign/webforms/model/HttpSuccess.java new file mode 100644 index 0000000..d1ef01b --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/HttpSuccess.java @@ -0,0 +1,99 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * A simple response indicating success when no extra data is needed. + * + */ +@Schema(description = "A simple response indicating success when no extra data is needed") + +public class HttpSuccess { + @JsonProperty("status") + private String status = null; + + + /** + * status. + * + * @return HttpSuccess + **/ + public HttpSuccess status(String status) { + this.status = status; + return this; + } + + /** + * Get status. + * @return status + **/ + @Schema(description = "") + public String getStatus() { + return status; + } + + /** + * setStatus. + **/ + public void setStatus(String status) { + this.status = status; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HttpSuccess httpSuccess = (HttpSuccess) o; + return Objects.equals(this.status, httpSuccess.status); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(status); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HttpSuccess {\n"); + + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/InstanceSource.java b/src/main/java/com/docusign/webforms/model/InstanceSource.java new file mode 100644 index 0000000..dd6e754 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/InstanceSource.java @@ -0,0 +1,49 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.v3.oas.annotations.media.Schema; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * The method through which form instance is created. + */ +public enum InstanceSource { + + PUBLIC_URL("PUBLIC_URL"), + + API_EMBEDDED("API_EMBEDDED"), + + API_REMOTE("API_REMOTE"), + + UI_REMOTE("UI_REMOTE"); + + private String value; + + InstanceSource(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static InstanceSource fromValue(String value) { + for (InstanceSource b : InstanceSource.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } +} + diff --git a/src/main/java/com/docusign/webforms/model/InstanceStatus.java b/src/main/java/com/docusign/webforms/model/InstanceStatus.java new file mode 100644 index 0000000..03d586e --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/InstanceStatus.java @@ -0,0 +1,49 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.v3.oas.annotations.media.Schema; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * The status of Web Form Instance. If the form status is INITIATED, it means the form is accessible until it is submitted or expired. If the form status is SUBMITTED, it means the form is submitted already and hence, cannot be opened again. + */ +public enum InstanceStatus { + + INITIATED("INITIATED"), + + SUBMITTED("SUBMITTED"), + + EXPIRED("EXPIRED"), + + FAILED("FAILED"); + + private String value; + + InstanceStatus(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static InstanceStatus fromValue(String value) { + for (InstanceStatus b : InstanceStatus.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } +} + diff --git a/src/main/java/com/docusign/webforms/model/Source.java b/src/main/java/com/docusign/webforms/model/Source.java new file mode 100644 index 0000000..94d0050 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/Source.java @@ -0,0 +1,49 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.v3.oas.annotations.media.Schema; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * The method through which form instance is created. + */ +public enum Source { + + PUBLIC_URL("PUBLIC_URL"), + + API_EMBEDDED("API_EMBEDDED"), + + API_REMOTE("API_REMOTE"), + + UI_REMOTE("UI_REMOTE"); + + private String value; + + Source(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static Source fromValue(String value) { + for (Source b : Source.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } +} + diff --git a/src/main/java/com/docusign/webforms/model/Tags.java b/src/main/java/com/docusign/webforms/model/Tags.java new file mode 100644 index 0000000..15cc58f --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/Tags.java @@ -0,0 +1,64 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * List of tags provided by the user with each request. This field is optional.. + * + */ +@Schema(description = "List of tags provided by the user with each request. This field is optional.") + +public class Tags extends java.util.ArrayList { + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return super.equals(o); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tags {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/TemplateProperties.java b/src/main/java/com/docusign/webforms/model/TemplateProperties.java new file mode 100644 index 0000000..bd57d09 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/TemplateProperties.java @@ -0,0 +1,209 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import java.time.OffsetDateTime; + +/** + * Information about a DocuSign template that will be used to seed a web form.. + * + */ +@Schema(description = "Information about a DocuSign template that will be used to seed a web form.") + +public class TemplateProperties { + @JsonProperty("originalTemplateId") + private String originalTemplateId = null; + + @JsonProperty("clonedTemplateId") + private String clonedTemplateId = null; + + @JsonProperty("importedDateTime") + private String importedDateTime = null; + + @JsonProperty("recipientIds") + private java.util.List recipientIds = null; + + + /** + * originalTemplateId. + * + * @return TemplateProperties + **/ + public TemplateProperties originalTemplateId(String originalTemplateId) { + this.originalTemplateId = originalTemplateId; + return this; + } + + /** + * Template identifier for original Template that is used by the DocuSign Template API.. + * @return originalTemplateId + **/ + @Schema(description = "Template identifier for original Template that is used by the DocuSign Template API.") + public String getOriginalTemplateId() { + return originalTemplateId; + } + + /** + * setOriginalTemplateId. + **/ + public void setOriginalTemplateId(String originalTemplateId) { + this.originalTemplateId = originalTemplateId; + } + + + /** + * clonedTemplateId. + * + * @return TemplateProperties + **/ + public TemplateProperties clonedTemplateId(String clonedTemplateId) { + this.clonedTemplateId = clonedTemplateId; + return this; + } + + /** + * Template identifier for cloned Template that is used by the DocuSign Template API.. + * @return clonedTemplateId + **/ + @Schema(description = "Template identifier for cloned Template that is used by the DocuSign Template API.") + public String getClonedTemplateId() { + return clonedTemplateId; + } + + /** + * setClonedTemplateId. + **/ + public void setClonedTemplateId(String clonedTemplateId) { + this.clonedTemplateId = clonedTemplateId; + } + + + /** + * importedDateTime. + * + * @return TemplateProperties + **/ + public TemplateProperties importedDateTime(String importedDateTime) { + this.importedDateTime = importedDateTime; + return this; + } + + /** + * Track the time of assignment of Template information to the Form.. + * @return importedDateTime + **/ + @Schema(description = "Track the time of assignment of Template information to the Form.") + public String getImportedDateTime() { + return importedDateTime; + } + + /** + * setImportedDateTime. + **/ + public void setImportedDateTime(String importedDateTime) { + this.importedDateTime = importedDateTime; + } + + + /** + * recipientIds. + * + * @return TemplateProperties + **/ + public TemplateProperties recipientIds(java.util.List recipientIds) { + this.recipientIds = recipientIds; + return this; + } + + /** + * addRecipientIdsItem. + * + * @return TemplateProperties + **/ + public TemplateProperties addRecipientIdsItem(String recipientIdsItem) { + if (this.recipientIds == null) { + this.recipientIds = new java.util.ArrayList<>(); + } + this.recipientIds.add(recipientIdsItem); + return this; + } + + /** + * Track mapped recipients on Template.. + * @return recipientIds + **/ + @Schema(description = "Track mapped recipients on Template.") + public java.util.List getRecipientIds() { + return recipientIds; + } + + /** + * setRecipientIds. + **/ + public void setRecipientIds(java.util.List recipientIds) { + this.recipientIds = recipientIds; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateProperties templateProperties = (TemplateProperties) o; + return Objects.equals(this.originalTemplateId, templateProperties.originalTemplateId) && + Objects.equals(this.clonedTemplateId, templateProperties.clonedTemplateId) && + Objects.equals(this.importedDateTime, templateProperties.importedDateTime) && + Objects.equals(this.recipientIds, templateProperties.recipientIds); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(originalTemplateId, clonedTemplateId, importedDateTime, recipientIds); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateProperties {\n"); + + sb.append(" originalTemplateId: ").append(toIndentedString(originalTemplateId)).append("\n"); + sb.append(" clonedTemplateId: ").append(toIndentedString(clonedTemplateId)).append("\n"); + sb.append(" importedDateTime: ").append(toIndentedString(importedDateTime)).append("\n"); + sb.append(" recipientIds: ").append(toIndentedString(recipientIds)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/UpdateInstanceRequestBody.java b/src/main/java/com/docusign/webforms/model/UpdateInstanceRequestBody.java new file mode 100644 index 0000000..5c5e500 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/UpdateInstanceRequestBody.java @@ -0,0 +1,100 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.docusign.webforms.model.WebFormValues; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Request body containing properties that needs to be updated.. + * + */ +@Schema(description = "Request body containing properties that needs to be updated.") + +public class UpdateInstanceRequestBody { + @JsonProperty("formValues") + private WebFormValues formValues = null; + + + /** + * formValues. + * + * @return UpdateInstanceRequestBody + **/ + public UpdateInstanceRequestBody formValues(WebFormValues formValues) { + this.formValues = formValues; + return this; + } + + /** + * Get formValues. + * @return formValues + **/ + @Schema(description = "") + public WebFormValues getFormValues() { + return formValues; + } + + /** + * setFormValues. + **/ + public void setFormValues(WebFormValues formValues) { + this.formValues = formValues; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateInstanceRequestBody updateInstanceRequestBody = (UpdateInstanceRequestBody) o; + return Objects.equals(this.formValues, updateInstanceRequestBody.formValues); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(formValues); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateInstanceRequestBody {\n"); + + sb.append(" formValues: ").append(toIndentedString(formValues)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/UserFilter.java b/src/main/java/com/docusign/webforms/model/UserFilter.java new file mode 100644 index 0000000..85436ba --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/UserFilter.java @@ -0,0 +1,47 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.v3.oas.annotations.media.Schema; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Filter which forms are returned + */ +public enum UserFilter { + + OWNED_BY_ME("owned_by_me"), + + SHARED_WITH_ME("shared_with_me"), + + ALL("all"); + + private String value; + + UserFilter(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static UserFilter fromValue(String value) { + for (UserFilter b : UserFilter.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } +} + diff --git a/src/main/java/com/docusign/webforms/model/WebForm.java b/src/main/java/com/docusign/webforms/model/WebForm.java new file mode 100644 index 0000000..7f484c6 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebForm.java @@ -0,0 +1,137 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.docusign.webforms.model.WebFormContent; +import com.docusign.webforms.model.WebFormMetadata; +import com.docusign.webforms.model.WebFormProperties; +import com.docusign.webforms.model.WebFormState; +import com.docusign.webforms.model.WebFormSummary; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * An object that fully describes an instance of a form. + * + */ +@Schema(description = "An object that fully describes an instance of a form") + +public class WebForm extends WebFormSummary { + @JsonProperty("versionId") + private Integer versionId = null; + + @JsonProperty("formContent") + private WebFormContent formContent = null; + + + /** + * versionId. + * + * @return WebForm + **/ + public WebForm versionId(Integer versionId) { + this.versionId = versionId; + return this; + } + + /** + * Get versionId. + * @return versionId + **/ + @Schema(description = "") + public Integer getVersionId() { + return versionId; + } + + /** + * setVersionId. + **/ + public void setVersionId(Integer versionId) { + this.versionId = versionId; + } + + + /** + * formContent. + * + * @return WebForm + **/ + public WebForm formContent(WebFormContent formContent) { + this.formContent = formContent; + return this; + } + + /** + * Get formContent. + * @return formContent + **/ + @Schema(description = "") + public WebFormContent getFormContent() { + return formContent; + } + + /** + * setFormContent. + **/ + public void setFormContent(WebFormContent formContent) { + this.formContent = formContent; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebForm webForm = (WebForm) o; + return Objects.equals(this.versionId, webForm.versionId) && + Objects.equals(this.formContent, webForm.formContent) && + super.equals(o); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(versionId, formContent, super.hashCode()); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebForm {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" versionId: ").append(toIndentedString(versionId)).append("\n"); + sb.append(" formContent: ").append(toIndentedString(formContent)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormAdmType.java b/src/main/java/com/docusign/webforms/model/WebFormAdmType.java new file mode 100644 index 0000000..4396c5f --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormAdmType.java @@ -0,0 +1,65 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.v3.oas.annotations.media.Schema; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Type used at ADM model as ComponentType decorator. \"String\", \"Boolean\", \"Double\", \"DateTime\", ArrayOfString\" are deprecated. + */ +public enum WebFormAdmType { + + STRING("String"), + + BOOLEAN("Boolean"), + + DOUBLE("Double"), + + DATETIME("DateTime"), + + ARRAYOFSTRING("ArrayOfString"), + + CHECKBOXGROUP("CheckboxGroup"), + + DATE("Date"), + + EMAIL("Email"), + + NUMBER("Number"), + + RADIOBUTTONGROUP("RadioButtonGroup"), + + SELECT("Select"), + + TEXTBOX("TextBox"); + + private String value; + + WebFormAdmType(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static WebFormAdmType fromValue(String value) { + for (WebFormAdmType b : WebFormAdmType.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormComponent.java b/src/main/java/com/docusign/webforms/model/WebFormComponent.java new file mode 100644 index 0000000..f0af062 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormComponent.java @@ -0,0 +1,164 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Each component type contains additional properties. + * + */ +@Schema(description = "Each component type contains additional properties") + +public class WebFormComponent extends java.util.HashMap { + @JsonProperty("componentKey") + private String componentKey = null; + + @JsonProperty("componentType") + private String componentType = null; + + @JsonProperty("componentName") + private String componentName = null; + + + /** + * componentKey. + * + * @return WebFormComponent + **/ + public WebFormComponent componentKey(String componentKey) { + this.componentKey = componentKey; + return this; + } + + /** + * Get componentKey. + * @return componentKey + **/ + @Schema(required = true, description = "") + public String getComponentKey() { + return componentKey; + } + + /** + * setComponentKey. + **/ + public void setComponentKey(String componentKey) { + this.componentKey = componentKey; + } + + + /** + * componentType. + * + * @return WebFormComponent + **/ + public WebFormComponent componentType(String componentType) { + this.componentType = componentType; + return this; + } + + /** + * The type of component this object represents. + * @return componentType + **/ + @Schema(example = "Checkbox", required = true, description = "The type of component this object represents") + public String getComponentType() { + return componentType; + } + + /** + * setComponentType. + **/ + public void setComponentType(String componentType) { + this.componentType = componentType; + } + + + /** + * componentName. + * + * @return WebFormComponent + **/ + public WebFormComponent componentName(String componentName) { + this.componentName = componentName; + return this; + } + + /** + * Name value that is used for mapping components to external sources. + * @return componentName + **/ + @Schema(example = "Country_Code", description = "Name value that is used for mapping components to external sources") + public String getComponentName() { + return componentName; + } + + /** + * setComponentName. + **/ + public void setComponentName(String componentName) { + this.componentName = componentName; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebFormComponent webFormComponent = (WebFormComponent) o; + return Objects.equals(this.componentKey, webFormComponent.componentKey) && + Objects.equals(this.componentType, webFormComponent.componentType) && + Objects.equals(this.componentName, webFormComponent.componentName) && + super.equals(o); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(componentKey, componentType, componentName, super.hashCode()); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormComponent {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" componentKey: ").append(toIndentedString(componentKey)).append("\n"); + sb.append(" componentType: ").append(toIndentedString(componentType)).append("\n"); + sb.append(" componentName: ").append(toIndentedString(componentName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormComponentType.java b/src/main/java/com/docusign/webforms/model/WebFormComponentType.java new file mode 100644 index 0000000..54b4084 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormComponentType.java @@ -0,0 +1,55 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.v3.oas.annotations.media.Schema; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Type of components used in the web form + */ +public enum WebFormComponentType { + + CHECKBOXGROUP("CheckboxGroup"), + + DATE("Date"), + + EMAIL("Email"), + + NUMBER("Number"), + + RADIOBUTTONGROUP("RadioButtonGroup"), + + SELECT("Select"), + + TEXTBOX("TextBox"); + + private String value; + + WebFormComponentType(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static WebFormComponentType fromValue(String value) { + for (WebFormComponentType b : WebFormComponentType.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormComponentsMap.java b/src/main/java/com/docusign/webforms/model/WebFormComponentsMap.java new file mode 100644 index 0000000..d652111 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormComponentsMap.java @@ -0,0 +1,65 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.docusign.webforms.model.WebFormComponent; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The components map for the web form. + * + */ +@Schema(description = "The components map for the web form") + +public class WebFormComponentsMap extends java.util.HashMap { + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return super.equals(o); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormComponentsMap {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormContent.java b/src/main/java/com/docusign/webforms/model/WebFormContent.java new file mode 100644 index 0000000..f63c4dd --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormContent.java @@ -0,0 +1,222 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.docusign.webforms.model.TemplateProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Container for the components map used during configuration and data collection. + * + */ +@Schema(description = "Container for the components map used during configuration and data collection") + +public class WebFormContent { + @JsonProperty("components") + private java.util.Map> components = null; + + @JsonProperty("isStandalone") + private Boolean isStandalone = null; + + @JsonProperty("brandId") + private String brandId = null; + + @JsonProperty("templates") + private java.util.List templates = null; + + + /** + * components. + * + * @return WebFormContent + **/ + public WebFormContent components(java.util.Map> components) { + this.components = components; + return this; + } + + /** + * putComponentsItem. + * + * @return WebFormContent + **/ + public WebFormContent putComponentsItem(String key, java.util.Map componentsItem) { + if (this.components == null) { + this.components = new java.util.HashMap<>(); + } + this.components.put(key, componentsItem); + return this; + } + + /** + * Key/value dictionary of components that represent the form. + * @return components + **/ + @Schema(example = "{\"Root_Of_Journey\":{\"componentKey\":\"Root_Of_Journey\",\"componentType\":\"Root\",\"children\":[\"Step_abc123\"]},\"TextBox_ABC123\":{\"componentKey\":\"TextBox_ABC123\",\"componentType\":\"TextBox\",\"componentName\":\"Full_Name\",\"label\":\"Full Name\",\"maxLength\":100,\"multiLine\":false,\"placeholder\":\"John Adams\",\"required\":true},\"Step_abc123\":{\"componentKey\":\"Step_abc123\",\"componentType\":\"Step\",\"componentName\":\"Step_abc123\",\"text\":\"Patient Demographics\"}}", description = "Key/value dictionary of components that represent the form") + public java.util.Map> getComponents() { + return components; + } + + /** + * setComponents. + **/ + public void setComponents(java.util.Map> components) { + this.components = components; + } + + + /** + * isStandalone. + * + * @return WebFormContent + **/ + public WebFormContent isStandalone(Boolean isStandalone) { + this.isStandalone = isStandalone; + return this; + } + + /** + * Get isStandalone. + * @return isStandalone + **/ + @Schema(description = "") + public Boolean getIsStandalone() { + return isStandalone; + } + + /** + * setIsStandalone. + **/ + public void setIsStandalone(Boolean isStandalone) { + this.isStandalone = isStandalone; + } + + + /** + * brandId. + * + * @return WebFormContent + **/ + public WebFormContent brandId(String brandId) { + this.brandId = brandId; + return this; + } + + /** + * Get brandId. + * @return brandId + **/ + @Schema(description = "") + public String getBrandId() { + return brandId; + } + + /** + * setBrandId. + **/ + public void setBrandId(String brandId) { + this.brandId = brandId; + } + + + /** + * templates. + * + * @return WebFormContent + **/ + public WebFormContent templates(java.util.List templates) { + this.templates = templates; + return this; + } + + /** + * addTemplatesItem. + * + * @return WebFormContent + **/ + public WebFormContent addTemplatesItem(TemplateProperties templatesItem) { + if (this.templates == null) { + this.templates = new java.util.ArrayList<>(); + } + this.templates.add(templatesItem); + return this; + } + + /** + * Optional template information that will be used to seed the form.. + * @return templates + **/ + @Schema(description = "Optional template information that will be used to seed the form.") + public java.util.List getTemplates() { + return templates; + } + + /** + * setTemplates. + **/ + public void setTemplates(java.util.List templates) { + this.templates = templates; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebFormContent webFormContent = (WebFormContent) o; + return Objects.equals(this.components, webFormContent.components) && + Objects.equals(this.isStandalone, webFormContent.isStandalone) && + Objects.equals(this.brandId, webFormContent.brandId) && + Objects.equals(this.templates, webFormContent.templates); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(components, isStandalone, brandId, templates); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormContent {\n"); + + sb.append(" components: ").append(toIndentedString(components)).append("\n"); + sb.append(" isStandalone: ").append(toIndentedString(isStandalone)).append("\n"); + sb.append(" brandId: ").append(toIndentedString(brandId)).append("\n"); + sb.append(" templates: ").append(toIndentedString(templates)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormInstance.java b/src/main/java/com/docusign/webforms/model/WebFormInstance.java new file mode 100644 index 0000000..335fc9d --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormInstance.java @@ -0,0 +1,481 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.docusign.webforms.model.InstanceStatus; +import com.docusign.webforms.model.WebFormInstanceEnvelopes; +import com.docusign.webforms.model.WebFormInstanceMetadata; +import com.docusign.webforms.model.WebFormValues; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * An object that contains the Web Form Instance required to render it and its metadata such as created by, created time. + * + */ +@Schema(description = "An object that contains the Web Form Instance required to render it and its metadata such as created by, created time") + +public class WebFormInstance { + @JsonProperty("formUrl") + private String formUrl = null; + + @JsonProperty("instanceToken") + private String instanceToken = null; + + @JsonProperty("tokenExpirationDateTime") + private String tokenExpirationDateTime = null; + + @JsonProperty("id") + private String id = null; + + @JsonProperty("formId") + private String formId = null; + + @JsonProperty("accountId") + private String accountId = null; + + @JsonProperty("clientUserId") + private String clientUserId = null; + + @JsonProperty("tags") + private java.util.List tags = null; + + @JsonProperty("status") + private InstanceStatus status = null; + + @JsonProperty("envelopes") + private java.util.List envelopes = null; + + @JsonProperty("instanceMetadata") + private WebFormInstanceMetadata instanceMetadata = null; + + @JsonProperty("formValues") + private WebFormValues formValues = null; + + + /** + * formUrl. + * + * @return WebFormInstance + **/ + public WebFormInstance formUrl(String formUrl) { + this.formUrl = formUrl; + return this; + } + + /** + * Get formUrl. + * @return formUrl + **/ + @Schema(description = "") + public String getFormUrl() { + return formUrl; + } + + /** + * setFormUrl. + **/ + public void setFormUrl(String formUrl) { + this.formUrl = formUrl; + } + + + /** + * instanceToken. + * + * @return WebFormInstance + **/ + public WebFormInstance instanceToken(String instanceToken) { + this.instanceToken = instanceToken; + return this; + } + + /** + * Get instanceToken. + * @return instanceToken + **/ + @Schema(description = "") + public String getInstanceToken() { + return instanceToken; + } + + /** + * setInstanceToken. + **/ + public void setInstanceToken(String instanceToken) { + this.instanceToken = instanceToken; + } + + + /** + * tokenExpirationDateTime. + * + * @return WebFormInstance + **/ + public WebFormInstance tokenExpirationDateTime(String tokenExpirationDateTime) { + this.tokenExpirationDateTime = tokenExpirationDateTime; + return this; + } + + /** + * Get tokenExpirationDateTime. + * @return tokenExpirationDateTime + **/ + @Schema(description = "") + public String getTokenExpirationDateTime() { + return tokenExpirationDateTime; + } + + /** + * setTokenExpirationDateTime. + **/ + public void setTokenExpirationDateTime(String tokenExpirationDateTime) { + this.tokenExpirationDateTime = tokenExpirationDateTime; + } + + + /** + * id. + * + * @return WebFormInstance + **/ + public WebFormInstance id(String id) { + this.id = id; + return this; + } + + /** + * Get id. + * @return id + **/ + @Schema(required = true, description = "") + public String getId() { + return id; + } + + /** + * setId. + **/ + public void setId(String id) { + this.id = id; + } + + + /** + * formId. + * + * @return WebFormInstance + **/ + public WebFormInstance formId(String formId) { + this.formId = formId; + return this; + } + + /** + * Web form from which the instance is created. + * @return formId + **/ + @Schema(description = "Web form from which the instance is created") + public String getFormId() { + return formId; + } + + /** + * setFormId. + **/ + public void setFormId(String formId) { + this.formId = formId; + } + + + /** + * accountId. + * + * @return WebFormInstance + **/ + public WebFormInstance accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Get accountId. + * @return accountId + **/ + @Schema(description = "") + public String getAccountId() { + return accountId; + } + + /** + * setAccountId. + **/ + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + + /** + * clientUserId. + * + * @return WebFormInstance + **/ + public WebFormInstance clientUserId(String clientUserId) { + this.clientUserId = clientUserId; + return this; + } + + /** + * Get clientUserId. + * @return clientUserId + **/ + @Schema(description = "") + public String getClientUserId() { + return clientUserId; + } + + /** + * setClientUserId. + **/ + public void setClientUserId(String clientUserId) { + this.clientUserId = clientUserId; + } + + + /** + * tags. + * + * @return WebFormInstance + **/ + public WebFormInstance tags(java.util.List tags) { + this.tags = tags; + return this; + } + + /** + * addTagsItem. + * + * @return WebFormInstance + **/ + public WebFormInstance addTagsItem(String tagsItem) { + if (this.tags == null) { + this.tags = new java.util.ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * List of tags provided by the user with each request. This field is optional.. + * @return tags + **/ + @Schema(example = "[\"loan_application\",\"finance_dept\"]", description = "List of tags provided by the user with each request. This field is optional.") + public java.util.List getTags() { + return tags; + } + + /** + * setTags. + **/ + public void setTags(java.util.List tags) { + this.tags = tags; + } + + + /** + * status. + * + * @return WebFormInstance + **/ + public WebFormInstance status(InstanceStatus status) { + this.status = status; + return this; + } + + /** + * Get status. + * @return status + **/ + @Schema(description = "") + public InstanceStatus getStatus() { + return status; + } + + /** + * setStatus. + **/ + public void setStatus(InstanceStatus status) { + this.status = status; + } + + + /** + * envelopes. + * + * @return WebFormInstance + **/ + public WebFormInstance envelopes(java.util.List envelopes) { + this.envelopes = envelopes; + return this; + } + + /** + * addEnvelopesItem. + * + * @return WebFormInstance + **/ + public WebFormInstance addEnvelopesItem(WebFormInstanceEnvelopes envelopesItem) { + if (this.envelopes == null) { + this.envelopes = new java.util.ArrayList<>(); + } + this.envelopes.add(envelopesItem); + return this; + } + + /** + * The associated envelope that is created when the instance is submitted. + * @return envelopes + **/ + @Schema(description = "The associated envelope that is created when the instance is submitted") + public java.util.List getEnvelopes() { + return envelopes; + } + + /** + * setEnvelopes. + **/ + public void setEnvelopes(java.util.List envelopes) { + this.envelopes = envelopes; + } + + + /** + * instanceMetadata. + * + * @return WebFormInstance + **/ + public WebFormInstance instanceMetadata(WebFormInstanceMetadata instanceMetadata) { + this.instanceMetadata = instanceMetadata; + return this; + } + + /** + * Get instanceMetadata. + * @return instanceMetadata + **/ + @Schema(description = "") + public WebFormInstanceMetadata getInstanceMetadata() { + return instanceMetadata; + } + + /** + * setInstanceMetadata. + **/ + public void setInstanceMetadata(WebFormInstanceMetadata instanceMetadata) { + this.instanceMetadata = instanceMetadata; + } + + + /** + * formValues. + * + * @return WebFormInstance + **/ + public WebFormInstance formValues(WebFormValues formValues) { + this.formValues = formValues; + return this; + } + + /** + * Get formValues. + * @return formValues + **/ + @Schema(description = "") + public WebFormValues getFormValues() { + return formValues; + } + + /** + * setFormValues. + **/ + public void setFormValues(WebFormValues formValues) { + this.formValues = formValues; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebFormInstance webFormInstance = (WebFormInstance) o; + return Objects.equals(this.formUrl, webFormInstance.formUrl) && + Objects.equals(this.instanceToken, webFormInstance.instanceToken) && + Objects.equals(this.tokenExpirationDateTime, webFormInstance.tokenExpirationDateTime) && + Objects.equals(this.id, webFormInstance.id) && + Objects.equals(this.formId, webFormInstance.formId) && + Objects.equals(this.accountId, webFormInstance.accountId) && + Objects.equals(this.clientUserId, webFormInstance.clientUserId) && + Objects.equals(this.tags, webFormInstance.tags) && + Objects.equals(this.status, webFormInstance.status) && + Objects.equals(this.envelopes, webFormInstance.envelopes) && + Objects.equals(this.instanceMetadata, webFormInstance.instanceMetadata) && + Objects.equals(this.formValues, webFormInstance.formValues); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(formUrl, instanceToken, tokenExpirationDateTime, id, formId, accountId, clientUserId, tags, status, envelopes, instanceMetadata, formValues); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormInstance {\n"); + + sb.append(" formUrl: ").append(toIndentedString(formUrl)).append("\n"); + sb.append(" instanceToken: ").append(toIndentedString(instanceToken)).append("\n"); + sb.append(" tokenExpirationDateTime: ").append(toIndentedString(tokenExpirationDateTime)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" formId: ").append(toIndentedString(formId)).append("\n"); + sb.append(" accountId: ").append(toIndentedString(accountId)).append("\n"); + sb.append(" clientUserId: ").append(toIndentedString(clientUserId)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" envelopes: ").append(toIndentedString(envelopes)).append("\n"); + sb.append(" instanceMetadata: ").append(toIndentedString(instanceMetadata)).append("\n"); + sb.append(" formValues: ").append(toIndentedString(formValues)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormInstanceEnvelopes.java b/src/main/java/com/docusign/webforms/model/WebFormInstanceEnvelopes.java new file mode 100644 index 0000000..4c2b201 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormInstanceEnvelopes.java @@ -0,0 +1,98 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * WebFormInstanceEnvelopes. + * + */ + +public class WebFormInstanceEnvelopes { + @JsonProperty("id") + private String id = null; + + + /** + * id. + * + * @return WebFormInstanceEnvelopes + **/ + public WebFormInstanceEnvelopes id(String id) { + this.id = id; + return this; + } + + /** + * Get id. + * @return id + **/ + @Schema(description = "") + public String getId() { + return id; + } + + /** + * setId. + **/ + public void setId(String id) { + this.id = id; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebFormInstanceEnvelopes webFormInstanceEnvelopes = (WebFormInstanceEnvelopes) o; + return Objects.equals(this.id, webFormInstanceEnvelopes.id); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(id); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormInstanceEnvelopes {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormInstanceList.java b/src/main/java/com/docusign/webforms/model/WebFormInstanceList.java new file mode 100644 index 0000000..ffde0dd --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormInstanceList.java @@ -0,0 +1,113 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.docusign.webforms.model.WebFormInstance; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * A list of web form instance items.. + * + */ +@Schema(description = "A list of web form instance items.") + +public class WebFormInstanceList { + @JsonProperty("items") + private java.util.List items = null; + + + /** + * items. + * + * @return WebFormInstanceList + **/ + public WebFormInstanceList items(java.util.List items) { + this.items = items; + return this; + } + + /** + * addItemsItem. + * + * @return WebFormInstanceList + **/ + public WebFormInstanceList addItemsItem(WebFormInstance itemsItem) { + if (this.items == null) { + this.items = new java.util.ArrayList<>(); + } + this.items.add(itemsItem); + return this; + } + + /** + * Array of web form instance items.. + * @return items + **/ + @Schema(description = "Array of web form instance items.") + public java.util.List getItems() { + return items; + } + + /** + * setItems. + **/ + public void setItems(java.util.List items) { + this.items = items; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebFormInstanceList webFormInstanceList = (WebFormInstanceList) o; + return Objects.equals(this.items, webFormInstanceList.items); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(items); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormInstanceList {\n"); + + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormInstanceMetadata.java b/src/main/java/com/docusign/webforms/model/WebFormInstanceMetadata.java new file mode 100644 index 0000000..8453747 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormInstanceMetadata.java @@ -0,0 +1,228 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.docusign.webforms.model.WebFormUserInfo; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Web Form Instance metadata containing information like created by, created time, etc.. + * + */ +@Schema(description = "Web Form Instance metadata containing information like created by, created time, etc.") + +public class WebFormInstanceMetadata { + @JsonProperty("expirationDateTime") + private String expirationDateTime = null; + + @JsonProperty("createdDateTime") + private String createdDateTime = null; + + @JsonProperty("createdBy") + private WebFormUserInfo createdBy = null; + + @JsonProperty("lastModifiedDateTime") + private String lastModifiedDateTime = null; + + @JsonProperty("lastModifiedBy") + private WebFormUserInfo lastModifiedBy = null; + + + /** + * expirationDateTime. + * + * @return WebFormInstanceMetadata + **/ + public WebFormInstanceMetadata expirationDateTime(String expirationDateTime) { + this.expirationDateTime = expirationDateTime; + return this; + } + + /** + * Get expirationDateTime. + * @return expirationDateTime + **/ + @Schema(required = true, description = "") + public String getExpirationDateTime() { + return expirationDateTime; + } + + /** + * setExpirationDateTime. + **/ + public void setExpirationDateTime(String expirationDateTime) { + this.expirationDateTime = expirationDateTime; + } + + + /** + * createdDateTime. + * + * @return WebFormInstanceMetadata + **/ + public WebFormInstanceMetadata createdDateTime(String createdDateTime) { + this.createdDateTime = createdDateTime; + return this; + } + + /** + * Get createdDateTime. + * @return createdDateTime + **/ + @Schema(required = true, description = "") + public String getCreatedDateTime() { + return createdDateTime; + } + + /** + * setCreatedDateTime. + **/ + public void setCreatedDateTime(String createdDateTime) { + this.createdDateTime = createdDateTime; + } + + + /** + * createdBy. + * + * @return WebFormInstanceMetadata + **/ + public WebFormInstanceMetadata createdBy(WebFormUserInfo createdBy) { + this.createdBy = createdBy; + return this; + } + + /** + * The user that created the Web Form Instance. + * @return createdBy + **/ + @Schema(required = true, description = "The user that created the Web Form Instance") + public WebFormUserInfo getCreatedBy() { + return createdBy; + } + + /** + * setCreatedBy. + **/ + public void setCreatedBy(WebFormUserInfo createdBy) { + this.createdBy = createdBy; + } + + + /** + * lastModifiedDateTime. + * + * @return WebFormInstanceMetadata + **/ + public WebFormInstanceMetadata lastModifiedDateTime(String lastModifiedDateTime) { + this.lastModifiedDateTime = lastModifiedDateTime; + return this; + } + + /** + * Get lastModifiedDateTime. + * @return lastModifiedDateTime + **/ + @Schema(description = "") + public String getLastModifiedDateTime() { + return lastModifiedDateTime; + } + + /** + * setLastModifiedDateTime. + **/ + public void setLastModifiedDateTime(String lastModifiedDateTime) { + this.lastModifiedDateTime = lastModifiedDateTime; + } + + + /** + * lastModifiedBy. + * + * @return WebFormInstanceMetadata + **/ + public WebFormInstanceMetadata lastModifiedBy(WebFormUserInfo lastModifiedBy) { + this.lastModifiedBy = lastModifiedBy; + return this; + } + + /** + * The user that last modified the Web Form Instance. + * @return lastModifiedBy + **/ + @Schema(description = "The user that last modified the Web Form Instance") + public WebFormUserInfo getLastModifiedBy() { + return lastModifiedBy; + } + + /** + * setLastModifiedBy. + **/ + public void setLastModifiedBy(WebFormUserInfo lastModifiedBy) { + this.lastModifiedBy = lastModifiedBy; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebFormInstanceMetadata webFormInstanceMetadata = (WebFormInstanceMetadata) o; + return Objects.equals(this.expirationDateTime, webFormInstanceMetadata.expirationDateTime) && + Objects.equals(this.createdDateTime, webFormInstanceMetadata.createdDateTime) && + Objects.equals(this.createdBy, webFormInstanceMetadata.createdBy) && + Objects.equals(this.lastModifiedDateTime, webFormInstanceMetadata.lastModifiedDateTime) && + Objects.equals(this.lastModifiedBy, webFormInstanceMetadata.lastModifiedBy); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(expirationDateTime, createdDateTime, createdBy, lastModifiedDateTime, lastModifiedBy); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormInstanceMetadata {\n"); + + sb.append(" expirationDateTime: ").append(toIndentedString(expirationDateTime)).append("\n"); + sb.append(" createdDateTime: ").append(toIndentedString(createdDateTime)).append("\n"); + sb.append(" createdBy: ").append(toIndentedString(createdBy)).append("\n"); + sb.append(" lastModifiedDateTime: ").append(toIndentedString(lastModifiedDateTime)).append("\n"); + sb.append(" lastModifiedBy: ").append(toIndentedString(lastModifiedBy)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormMetadata.java b/src/main/java/com/docusign/webforms/model/WebFormMetadata.java new file mode 100644 index 0000000..b530ab0 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormMetadata.java @@ -0,0 +1,724 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.docusign.webforms.model.WebFormComponentType; +import com.docusign.webforms.model.WebFormSource; +import com.docusign.webforms.model.WebFormUserInfo; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import java.time.OffsetDateTime; + +/** + * Form metadata. + * + */ +@Schema(description = "Form metadata") + +public class WebFormMetadata { + @JsonProperty("source") + private WebFormSource source = null; + + @JsonProperty("owner") + private WebFormUserInfo owner = null; + + @JsonProperty("sender") + private WebFormUserInfo sender = null; + + @JsonProperty("lastModifiedBy") + private WebFormUserInfo lastModifiedBy = null; + + @JsonProperty("formContentModifiedBy") + private WebFormUserInfo formContentModifiedBy = null; + + @JsonProperty("formPropertiesModifiedBy") + private WebFormUserInfo formPropertiesModifiedBy = null; + + @JsonProperty("lastPublishedBy") + private WebFormUserInfo lastPublishedBy = null; + + @JsonProperty("lastEnabledBy") + private WebFormUserInfo lastEnabledBy = null; + + @JsonProperty("lastDisabledBy") + private WebFormUserInfo lastDisabledBy = null; + + @JsonProperty("archivedDateTime") + private String archivedDateTime = null; + + @JsonProperty("createdDateTime") + private String createdDateTime = null; + + @JsonProperty("lastModifiedDateTime") + private String lastModifiedDateTime = null; + + @JsonProperty("formContentModifiedDateTime") + private String formContentModifiedDateTime = null; + + @JsonProperty("formPropertiesModifiedDateTime") + private String formPropertiesModifiedDateTime = null; + + @JsonProperty("lastPublishedDateTime") + private String lastPublishedDateTime = null; + + @JsonProperty("lastEnabledDateTime") + private String lastEnabledDateTime = null; + + @JsonProperty("lastDisabledDateTime") + private String lastDisabledDateTime = null; + + @JsonProperty("lastSenderConsentDateTime") + private String lastSenderConsentDateTime = null; + + @JsonProperty("publishedSlug") + private String publishedSlug = null; + + @JsonProperty("publishedComponentNames") + private java.util.Map publishedComponentNames = null; + + + /** + * source. + * + * @return WebFormMetadata + **/ + public WebFormMetadata source(WebFormSource source) { + this.source = source; + return this; + } + + /** + * The source from which the webform is created. Accepted values are [upload, templates, blank]. + * @return source + **/ + @Schema(description = "The source from which the webform is created. Accepted values are [upload, templates, blank]") + public WebFormSource getSource() { + return source; + } + + /** + * setSource. + **/ + public void setSource(WebFormSource source) { + this.source = source; + } + + + /** + * owner. + * + * @return WebFormMetadata + **/ + public WebFormMetadata owner(WebFormUserInfo owner) { + this.owner = owner; + return this; + } + + /** + * The user that created the form or has been transferred ownership. + * @return owner + **/ + @Schema(description = "The user that created the form or has been transferred ownership") + public WebFormUserInfo getOwner() { + return owner; + } + + /** + * setOwner. + **/ + public void setOwner(WebFormUserInfo owner) { + this.owner = owner; + } + + + /** + * sender. + * + * @return WebFormMetadata + **/ + public WebFormMetadata sender(WebFormUserInfo sender) { + this.sender = sender; + return this; + } + + /** + * The user that has added their consent to the form for sending actions. + * @return sender + **/ + @Schema(description = "The user that has added their consent to the form for sending actions") + public WebFormUserInfo getSender() { + return sender; + } + + /** + * setSender. + **/ + public void setSender(WebFormUserInfo sender) { + this.sender = sender; + } + + + /** + * lastModifiedBy. + * + * @return WebFormMetadata + **/ + public WebFormMetadata lastModifiedBy(WebFormUserInfo lastModifiedBy) { + this.lastModifiedBy = lastModifiedBy; + return this; + } + + /** + * Track the user that last modified anything related to the form. + * @return lastModifiedBy + **/ + @Schema(description = "Track the user that last modified anything related to the form") + public WebFormUserInfo getLastModifiedBy() { + return lastModifiedBy; + } + + /** + * setLastModifiedBy. + **/ + public void setLastModifiedBy(WebFormUserInfo lastModifiedBy) { + this.lastModifiedBy = lastModifiedBy; + } + + + /** + * formContentModifiedBy. + * + * @return WebFormMetadata + **/ + public WebFormMetadata formContentModifiedBy(WebFormUserInfo formContentModifiedBy) { + this.formContentModifiedBy = formContentModifiedBy; + return this; + } + + /** + * Track the user that last modified the form content. + * @return formContentModifiedBy + **/ + @Schema(description = "Track the user that last modified the form content") + public WebFormUserInfo getFormContentModifiedBy() { + return formContentModifiedBy; + } + + /** + * setFormContentModifiedBy. + **/ + public void setFormContentModifiedBy(WebFormUserInfo formContentModifiedBy) { + this.formContentModifiedBy = formContentModifiedBy; + } + + + /** + * formPropertiesModifiedBy. + * + * @return WebFormMetadata + **/ + public WebFormMetadata formPropertiesModifiedBy(WebFormUserInfo formPropertiesModifiedBy) { + this.formPropertiesModifiedBy = formPropertiesModifiedBy; + return this; + } + + /** + * Track the user that last modified the form properties. + * @return formPropertiesModifiedBy + **/ + @Schema(description = "Track the user that last modified the form properties") + public WebFormUserInfo getFormPropertiesModifiedBy() { + return formPropertiesModifiedBy; + } + + /** + * setFormPropertiesModifiedBy. + **/ + public void setFormPropertiesModifiedBy(WebFormUserInfo formPropertiesModifiedBy) { + this.formPropertiesModifiedBy = formPropertiesModifiedBy; + } + + + /** + * lastPublishedBy. + * + * @return WebFormMetadata + **/ + public WebFormMetadata lastPublishedBy(WebFormUserInfo lastPublishedBy) { + this.lastPublishedBy = lastPublishedBy; + return this; + } + + /** + * Track the user that last published a draft version to active. + * @return lastPublishedBy + **/ + @Schema(description = "Track the user that last published a draft version to active") + public WebFormUserInfo getLastPublishedBy() { + return lastPublishedBy; + } + + /** + * setLastPublishedBy. + **/ + public void setLastPublishedBy(WebFormUserInfo lastPublishedBy) { + this.lastPublishedBy = lastPublishedBy; + } + + + /** + * lastEnabledBy. + * + * @return WebFormMetadata + **/ + public WebFormMetadata lastEnabledBy(WebFormUserInfo lastEnabledBy) { + this.lastEnabledBy = lastEnabledBy; + return this; + } + + /** + * Track the user that last unpublished an active version. + * @return lastEnabledBy + **/ + @Schema(description = "Track the user that last unpublished an active version") + public WebFormUserInfo getLastEnabledBy() { + return lastEnabledBy; + } + + /** + * setLastEnabledBy. + **/ + public void setLastEnabledBy(WebFormUserInfo lastEnabledBy) { + this.lastEnabledBy = lastEnabledBy; + } + + + /** + * lastDisabledBy. + * + * @return WebFormMetadata + **/ + public WebFormMetadata lastDisabledBy(WebFormUserInfo lastDisabledBy) { + this.lastDisabledBy = lastDisabledBy; + return this; + } + + /** + * Track the user that last unpublished an active version. + * @return lastDisabledBy + **/ + @Schema(description = "Track the user that last unpublished an active version") + public WebFormUserInfo getLastDisabledBy() { + return lastDisabledBy; + } + + /** + * setLastDisabledBy. + **/ + public void setLastDisabledBy(WebFormUserInfo lastDisabledBy) { + this.lastDisabledBy = lastDisabledBy; + } + + + /** + * archivedDateTime. + * + * @return WebFormMetadata + **/ + public WebFormMetadata archivedDateTime(String archivedDateTime) { + this.archivedDateTime = archivedDateTime; + return this; + } + + /** + * The last time the web form was archived. + * @return archivedDateTime + **/ + @Schema(description = "The last time the web form was archived") + public String getArchivedDateTime() { + return archivedDateTime; + } + + /** + * setArchivedDateTime. + **/ + public void setArchivedDateTime(String archivedDateTime) { + this.archivedDateTime = archivedDateTime; + } + + + /** + * createdDateTime. + * + * @return WebFormMetadata + **/ + public WebFormMetadata createdDateTime(String createdDateTime) { + this.createdDateTime = createdDateTime; + return this; + } + + /** + * Track the time the web form was created. + * @return createdDateTime + **/ + @Schema(description = "Track the time the web form was created") + public String getCreatedDateTime() { + return createdDateTime; + } + + /** + * setCreatedDateTime. + **/ + public void setCreatedDateTime(String createdDateTime) { + this.createdDateTime = createdDateTime; + } + + + /** + * lastModifiedDateTime. + * + * @return WebFormMetadata + **/ + public WebFormMetadata lastModifiedDateTime(String lastModifiedDateTime) { + this.lastModifiedDateTime = lastModifiedDateTime; + return this; + } + + /** + * The last time anything was modified on the form. + * @return lastModifiedDateTime + **/ + @Schema(description = "The last time anything was modified on the form") + public String getLastModifiedDateTime() { + return lastModifiedDateTime; + } + + /** + * setLastModifiedDateTime. + **/ + public void setLastModifiedDateTime(String lastModifiedDateTime) { + this.lastModifiedDateTime = lastModifiedDateTime; + } + + + /** + * formContentModifiedDateTime. + * + * @return WebFormMetadata + **/ + public WebFormMetadata formContentModifiedDateTime(String formContentModifiedDateTime) { + this.formContentModifiedDateTime = formContentModifiedDateTime; + return this; + } + + /** + * Track the last time web form content changed.. + * @return formContentModifiedDateTime + **/ + @Schema(description = "Track the last time web form content changed.") + public String getFormContentModifiedDateTime() { + return formContentModifiedDateTime; + } + + /** + * setFormContentModifiedDateTime. + **/ + public void setFormContentModifiedDateTime(String formContentModifiedDateTime) { + this.formContentModifiedDateTime = formContentModifiedDateTime; + } + + + /** + * formPropertiesModifiedDateTime. + * + * @return WebFormMetadata + **/ + public WebFormMetadata formPropertiesModifiedDateTime(String formPropertiesModifiedDateTime) { + this.formPropertiesModifiedDateTime = formPropertiesModifiedDateTime; + return this; + } + + /** + * Track the last time the form properties changed.. + * @return formPropertiesModifiedDateTime + **/ + @Schema(description = "Track the last time the form properties changed.") + public String getFormPropertiesModifiedDateTime() { + return formPropertiesModifiedDateTime; + } + + /** + * setFormPropertiesModifiedDateTime. + **/ + public void setFormPropertiesModifiedDateTime(String formPropertiesModifiedDateTime) { + this.formPropertiesModifiedDateTime = formPropertiesModifiedDateTime; + } + + + /** + * lastPublishedDateTime. + * + * @return WebFormMetadata + **/ + public WebFormMetadata lastPublishedDateTime(String lastPublishedDateTime) { + this.lastPublishedDateTime = lastPublishedDateTime; + return this; + } + + /** + * Track the last time a draft version was published to active. + * @return lastPublishedDateTime + **/ + @Schema(description = "Track the last time a draft version was published to active") + public String getLastPublishedDateTime() { + return lastPublishedDateTime; + } + + /** + * setLastPublishedDateTime. + **/ + public void setLastPublishedDateTime(String lastPublishedDateTime) { + this.lastPublishedDateTime = lastPublishedDateTime; + } + + + /** + * lastEnabledDateTime. + * + * @return WebFormMetadata + **/ + public WebFormMetadata lastEnabledDateTime(String lastEnabledDateTime) { + this.lastEnabledDateTime = lastEnabledDateTime; + return this; + } + + /** + * Track the last time the form was enabled. + * @return lastEnabledDateTime + **/ + @Schema(description = "Track the last time the form was enabled") + public String getLastEnabledDateTime() { + return lastEnabledDateTime; + } + + /** + * setLastEnabledDateTime. + **/ + public void setLastEnabledDateTime(String lastEnabledDateTime) { + this.lastEnabledDateTime = lastEnabledDateTime; + } + + + /** + * lastDisabledDateTime. + * + * @return WebFormMetadata + **/ + public WebFormMetadata lastDisabledDateTime(String lastDisabledDateTime) { + this.lastDisabledDateTime = lastDisabledDateTime; + return this; + } + + /** + * Track the last time the form was disabled. + * @return lastDisabledDateTime + **/ + @Schema(description = "Track the last time the form was disabled") + public String getLastDisabledDateTime() { + return lastDisabledDateTime; + } + + /** + * setLastDisabledDateTime. + **/ + public void setLastDisabledDateTime(String lastDisabledDateTime) { + this.lastDisabledDateTime = lastDisabledDateTime; + } + + + /** + * lastSenderConsentDateTime. + * + * @return WebFormMetadata + **/ + public WebFormMetadata lastSenderConsentDateTime(String lastSenderConsentDateTime) { + this.lastSenderConsentDateTime = lastSenderConsentDateTime; + return this; + } + + /** + * Track the last time a user added their consent for the form.. + * @return lastSenderConsentDateTime + **/ + @Schema(description = "Track the last time a user added their consent for the form.") + public String getLastSenderConsentDateTime() { + return lastSenderConsentDateTime; + } + + /** + * setLastSenderConsentDateTime. + **/ + public void setLastSenderConsentDateTime(String lastSenderConsentDateTime) { + this.lastSenderConsentDateTime = lastSenderConsentDateTime; + } + + + /** + * publishedSlug. + * + * @return WebFormMetadata + **/ + public WebFormMetadata publishedSlug(String publishedSlug) { + this.publishedSlug = publishedSlug; + return this; + } + + /** + * The public friendly slug that is used to access the form from the player. + * @return publishedSlug + **/ + @Schema(example = "BFS6Zw9QxKnerieBsgRyif", description = "The public friendly slug that is used to access the form from the player") + public String getPublishedSlug() { + return publishedSlug; + } + + /** + * setPublishedSlug. + **/ + public void setPublishedSlug(String publishedSlug) { + this.publishedSlug = publishedSlug; + } + + + /** + * publishedComponentNames. + * + * @return WebFormMetadata + **/ + public WebFormMetadata publishedComponentNames(java.util.Map publishedComponentNames) { + this.publishedComponentNames = publishedComponentNames; + return this; + } + + /** + * putPublishedComponentNamesItem. + * + * @return WebFormMetadata + **/ + public WebFormMetadata putPublishedComponentNamesItem(String key, WebFormComponentType publishedComponentNamesItem) { + if (this.publishedComponentNames == null) { + this.publishedComponentNames = new java.util.HashMap<>(); + } + this.publishedComponentNames.put(key, publishedComponentNamesItem); + return this; + } + + /** + * A dictionary containing the mapping of component names to their respective component types for all the published components.. + * @return publishedComponentNames + **/ + @Schema(description = "A dictionary containing the mapping of component names to their respective component types for all the published components.") + public java.util.Map getPublishedComponentNames() { + return publishedComponentNames; + } + + /** + * setPublishedComponentNames. + **/ + public void setPublishedComponentNames(java.util.Map publishedComponentNames) { + this.publishedComponentNames = publishedComponentNames; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebFormMetadata webFormMetadata = (WebFormMetadata) o; + return Objects.equals(this.source, webFormMetadata.source) && + Objects.equals(this.owner, webFormMetadata.owner) && + Objects.equals(this.sender, webFormMetadata.sender) && + Objects.equals(this.lastModifiedBy, webFormMetadata.lastModifiedBy) && + Objects.equals(this.formContentModifiedBy, webFormMetadata.formContentModifiedBy) && + Objects.equals(this.formPropertiesModifiedBy, webFormMetadata.formPropertiesModifiedBy) && + Objects.equals(this.lastPublishedBy, webFormMetadata.lastPublishedBy) && + Objects.equals(this.lastEnabledBy, webFormMetadata.lastEnabledBy) && + Objects.equals(this.lastDisabledBy, webFormMetadata.lastDisabledBy) && + Objects.equals(this.archivedDateTime, webFormMetadata.archivedDateTime) && + Objects.equals(this.createdDateTime, webFormMetadata.createdDateTime) && + Objects.equals(this.lastModifiedDateTime, webFormMetadata.lastModifiedDateTime) && + Objects.equals(this.formContentModifiedDateTime, webFormMetadata.formContentModifiedDateTime) && + Objects.equals(this.formPropertiesModifiedDateTime, webFormMetadata.formPropertiesModifiedDateTime) && + Objects.equals(this.lastPublishedDateTime, webFormMetadata.lastPublishedDateTime) && + Objects.equals(this.lastEnabledDateTime, webFormMetadata.lastEnabledDateTime) && + Objects.equals(this.lastDisabledDateTime, webFormMetadata.lastDisabledDateTime) && + Objects.equals(this.lastSenderConsentDateTime, webFormMetadata.lastSenderConsentDateTime) && + Objects.equals(this.publishedSlug, webFormMetadata.publishedSlug) && + Objects.equals(this.publishedComponentNames, webFormMetadata.publishedComponentNames); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(source, owner, sender, lastModifiedBy, formContentModifiedBy, formPropertiesModifiedBy, lastPublishedBy, lastEnabledBy, lastDisabledBy, archivedDateTime, createdDateTime, lastModifiedDateTime, formContentModifiedDateTime, formPropertiesModifiedDateTime, lastPublishedDateTime, lastEnabledDateTime, lastDisabledDateTime, lastSenderConsentDateTime, publishedSlug, publishedComponentNames); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormMetadata {\n"); + + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); + sb.append(" sender: ").append(toIndentedString(sender)).append("\n"); + sb.append(" lastModifiedBy: ").append(toIndentedString(lastModifiedBy)).append("\n"); + sb.append(" formContentModifiedBy: ").append(toIndentedString(formContentModifiedBy)).append("\n"); + sb.append(" formPropertiesModifiedBy: ").append(toIndentedString(formPropertiesModifiedBy)).append("\n"); + sb.append(" lastPublishedBy: ").append(toIndentedString(lastPublishedBy)).append("\n"); + sb.append(" lastEnabledBy: ").append(toIndentedString(lastEnabledBy)).append("\n"); + sb.append(" lastDisabledBy: ").append(toIndentedString(lastDisabledBy)).append("\n"); + sb.append(" archivedDateTime: ").append(toIndentedString(archivedDateTime)).append("\n"); + sb.append(" createdDateTime: ").append(toIndentedString(createdDateTime)).append("\n"); + sb.append(" lastModifiedDateTime: ").append(toIndentedString(lastModifiedDateTime)).append("\n"); + sb.append(" formContentModifiedDateTime: ").append(toIndentedString(formContentModifiedDateTime)).append("\n"); + sb.append(" formPropertiesModifiedDateTime: ").append(toIndentedString(formPropertiesModifiedDateTime)).append("\n"); + sb.append(" lastPublishedDateTime: ").append(toIndentedString(lastPublishedDateTime)).append("\n"); + sb.append(" lastEnabledDateTime: ").append(toIndentedString(lastEnabledDateTime)).append("\n"); + sb.append(" lastDisabledDateTime: ").append(toIndentedString(lastDisabledDateTime)).append("\n"); + sb.append(" lastSenderConsentDateTime: ").append(toIndentedString(lastSenderConsentDateTime)).append("\n"); + sb.append(" publishedSlug: ").append(toIndentedString(publishedSlug)).append("\n"); + sb.append(" publishedComponentNames: ").append(toIndentedString(publishedComponentNames)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormProperties.java b/src/main/java/com/docusign/webforms/model/WebFormProperties.java new file mode 100644 index 0000000..a5b95ed --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormProperties.java @@ -0,0 +1,131 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * General information about the web form that is consistent across versions. + * + */ +@Schema(description = "General information about the web form that is consistent across versions") + +public class WebFormProperties { + @JsonProperty("name") + private String name = null; + + @JsonProperty("isPrivateAccess") + private Boolean isPrivateAccess = null; + + + /** + * name. + * + * @return WebFormProperties + **/ + public WebFormProperties name(String name) { + this.name = name; + return this; + } + + /** + * Get name. + * @return name + **/ + @Schema(description = "") + public String getName() { + return name; + } + + /** + * setName. + **/ + public void setName(String name) { + this.name = name; + } + + + /** + * isPrivateAccess. + * + * @return WebFormProperties + **/ + public WebFormProperties isPrivateAccess(Boolean isPrivateAccess) { + this.isPrivateAccess = isPrivateAccess; + return this; + } + + /** + * Get isPrivateAccess. + * @return isPrivateAccess + **/ + @Schema(description = "") + public Boolean getIsPrivateAccess() { + return isPrivateAccess; + } + + /** + * setIsPrivateAccess. + **/ + public void setIsPrivateAccess(Boolean isPrivateAccess) { + this.isPrivateAccess = isPrivateAccess; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebFormProperties webFormProperties = (WebFormProperties) o; + return Objects.equals(this.name, webFormProperties.name) && + Objects.equals(this.isPrivateAccess, webFormProperties.isPrivateAccess); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(name, isPrivateAccess); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormProperties {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" isPrivateAccess: ").append(toIndentedString(isPrivateAccess)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormPublishedNames.java b/src/main/java/com/docusign/webforms/model/WebFormPublishedNames.java new file mode 100644 index 0000000..949245a --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormPublishedNames.java @@ -0,0 +1,64 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * A collection of the published component name and its corresponding type. + * + */ +@Schema(description = "A collection of the published component name and its corresponding type") + +public class WebFormPublishedNames extends java.util.HashMap { + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return super.equals(o); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormPublishedNames {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormSource.java b/src/main/java/com/docusign/webforms/model/WebFormSource.java new file mode 100644 index 0000000..b1dc0b3 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormSource.java @@ -0,0 +1,45 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.v3.oas.annotations.media.Schema; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * The source from which the web form is created. + */ +public enum WebFormSource { + + TEMPLATES("templates"), + + BLANK("blank"); + + private String value; + + WebFormSource(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static WebFormSource fromValue(String value) { + for (WebFormSource b : WebFormSource.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormState.java b/src/main/java/com/docusign/webforms/model/WebFormState.java new file mode 100644 index 0000000..9554739 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormState.java @@ -0,0 +1,45 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.v3.oas.annotations.media.Schema; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * The state of the form content + */ +public enum WebFormState { + + ACTIVE("active"), + + DRAFT("draft"); + + private String value; + + WebFormState(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static WebFormState fromValue(String value) { + for (WebFormState b : WebFormState.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormSummary.java b/src/main/java/com/docusign/webforms/model/WebFormSummary.java new file mode 100644 index 0000000..fa06996 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormSummary.java @@ -0,0 +1,326 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.docusign.webforms.model.WebFormMetadata; +import com.docusign.webforms.model.WebFormProperties; +import com.docusign.webforms.model.WebFormState; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * An object that summarizes an instance of a form that can be used to display a listing. + * + */ +@Schema(description = "An object that summarizes an instance of a form that can be used to display a listing") + +public class WebFormSummary { + @JsonProperty("id") + private String id = null; + + @JsonProperty("accountId") + private String accountId = null; + + @JsonProperty("isPublished") + private Boolean isPublished = null; + + @JsonProperty("isEnabled") + private Boolean isEnabled = null; + + @JsonProperty("hasDraftChanges") + private Boolean hasDraftChanges = null; + + @JsonProperty("formState") + private WebFormState formState = null; + + @JsonProperty("formProperties") + private WebFormProperties formProperties = null; + + @JsonProperty("formMetadata") + private WebFormMetadata formMetadata = null; + + + /** + * id. + * + * @return WebFormSummary + **/ + public WebFormSummary id(String id) { + this.id = id; + return this; + } + + /** + * Get id. + * @return id + **/ + @Schema(description = "") + public String getId() { + return id; + } + + /** + * setId. + **/ + public void setId(String id) { + this.id = id; + } + + + /** + * accountId. + * + * @return WebFormSummary + **/ + public WebFormSummary accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Get accountId. + * @return accountId + **/ + @Schema(description = "") + public String getAccountId() { + return accountId; + } + + /** + * setAccountId. + **/ + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + + /** + * isPublished. + * + * @return WebFormSummary + **/ + public WebFormSummary isPublished(Boolean isPublished) { + this.isPublished = isPublished; + return this; + } + + /** + * Has the form been published. + * @return isPublished + **/ + @Schema(example = "true", description = "Has the form been published") + public Boolean isIsPublished() { + return isPublished; + } + + /** + * setIsPublished. + **/ + public void setIsPublished(Boolean isPublished) { + this.isPublished = isPublished; + } + + + /** + * isEnabled. + * + * @return WebFormSummary + **/ + public WebFormSummary isEnabled(Boolean isEnabled) { + this.isEnabled = isEnabled; + return this; + } + + /** + * Is the form currently enabled and available for data collection. + * @return isEnabled + **/ + @Schema(example = "true", description = "Is the form currently enabled and available for data collection") + public Boolean isIsEnabled() { + return isEnabled; + } + + /** + * setIsEnabled. + **/ + public void setIsEnabled(Boolean isEnabled) { + this.isEnabled = isEnabled; + } + + + /** + * hasDraftChanges. + * + * @return WebFormSummary + **/ + public WebFormSummary hasDraftChanges(Boolean hasDraftChanges) { + this.hasDraftChanges = hasDraftChanges; + return this; + } + + /** + * Does the form have draft changes that need to be published?. + * @return hasDraftChanges + **/ + @Schema(example = "true", description = "Does the form have draft changes that need to be published?") + public Boolean isHasDraftChanges() { + return hasDraftChanges; + } + + /** + * setHasDraftChanges. + **/ + public void setHasDraftChanges(Boolean hasDraftChanges) { + this.hasDraftChanges = hasDraftChanges; + } + + + /** + * formState. + * + * @return WebFormSummary + **/ + public WebFormSummary formState(WebFormState formState) { + this.formState = formState; + return this; + } + + /** + * Get formState. + * @return formState + **/ + @Schema(description = "") + public WebFormState getFormState() { + return formState; + } + + /** + * setFormState. + **/ + public void setFormState(WebFormState formState) { + this.formState = formState; + } + + + /** + * formProperties. + * + * @return WebFormSummary + **/ + public WebFormSummary formProperties(WebFormProperties formProperties) { + this.formProperties = formProperties; + return this; + } + + /** + * Get formProperties. + * @return formProperties + **/ + @Schema(description = "") + public WebFormProperties getFormProperties() { + return formProperties; + } + + /** + * setFormProperties. + **/ + public void setFormProperties(WebFormProperties formProperties) { + this.formProperties = formProperties; + } + + + /** + * formMetadata. + * + * @return WebFormSummary + **/ + public WebFormSummary formMetadata(WebFormMetadata formMetadata) { + this.formMetadata = formMetadata; + return this; + } + + /** + * Get formMetadata. + * @return formMetadata + **/ + @Schema(description = "") + public WebFormMetadata getFormMetadata() { + return formMetadata; + } + + /** + * setFormMetadata. + **/ + public void setFormMetadata(WebFormMetadata formMetadata) { + this.formMetadata = formMetadata; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebFormSummary webFormSummary = (WebFormSummary) o; + return Objects.equals(this.id, webFormSummary.id) && + Objects.equals(this.accountId, webFormSummary.accountId) && + Objects.equals(this.isPublished, webFormSummary.isPublished) && + Objects.equals(this.isEnabled, webFormSummary.isEnabled) && + Objects.equals(this.hasDraftChanges, webFormSummary.hasDraftChanges) && + Objects.equals(this.formState, webFormSummary.formState) && + Objects.equals(this.formProperties, webFormSummary.formProperties) && + Objects.equals(this.formMetadata, webFormSummary.formMetadata); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(id, accountId, isPublished, isEnabled, hasDraftChanges, formState, formProperties, formMetadata); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormSummary {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" accountId: ").append(toIndentedString(accountId)).append("\n"); + sb.append(" isPublished: ").append(toIndentedString(isPublished)).append("\n"); + sb.append(" isEnabled: ").append(toIndentedString(isEnabled)).append("\n"); + sb.append(" hasDraftChanges: ").append(toIndentedString(hasDraftChanges)).append("\n"); + sb.append(" formState: ").append(toIndentedString(formState)).append("\n"); + sb.append(" formProperties: ").append(toIndentedString(formProperties)).append("\n"); + sb.append(" formMetadata: ").append(toIndentedString(formMetadata)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormSummaryList.java b/src/main/java/com/docusign/webforms/model/WebFormSummaryList.java new file mode 100644 index 0000000..a93c1c3 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormSummaryList.java @@ -0,0 +1,306 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.docusign.webforms.model.WebFormSummary; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import java.math.BigDecimal; + +/** + * A list of web form summary items.. + * + */ +@Schema(description = "A list of web form summary items.") + +public class WebFormSummaryList { + @JsonProperty("items") + private java.util.List items = null; + + @JsonProperty("resultSetSize") + private BigDecimal resultSetSize = null; + + @JsonProperty("totalSetSize") + private BigDecimal totalSetSize = null; + + @JsonProperty("startPosition") + private BigDecimal startPosition = null; + + @JsonProperty("endPosition") + private BigDecimal endPosition = null; + + @JsonProperty("nextUrl") + private String nextUrl = null; + + @JsonProperty("previousUrl") + private String previousUrl = null; + + + /** + * items. + * + * @return WebFormSummaryList + **/ + public WebFormSummaryList items(java.util.List items) { + this.items = items; + return this; + } + + /** + * addItemsItem. + * + * @return WebFormSummaryList + **/ + public WebFormSummaryList addItemsItem(WebFormSummary itemsItem) { + if (this.items == null) { + this.items = new java.util.ArrayList<>(); + } + this.items.add(itemsItem); + return this; + } + + /** + * Array of web form items with each containing summary.. + * @return items + **/ + @Schema(description = "Array of web form items with each containing summary.") + public java.util.List getItems() { + return items; + } + + /** + * setItems. + **/ + public void setItems(java.util.List items) { + this.items = items; + } + + + /** + * resultSetSize. + * + * @return WebFormSummaryList + **/ + public WebFormSummaryList resultSetSize(BigDecimal resultSetSize) { + this.resultSetSize = resultSetSize; + return this; + } + + /** + * Result set size for current page. + * @return resultSetSize + **/ + @Schema(example = "1.0", description = "Result set size for current page") + public BigDecimal getResultSetSize() { + return resultSetSize; + } + + /** + * setResultSetSize. + **/ + public void setResultSetSize(BigDecimal resultSetSize) { + this.resultSetSize = resultSetSize; + } + + + /** + * totalSetSize. + * + * @return WebFormSummaryList + **/ + public WebFormSummaryList totalSetSize(BigDecimal totalSetSize) { + this.totalSetSize = totalSetSize; + return this; + } + + /** + * Total result set size. + * @return totalSetSize + **/ + @Schema(example = "1.0", description = "Total result set size") + public BigDecimal getTotalSetSize() { + return totalSetSize; + } + + /** + * setTotalSetSize. + **/ + public void setTotalSetSize(BigDecimal totalSetSize) { + this.totalSetSize = totalSetSize; + } + + + /** + * startPosition. + * + * @return WebFormSummaryList + **/ + public WebFormSummaryList startPosition(BigDecimal startPosition) { + this.startPosition = startPosition; + return this; + } + + /** + * Starting position of fields returned for the current page. + * @return startPosition + **/ + @Schema(example = "1.0", description = "Starting position of fields returned for the current page") + public BigDecimal getStartPosition() { + return startPosition; + } + + /** + * setStartPosition. + **/ + public void setStartPosition(BigDecimal startPosition) { + this.startPosition = startPosition; + } + + + /** + * endPosition. + * + * @return WebFormSummaryList + **/ + public WebFormSummaryList endPosition(BigDecimal endPosition) { + this.endPosition = endPosition; + return this; + } + + /** + * Ending position of fields returned for the current page. + * @return endPosition + **/ + @Schema(example = "1.0", description = "Ending position of fields returned for the current page") + public BigDecimal getEndPosition() { + return endPosition; + } + + /** + * setEndPosition. + **/ + public void setEndPosition(BigDecimal endPosition) { + this.endPosition = endPosition; + } + + + /** + * nextUrl. + * + * @return WebFormSummaryList + **/ + public WebFormSummaryList nextUrl(String nextUrl) { + this.nextUrl = nextUrl; + return this; + } + + /** + * Url for the next page of results. + * @return nextUrl + **/ + @Schema(description = "Url for the next page of results") + public String getNextUrl() { + return nextUrl; + } + + /** + * setNextUrl. + **/ + public void setNextUrl(String nextUrl) { + this.nextUrl = nextUrl; + } + + + /** + * previousUrl. + * + * @return WebFormSummaryList + **/ + public WebFormSummaryList previousUrl(String previousUrl) { + this.previousUrl = previousUrl; + return this; + } + + /** + * Url for the previous page of results. + * @return previousUrl + **/ + @Schema(description = "Url for the previous page of results") + public String getPreviousUrl() { + return previousUrl; + } + + /** + * setPreviousUrl. + **/ + public void setPreviousUrl(String previousUrl) { + this.previousUrl = previousUrl; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebFormSummaryList webFormSummaryList = (WebFormSummaryList) o; + return Objects.equals(this.items, webFormSummaryList.items) && + Objects.equals(this.resultSetSize, webFormSummaryList.resultSetSize) && + Objects.equals(this.totalSetSize, webFormSummaryList.totalSetSize) && + Objects.equals(this.startPosition, webFormSummaryList.startPosition) && + Objects.equals(this.endPosition, webFormSummaryList.endPosition) && + Objects.equals(this.nextUrl, webFormSummaryList.nextUrl) && + Objects.equals(this.previousUrl, webFormSummaryList.previousUrl); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(items, resultSetSize, totalSetSize, startPosition, endPosition, nextUrl, previousUrl); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormSummaryList {\n"); + + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" resultSetSize: ").append(toIndentedString(resultSetSize)).append("\n"); + sb.append(" totalSetSize: ").append(toIndentedString(totalSetSize)).append("\n"); + sb.append(" startPosition: ").append(toIndentedString(startPosition)).append("\n"); + sb.append(" endPosition: ").append(toIndentedString(endPosition)).append("\n"); + sb.append(" nextUrl: ").append(toIndentedString(nextUrl)).append("\n"); + sb.append(" previousUrl: ").append(toIndentedString(previousUrl)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormUserInfo.java b/src/main/java/com/docusign/webforms/model/WebFormUserInfo.java new file mode 100644 index 0000000..c550766 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormUserInfo.java @@ -0,0 +1,131 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Information about a DocuSign system user. The user exists within the account associated with the form.. + * + */ +@Schema(description = "Information about a DocuSign system user. The user exists within the account associated with the form.") + +public class WebFormUserInfo { + @JsonProperty("userId") + private String userId = null; + + @JsonProperty("userName") + private String userName = null; + + + /** + * userId. + * + * @return WebFormUserInfo + **/ + public WebFormUserInfo userId(String userId) { + this.userId = userId; + return this; + } + + /** + * Get userId. + * @return userId + **/ + @Schema(description = "") + public String getUserId() { + return userId; + } + + /** + * setUserId. + **/ + public void setUserId(String userId) { + this.userId = userId; + } + + + /** + * userName. + * + * @return WebFormUserInfo + **/ + public WebFormUserInfo userName(String userName) { + this.userName = userName; + return this; + } + + /** + * Name of the user that can be displayed in the user interface.. + * @return userName + **/ + @Schema(example = "John Doe", description = "Name of the user that can be displayed in the user interface.") + public String getUserName() { + return userName; + } + + /** + * setUserName. + **/ + public void setUserName(String userName) { + this.userName = userName; + } + + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebFormUserInfo webFormUserInfo = (WebFormUserInfo) o; + return Objects.equals(this.userId, webFormUserInfo.userId) && + Objects.equals(this.userName, webFormUserInfo.userName); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(userId, userName); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormUserInfo {\n"); + + sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" userName: ").append(toIndentedString(userName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/com/docusign/webforms/model/WebFormValues.java b/src/main/java/com/docusign/webforms/model/WebFormValues.java new file mode 100644 index 0000000..186de41 --- /dev/null +++ b/src/main/java/com/docusign/webforms/model/WebFormValues.java @@ -0,0 +1,64 @@ +package com.docusign.webforms.model; + +import java.util.Objects; +import java.util.Arrays; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Key-value pairs (where key is the component name and value is the form value) used to create a form instance. For key of type TextBox, Email, Date, Select and RadioButtonGroup the value is of string type. For key of type Number, the value is of number type. For key of type of CheckboxGroup, the value is of type array of string.. + * + */ +@Schema(description = "Key-value pairs (where key is the component name and value is the form value) used to create a form instance. For key of type TextBox, Email, Date, Select and RadioButtonGroup the value is of string type. For key of type Number, the value is of number type. For key of type of CheckboxGroup, the value is of type array of string.") + +public class WebFormValues extends java.util.HashMap { + + /** + * Compares objects. + * + * @return true or false depending on comparison result. + */ + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return super.equals(o); + } + + /** + * Returns the HashCode. + */ + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + + /** + * Converts the given object to string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebFormValues {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/test/java/SdkUnitTests.java b/src/test/java/SdkUnitTests.java new file mode 100644 index 0000000..168a3e9 --- /dev/null +++ b/src/test/java/SdkUnitTests.java @@ -0,0 +1,108 @@ +import com.docusign.webforms.api.*; +import com.docusign.webforms.client.*; +import com.docusign.webforms.model.*; +import java.util.*; +import org.junit.*; +import org.junit.runners.MethodSorters; + +/** @author majid.mallis */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class SdkUnitTests { + + // private static final String UserName = System.getenv("USER_NAME"); + // private static final String UserId = System.getenv("USER_ID"); + // private static final String IntegratorKey = System.getenv("INTEGRATOR_KEY_JWT"); + + // private static final String BaseUrl = "https://demo.services.docusign.net/webforms/v1.1"; + // private static final byte[] privateKeyBytes = + // Base64.getDecoder().decode(System.getenv("PRIVATE_KEY")); + // private static final String brandLogoFullPath = + // System.getProperty("user.dir") + "/src/test/docs/DS.png"; + // private static final String brandFullPath = + // System.getProperty("user.dir") + "/src/test/docs/brand.xml"; + + // private static final String SignTest1File = "/src/test/docs/SignTest1.pdf"; + // private static final String TemplateId = System.getenv("TEMPLATE_ID"); + // private static final String BrandId = System.getenv("BRAND_ID"); + // private String[] envelopeIds = new String[0]; + // JUnit 4.12 runs test cases in parallel, so the envelope ID needs to be initiated as well. + private String AccountId = "temp-accountId"; + + public SdkUnitTests() {} + + @BeforeClass + public static void setUpClass() {} + + @AfterClass + public static void tearDownClass() {} + + @Before + public void setUp() { + // if (envelopeIds.length == 0) { + // envelopeIds = getLastTenEnvelopeIds(); + // } + + AccountId = "temp-accountId"; + // if (AccountId.isEmpty()) { + // AccountId = initApiClient(); + // } + } + + @After + public void tearDown() {} + + // try { + // java.util.List scopes = new ArrayList<>(); + // scopes.add(OAuth.Scope_SIGNATURE); + // scopes.add(OAuth.Scope_IMPERSONATION); + + // OAuth.OAuthToken oAuthToken = + // apiClient.requestJWTUserToken(IntegratorKey, UserId, scopes, privateKeyBytes, 3600); + // Assert.assertNotNull(oAuthToken); + // // now that the API client has an OAuth token, let's use it in all + // // DocuSign APIs + // apiClient.setAccessToken(oAuthToken.getAccessToken(), oAuthToken.getExpiresIn()); + // UserInfo userInfo = apiClient.getUserInfo(oAuthToken.getAccessToken()); + // Assert.assertNotNull(userInfo); + // Assert.assertNotNull(userInfo.getAccounts()); + // Assert.assertTrue(userInfo.getAccounts().size() > 0); + + // System.out.println("UserInfo: " + userInfo); + // // parse first account's baseUrl + // // below code required for production, no effect in demo (same + // // domain) + // apiClient.setBasePath(userInfo.getAccounts().get(0).getBaseUri() + "/restapi"); + // Configuration.setDefaultApiClient(apiClient); + // } catch (ApiException ex) { + // Assert.fail("Exception: " + ex); + // } catch (Exception e) { + // Assert.fail("Exception: " + e.getLocalizedMessage()); + // } + // } + + @Test + public void ListDocuments() { + try { + String BaseUrl = "https://demo.services.docusign.net/webforms/v1.1"; + ApiClient apiClient = new ApiClient(BaseUrl); + apiClient.setAccessToken( + "Bearer temp-token", + (long) 5000000); + // UserInfo userInfo = apiClient.getUserInfo(oAuthToken.getAccessToken()); + // System.out.println("userInfo: " + userInfo); + FormManagementApi formManagementApi = new FormManagementApi(); + UUID AccountIdUuid = UUID.fromString(AccountId); + WebFormSummaryList forms = formManagementApi.listForms(AccountIdUuid); + + Assert.assertNotNull(forms); + // Assert.assertNotNull(users.getUsers()); + + // System.out.println("forms: " + forms); + } catch (ApiException ex) { + System.err.println("##########Exception#############: " + ex.getMessage()); + Assert.fail("Exception: " + ex.getLocalizedMessage()); + } catch (Exception e) { + Assert.fail("Exception: " + e.getLocalizedMessage()); + } + } +} diff --git a/stylesheets/github-light.css b/stylesheets/github-light.css new file mode 100644 index 0000000..a562500 --- /dev/null +++ b/stylesheets/github-light.css @@ -0,0 +1,125 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 GitHub, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +*/ + +.pl-c /* comment */ { + color: #969896; + } + + .pl-c1 /* constant, variable.other.constant, support, meta.property-name, support.constant, support.variable, meta.module-reference, markup.raw, meta.diff.header */, + .pl-s .pl-v /* string variable */ { + color: #0086b3; + } + + .pl-e /* entity */, + .pl-en /* entity.name */ { + color: #795da3; + } + + .pl-smi /* variable.parameter.function, storage.modifier.package, storage.modifier.import, storage.type.java, variable.other */, + .pl-s .pl-s1 /* string source */ { + color: #333; + } + + .pl-ent /* entity.name.tag */ { + color: #63a35c; + } + + .pl-k /* keyword, storage, storage.type */ { + color: #a71d5d; + } + + .pl-s /* string */, + .pl-pds /* punctuation.definition.string, string.regexp.character-class */, + .pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */, + .pl-sr /* string.regexp */, + .pl-sr .pl-cce /* string.regexp constant.character.escape */, + .pl-sr .pl-sre /* string.regexp source.ruby.embedded */, + .pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */ { + color: #183691; + } + + .pl-v /* variable */ { + color: #ed6a43; + } + + .pl-id /* invalid.deprecated */ { + color: #b52a1d; + } + + .pl-ii /* invalid.illegal */ { + color: #f8f8f8; + background-color: #b52a1d; + } + + .pl-sr .pl-cce /* string.regexp constant.character.escape */ { + font-weight: bold; + color: #63a35c; + } + + .pl-ml /* markup.list */ { + color: #693a17; + } + + .pl-mh /* markup.heading */, + .pl-mh .pl-en /* markup.heading entity.name */, + .pl-ms /* meta.separator */ { + font-weight: bold; + color: #1d3e81; + } + + .pl-mq /* markup.quote */ { + color: #008080; + } + + .pl-mi /* markup.italic */ { + font-style: italic; + color: #333; + } + + .pl-mb /* markup.bold */ { + font-weight: bold; + color: #333; + } + + .pl-md /* markup.deleted, meta.diff.header.from-file */ { + color: #bd2c00; + background-color: #ffecec; + } + + .pl-mi1 /* markup.inserted, meta.diff.header.to-file */ { + color: #55a532; + background-color: #eaffea; + } + + .pl-mdr /* meta.diff.range */ { + font-weight: bold; + color: #795da3; + } + + .pl-mo /* meta.output */ { + color: #1d3e81; + } + + \ No newline at end of file diff --git a/stylesheets/normalize.css b/stylesheets/normalize.css new file mode 100644 index 0000000..b897081 --- /dev/null +++ b/stylesheets/normalize.css @@ -0,0 +1,425 @@ +/*! normalize.css v3.0.2 | MIT License | git.io/normalize */ + +/** + * 1. Set default font family to sans-serif. + * 2. Prevent iOS text size adjust after orientation change, without disabling + * user zoom. + */ + + html { + font-family: sans-serif; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ + } + + /** + * Remove default margin. + */ + + body { + margin: 0; + } + + /* HTML5 display definitions + ========================================================================== */ + + /** + * Correct `block` display not defined for any HTML5 element in IE 8/9. + * Correct `block` display not defined for `details` or `summary` in IE 10/11 + * and Firefox. + * Correct `block` display not defined for `main` in IE 11. + */ + + article, + aside, + details, + figcaption, + figure, + footer, + header, + hgroup, + main, + menu, + nav, + section, + summary { + display: block; + } + + /** + * 1. Correct `inline-block` display not defined in IE 8/9. + * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. + */ + + audio, + canvas, + progress, + video { + display: inline-block; /* 1 */ + vertical-align: baseline; /* 2 */ + } + + /** + * Prevent modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + + audio:not([controls]) { + display: none; + height: 0; + } + + /** + * Address `[hidden]` styling not present in IE 8/9/10. + * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. + */ + + [hidden], + template { + display: none; + } + + /* Links + ========================================================================== */ + + /** + * Remove the gray background color from active links in IE 10. + */ + + a { + background-color: transparent; + } + + /** + * Improve readability when focused and also mouse hovered in all browsers. + */ + + a:active, + a:hover { + outline: 0; + } + + /* Text-level semantics + ========================================================================== */ + + /** + * Address styling not present in IE 8/9/10/11, Safari, and Chrome. + */ + + abbr[title] { + border-bottom: 1px dotted; + } + + /** + * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. + */ + + b, + strong { + font-weight: bold; + } + + /** + * Address styling not present in Safari and Chrome. + */ + + dfn { + font-style: italic; + } + + /** + * Address variable `h1` font-size and margin within `section` and `article` + * contexts in Firefox 4+, Safari, and Chrome. + */ + + h1 { + font-size: 2em; + margin: 0.67em 0; + } + + /** + * Address styling not present in IE 8/9. + */ + + mark { + background: #ff0; + color: #000; + } + + /** + * Address inconsistent and variable font size in all browsers. + */ + + small { + font-size: 80%; + } + + /** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. + */ + + sub, + sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; + } + + sup { + top: -0.5em; + } + + sub { + bottom: -0.25em; + } + + /* Embedded content + ========================================================================== */ + + /** + * Remove border when inside `a` element in IE 8/9/10. + */ + + img { + border: 0; + } + + /** + * Correct overflow not hidden in IE 9/10/11. + */ + + svg:not(:root) { + overflow: hidden; + } + + /* Grouping content + ========================================================================== */ + + /** + * Address margin not present in IE 8/9 and Safari. + */ + + figure { + margin: 1em 40px; + } + + /** + * Address differences between Firefox and other browsers. + */ + + hr { + box-sizing: content-box; + height: 0; + } + + /** + * Contain overflow in all browsers. + */ + + pre { + overflow: auto; + } + + /** + * Address odd `em`-unit font size rendering in all browsers. + */ + + code, + kbd, + pre, + samp { + font-family: monospace, monospace; + font-size: 1em; + } + + /* Forms + ========================================================================== */ + + /** + * Known limitation: by default, Chrome and Safari on OS X allow very limited + * styling of `select`, unless a `border` property is set. + */ + + /** + * 1. Correct color not being inherited. + * Known issue: affects color of disabled elements. + * 2. Correct font properties not being inherited. + * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. + */ + + button, + input, + optgroup, + select, + textarea { + color: inherit; /* 1 */ + font: inherit; /* 2 */ + margin: 0; /* 3 */ + } + + /** + * Address `overflow` set to `hidden` in IE 8/9/10/11. + */ + + button { + overflow: visible; + } + + /** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. + * Correct `select` style inheritance in Firefox. + */ + + button, + select { + text-transform: none; + } + + /** + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type + * `input` and others. + */ + + button, + html input[type="button"], /* 1 */ + input[type="reset"], + input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ + } + + /** + * Re-set default cursor for disabled elements. + */ + + button[disabled], + html input[disabled] { + cursor: default; + } + + /** + * Remove inner padding and border in Firefox 4+. + */ + + button::-moz-focus-inner, + input::-moz-focus-inner { + border: 0; + padding: 0; + } + + /** + * Address Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + + input { + line-height: normal; + } + + /** + * It's recommended that you don't attempt to style these elements. + * Firefox's implementation doesn't respect box-sizing, padding, or width. + * + * 1. Address box sizing set to `content-box` in IE 8/9/10. + * 2. Remove excess padding in IE 8/9/10. + */ + + input[type="checkbox"], + input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ + } + + /** + * Fix the cursor style for Chrome's increment/decrement buttons. For certain + * `font-size` values of the `input`, it causes the cursor style of the + * decrement button to change from `default` to `text`. + */ + + input[type="number"]::-webkit-inner-spin-button, + input[type="number"]::-webkit-outer-spin-button { + height: auto; + } + + /** + * 1. Address `appearance` set to `searchfield` in Safari and Chrome. + * 2. Address `box-sizing` set to `border-box` in Safari and Chrome + * (include `-moz` to future-proof). + */ + + input[type="search"] { + -webkit-appearance: textfield; /* 1 */ /* 2 */ + box-sizing: content-box; + } + + /** + * Remove inner padding and search cancel button in Safari and Chrome on OS X. + * Safari (but not Chrome) clips the cancel button when the search input has + * padding (and `textfield` appearance). + */ + + input[type="search"]::-webkit-search-cancel-button, + input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; + } + + /** + * Define consistent border, margin, and padding. + */ + + fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; + } + + /** + * 1. Correct `color` not being inherited in IE 8/9/10/11. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + + legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ + } + + /** + * Remove default vertical scrollbar in IE 8/9/10/11. + */ + + textarea { + overflow: auto; + } + + /** + * Don't inherit the `font-weight` (applied by a rule above). + * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. + */ + + optgroup { + font-weight: bold; + } + + /* Tables + ========================================================================== */ + + /** + * Remove most spacing between table cells. + */ + + table { + border-collapse: collapse; + border-spacing: 0; + } + + td, + th { + padding: 0; + } + \ No newline at end of file diff --git a/stylesheets/stylesheet.css b/stylesheets/stylesheet.css new file mode 100644 index 0000000..a1f3ebb --- /dev/null +++ b/stylesheets/stylesheet.css @@ -0,0 +1,246 @@ +* { + box-sizing: border-box; } + + body { + padding: 0; + margin: 0; + font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 1.5; + color: #606c71; } + + a { + color: #1e6bb8; + text-decoration: none; } + a:hover { + text-decoration: underline; } + + .btn { + display: inline-block; + margin-bottom: 1rem; + color: rgba(255, 255, 255, 0.7); + background-color: rgba(255, 255, 255, 0.08); + border-color: rgba(255, 255, 255, 0.2); + border-style: solid; + border-width: 1px; + border-radius: 0.3rem; + transition: color 0.2s, background-color 0.2s, border-color 0.2s; } + .btn + .btn { + margin-left: 1rem; } + + .btn:hover { + color: rgba(255, 255, 255, 0.8); + text-decoration: none; + background-color: rgba(255, 255, 255, 0.2); + border-color: rgba(255, 255, 255, 0.3); } + + @media screen and (min-width: 64em) { + .btn { + padding: 0.75rem 1rem; } } + + @media screen and (min-width: 42em) and (max-width: 64em) { + .btn { + padding: 0.6rem 0.9rem; + font-size: 0.9rem; } } + + @media screen and (max-width: 42em) { + .btn { + display: block; + width: 100%; + padding: 0.75rem; + font-size: 0.9rem; } + .btn + .btn { + margin-top: 1rem; + margin-left: 0; } } + + .page-header { + color: #fff; + text-align: center; + background-color: #159957; + background-image: linear-gradient(120deg, #155799, #159957); } + + @media screen and (min-width: 64em) { + .page-header { + padding: 5rem 6rem; } } + + @media screen and (min-width: 42em) and (max-width: 64em) { + .page-header { + padding: 3rem 4rem; } } + + @media screen and (max-width: 42em) { + .page-header { + padding: 2rem 1rem; } } + + .project-name { + margin-top: 0; + margin-bottom: 0.1rem; } + + @media screen and (min-width: 64em) { + .project-name { + font-size: 3.25rem; } } + + @media screen and (min-width: 42em) and (max-width: 64em) { + .project-name { + font-size: 2.25rem; } } + + @media screen and (max-width: 42em) { + .project-name { + font-size: 1.75rem; } } + + .project-tagline { + margin-bottom: 2rem; + font-weight: normal; + opacity: 0.7; } + + @media screen and (min-width: 64em) { + .project-tagline { + font-size: 1.25rem; } } + + @media screen and (min-width: 42em) and (max-width: 64em) { + .project-tagline { + font-size: 1.15rem; } } + + @media screen and (max-width: 42em) { + .project-tagline { + font-size: 1rem; } } + + .main-content :first-child { + margin-top: 0; } + .main-content img { + max-width: 100%; } + .main-content h1, .main-content h2, .main-content h3, .main-content h4, .main-content h5, .main-content h6 { + margin-top: 2rem; + margin-bottom: 1rem; + font-weight: normal; + color: #159957; } + .main-content p { + margin-bottom: 1em; } + .main-content code { + padding: 2px 4px; + font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; + font-size: 0.9rem; + color: #383e41; + background-color: #f3f6fa; + border-radius: 0.3rem; } + .main-content pre { + padding: 0.8rem; + margin-top: 0; + margin-bottom: 1rem; + font: 1rem Consolas, "Liberation Mono", Menlo, Courier, monospace; + color: #567482; + word-wrap: normal; + background-color: #f3f6fa; + border: solid 1px #dce6f0; + border-radius: 0.3rem; } + .main-content pre > code { + padding: 0; + margin: 0; + font-size: 0.9rem; + color: #567482; + word-break: normal; + white-space: pre; + background: transparent; + border: 0; } + .main-content .highlight { + margin-bottom: 1rem; } + .main-content .highlight pre { + margin-bottom: 0; + word-break: normal; } + .main-content .highlight pre, .main-content pre { + padding: 0.8rem; + overflow: auto; + font-size: 0.9rem; + line-height: 1.45; + border-radius: 0.3rem; } + .main-content pre code, .main-content pre tt { + display: inline; + max-width: initial; + padding: 0; + margin: 0; + overflow: initial; + line-height: inherit; + word-wrap: normal; + background-color: transparent; + border: 0; } + .main-content pre code:before, .main-content pre code:after, .main-content pre tt:before, .main-content pre tt:after { + content: normal; } + .main-content ul, .main-content ol { + margin-top: 0; } + .main-content blockquote { + padding: 0 1rem; + margin-left: 0; + color: #819198; + border-left: 0.3rem solid #dce6f0; } + .main-content blockquote > :first-child { + margin-top: 0; } + .main-content blockquote > :last-child { + margin-bottom: 0; } + .main-content table { + display: block; + width: 100%; + overflow: auto; + word-break: normal; + word-break: keep-all; } + .main-content table th { + font-weight: bold; } + .main-content table th, .main-content table td { + padding: 0.5rem 1rem; + border: 1px solid #e9ebec; } + .main-content dl { + padding: 0; } + .main-content dl dt { + padding: 0; + margin-top: 1rem; + font-size: 1rem; + font-weight: bold; } + .main-content dl dd { + padding: 0; + margin-bottom: 1rem; } + .main-content hr { + height: 2px; + padding: 0; + margin: 1rem 0; + background-color: #eff0f1; + border: 0; } + + @media screen and (min-width: 64em) { + .main-content { + max-width: 64rem; + padding: 2rem 6rem; + margin: 0 auto; + font-size: 1.1rem; } } + + @media screen and (min-width: 42em) and (max-width: 64em) { + .main-content { + padding: 2rem 4rem; + font-size: 1.1rem; } } + + @media screen and (max-width: 42em) { + .main-content { + padding: 2rem 1rem; + font-size: 1rem; } } + + .site-footer { + padding-top: 2rem; + margin-top: 2rem; + border-top: solid 1px #eff0f1; } + + .site-footer-owner { + display: block; + font-weight: bold; } + + .site-footer-credits { + color: #819198; } + + @media screen and (min-width: 64em) { + .site-footer { + font-size: 1rem; } } + + @media screen and (min-width: 42em) and (max-width: 64em) { + .site-footer { + font-size: 1rem; } } + + @media screen and (max-width: 42em) { + .site-footer { + font-size: 0.9rem; } } + \ No newline at end of file