A Java client for the PactSafe Activity API. Integrate into any application for secure legal record-keeping.
Download the release or clone to build with mvn clean install
.
Coming soon to maven-central.
<dependency>
<groupId>com.pactsafe</groupId>
<artifactId>pactsafe-java-sdk</artifactId>
<version>{version}</version>
</dependency>
Initialize the Activity client, passing your PactSafe Site's access_id
String as the first argument.
Activity site = new Activity("ACCESS_KEY");
The second argument to the Activity
constructor is an optional ParameterStore
object of properties for the Activity client.
ParameterStore parameters = new ParameterStore();
parameters.setTestMode(true);
Activity site = new Activity("ACCESS_KEY", parameters);
The third argument is an optional ActivityOptions
object of client configuration settings.
ActivityOptions options = new ActivityOptions();
options.setHost("https://pactsafe.io"); //optional
Activity site = new Activity("ACCESS_KEY", parameters, options);
Every Action sent to the PactSafe Activity API is built from the parameters stored on the Activity client. These parameter values can be set or retrieved at any point.
ParameterStore parameters = site.getParameters();
parameters.setPageTitle("Registration Page");
site.setParameters(parameters);
The load
method lets you load the properties and content of a clickwrap Group by key.
Group group = site.load("GROUP_KEY");
Optionally, you can pass a custom Map<String, Object>
as renderData
for the second argument -- allowing you to alter the content each time the Group is loaded. For this reason, every response from the load
request provides a unique render_id
to use for activity tracking.
renderDataMap.put("order_id", 123456);
renderDataMap.put("company_name", "Example LLC");
Group group = site.load("GROUP_KEY", renderDataMap);
The retrieve
method lets you load a Signer's acceptance history for a given set of Contract IDs.
Providing a signer_id
and an array of contracts
, the response will contain a map of each Contract ID and its most recently accepted Version ID.
List<Integer> contractIds = new ArrayList<Integer>();
contractIds.add(1);
contractIds.add(4);
Map<Integer, String> retrieve = activity.retrieve("SIGNER_ID", contractIds);
When invoked from a group object, the contracts from the group will be automatically loaded.
Map<Integer, String> retrieve = group.retrieve("SIGNER_ID");
The latest
method tells you if a Signer has accepted the latest Version for a given set of Contract IDs.
This method is similar to the retrieve
method, but instead of providing the actual Version ID that was last accepted, the response contains a boolean true
or false
for each contract ID.
Map<Integer, Boolean> latest = activity.latest("SIGNER_ID", contractIds);
When invoked from a group object, the contracts from the group will be automatically loaded.
Map<Integer, Boolean> latest = activity.latest("SIGNER_ID");
The send
method lets you track a Signer Action by sending data to the PactSafe Activity API.
Provide an option from the EventType
enum, as well as any parameters to save on the Action. The signerId
parameter and renderId
are required for most event types.
ParameterStore action = new ParameterStore();
action.setSignerId("[email protected]");
action.setRenderId(group.getParameters().getRenderId());
action.setPageTitle("My Test Page Title");
site.send(EventType.UPDATED, action);
The agreed
method sends a Signer Action to the PactSafe Activity API with the event type agreed
.
Provide a signer_id
, as well as any parameters to save on the Action. If the content being accepted was assigned a render_id
, be sure to include that same render_id
in the Action parameters.
ParameterStore action = new ParameterStore();
action.setSignerId("[email protected]");
action.setRenderId(group.getParameters().getRenderId());
Map<String, Object> customData = new HashMap<String, Object>();
customData.put("order_id", 123456);
customData.put("sku", "MYTX772");
action.setCustomData(customData);
site.agreed(action);
All methods outside of Activity
initialization are designed to throw a PactSafeActivityException
Exception should an issue arrise in the processing of your request. Additionally, an IllegalArgumentException
will be raised should illegal arguments be passed.
For development, you can enable the test_mode
parameter when the client is initialized. Any Signers or Actions created within test mode can be easily cleared from your account.
ParameterStore parameters = new ParameterStore();
parameters.setTestMode(true);
Activity site = new Activity("ACCESS_KEY", parameters);
View the documentation to see how our Javascript web snippet works.
Copyright © 2016 PactSafe, Inc. <[email protected]>
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.