- "body": "# DocuSign Java Client\r\n\r\nYou can sign up for a free [developer sandbox](https://www.docusign.com/developer-center).\r\n\r\nRequirements\r\n============\r\n\r\nJava 1.6 or later. \r\n\r\nInstallation\r\n============\r\n\r\n### Maven users\r\n\r\nAdd this dependency to your project's POM:\r\n\r\n```xml\r\n<dependency>\r\n <groupId>com.docusign</groupId>\r\n <artifactId>docusign-esign-java</artifactId>\r\n <version>2.1.0</version>\r\n</dependency>\r\n```\r\n\r\n### Gradle users\r\n\r\nAdd this dependency to your project's build file:\r\n\r\n```groovy\r\ncompile \"com.docusign:docusign-esign-java:2.1.0\"\r\n```\r\n\r\n#### Note for Android Developers \r\n\r\nIf you encounter build errors due to duplicate definitions, include the following in your build.gradle module:\r\n\r\n```\r\nandroid {\r\n packagingOptions {\r\n pickFirst 'META-INF/services/javax.ws.rs.ext.MessageBodyReader’\r\n pickFirst 'META-INF/services/javax.ws.rs.ext.MessageBodyWriter’\r\n pickFirst 'META-INF/services/com.sun.jersey.spi.inject.InjectableProvider’\r\n pickFirst 'META-INF/jersey-module-version' pickFirst 'META-INF/NOTICE’\r\n pickFirst 'META-INF/LICENSE’\r\n pickFirst 'META-INF/services/com.fasterxml.jackson.databind.Module’\r\n pickFirst 'META-INF/services/com.fasterxml.jackson.core.ObjectCodec’\r\n pickFirst 'META-INF/services/com.fasterxml.jackson.core.JsonFactory’\r\n }\r\n}\r\n```\r\n\r\n### Package Managers\r\n\r\nThis client is available through the following Java package managers:\r\n\r\n- [Nexus Repository Manager](https://oss.sonatype.org/#nexus-search;quick~docusign-esign-java) (oss.sonatype.org). You can search for com.docusign or docusign-esign-java. The current version is 2.1.0.\r\n- [JFrog Bintray](https://bintray.com/search?query=docusign-esign-java) (bintray.com). You can search for com.docusign or docusign-esign-java. The current version is 2.1.0.\r\n\r\n### Others\r\n\r\nOr you can manually download and add the following JARs to your project:\r\n\r\n* The [docusign-esign-java-2.1.0](/target/docusign-esign-java-2.1.0.jar) JAR.\r\n* The [Dependency JARs](/target/lib) in /lib folder.\r\n\r\n\r\nUsage\r\n=====\r\n\r\nTo send a signature request from a Template:\r\n\r\n```java\r\nimport com.docusign.esign.api.*;\r\nimport com.docusign.esign.client.*;\r\nimport com.docusign.esign.model.*;\r\n\r\npublic class DocuSignExample {\r\n\tpublic static void main(String[] args) {\r\n\t\tString username = \"[EMAIL]\";\r\n\t\tString password = \"[PASSWORD]\";\r\n\t\tString integratorKey = \"[INTEGRATOR_KEY]\";\r\n\t\t\r\n\t\t// initialize client for desired environment and add X-DocuSign-Authentication header\r\n\t\tApiClient apiClient = new ApiClient();\r\n\t\tapiClient.setBasePath(\"https://demo.docusign.net/restapi\");\r\n\t\t\r\n\t\t// configure 'X-DocuSign-Authentication' authentication header\r\n String authHeader = \"{\\\"Username\\\":\\\"\" + username + \"\\\",\\\"Password\\\":\\\"\" + password + \"\\\",\\\"IntegratorKey\\\":\\\"\" + integratorKey + \"\\\"}\";\r\n apiClient.addDefaultHeader(\"X-DocuSign-Authentication\", authHeader);\r\n Configuration.setDefaultApiClient(apiClient);\r\n try\r\n {\r\n \r\n /////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n // STEP 1: AUTHENTICATE TO RETRIEVE ACCOUNTID & BASEURL \r\n /////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n\t \r\n AuthenticationApi authApi = new AuthenticationApi();\r\n LoginInformation loginInfo = authApi.login();\r\n \r\n // parse first account ID (user might belong to multiple accounts) and baseUrl\r\n String accountId = loginInfo.getLoginAccounts().get(0).getAccountId(); \r\n String baseUrl = loginInfo.getLoginAccounts().get(0).getBaseUrl();\r\n String[] accountDomain = baseUrl.split(\"/v2\");\r\n \r\n // below code required for production, no effect in demo (same domain) \r\n apiClient.setBasePath(accountDomain[0]);\r\n Configuration.setDefaultApiClient(apiClient);\r\n \r\n /////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n // *** STEP 2: CREATE ENVELOPE FROM TEMPLATE \r\n /////////////////////////////////////////////////////////////////////////////////////////////////////////\r\n \r\n // create a new envelope to manage the signature request\r\n EnvelopeDefinition envDef = new EnvelopeDefinition();\r\n envDef.setEmailSubject(\"DocuSign Java SDK - Sample Signature Request\");\r\n \r\n // assign template information including ID and role(s)\r\n envDef.setTemplateId(\"[TEMPLATE_ID]\");\r\n \r\n // create a template role with a valid templateId and roleName and assign signer info\r\n TemplateRole tRole = new TemplateRole();\r\n tRole.setRoleName(\"[ROLE_NAME]\");\r\n tRole.setName(\"[SIGNER_NAME]\");\r\n tRole.setEmail(\"[SIGNER_EMAIL]\");\r\n \r\n // create a list of template roles and add our newly created role\r\n List<TemplateRole> templateRolesList = new ArrayList<TemplateRole>();\r\n templateRolesList.add(tRole);\r\n \r\n // assign template role(s) to the envelope \r\n envDef.setTemplateRoles(templateRolesList);\r\n \r\n // send the envelope by setting |status| to \"sent\". To save as a draft set to \"created\"\r\n envDef.setStatus(\"sent\");\r\n \r\n // instantiate a new EnvelopesApi object\r\n EnvelopesApi envelopesApi = new EnvelopesApi();\r\n \r\n // call the createEnvelope() API\r\n EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef);\r\n }\r\n catch (com.docusign.esign.client.ApiException ex)\r\n {\r\n System.out.println(\"Exception: \" + ex);\r\n }\r\n\t}\r\n} \r\n```\r\n\r\nSee [SdkUnitTests.java](https://github.com/docusign/docusign-java-client/blob/master/src/test/java/SdkUnitTests.java) for more examples.\r\n\r\nTesting\r\n=======\r\n\r\nYou must have Maven installed. To run the tests:\r\n\r\n mvn test\r\n\r\nSupport\r\n=======\r\n\r\nFeel free to log issues against this client through GitHub. We also have an active developer community on Stack Overflow, search the [DocuSignAPI](http://stackoverflow.com/questions/tagged/docusignapi) tag.\r\n\r\nLicense\r\n=======\r\n\r\nThe DocuSign Java Client is licensed under the following [License](LICENSE).\r\n\r\nNotes\r\n=======\r\n\r\nThis version of the client library does not implement all of the DocuSign REST API methods. The current client omits methods in the Accounts, Billing, Cloud Storage, Connect, Groups (Branding), and Templates (Bulk Recipients) categories. The client's methods support the core set of use cases that most integrations will encounter. For a complete list of omitted endpoints, see [Omitted Endpoints](./omitted_endpoints.md).",
0 commit comments