Retrieving a List of Transactions
  • 10 Oct 2024
  • 4 Minutes to read
  • Dark
    Light
  • PDF

Retrieving a List of Transactions

  • Dark
    Light
  • PDF

Article summary

Java SDK.NET SDKREST APIAPEX SDK

Java SDK

It is strongly recommended that you use a Callback Listener instead of polling for transaction statuses. The use of polling may consume unnecessary resources on both your end, and on the OneSpan Sign service.

Retrieving Transaction Within Specified Date Ranges

To download the full code sample see our Code Share site.

The first step in retrieving a list of transactions that fall within a specified date range is to define the range of dates. The following code will do this:

Date START_DATE = new LocalDateTime(2016, 1, 1, 0, 0).toDate(); //January 01 2016, 00:00 EST
Date END_DATE = LocalDateTime.now().toDate();

Then, you can retrieve your transactions within this date range, sorted by status. For example,  COMPLETED, DRAFT, ARCHIVED, SENT, and DECLINED). The following code will do this:

Page<DocumentPackage> draftPage = eslClient.getPackageService().getUpdatedPackagesWithinDateRange(PackageStatus.DRAFT, new PageRequest(1), START_DATE, END_DATE);

Retrieving a List of Transactions IDs

To download the full code sample see our Code Share site.

Retrieving a list of transaction IDs returns a Page object containing a List of Map types, with each Map Type containing the PackageID.

The following code will do this:

		PageRequest pageRequest = new PageRequest(1, 100);
		Boolean hasNext = false;
		do {
		    Page<Map<String, String>> packages = eslClient.getPackageService().getPackagesFields(PackageStatus.COMPLETED,
		            pageRequest, Sets.newHashSet("id"));
		    hasNext = packages.hasNextPage();
		    pageRequest = pageRequest.next();
		     
		    List<Map<String,String>> results = packages.getResults();
		    for (Map<String, String> map : results) {
		        String packageId = map.get("id");
		        System.out.println(packageId);
		    }
		     
		} while (hasNext);

.NET SDK

It is strongly recommended that you use a Callback Listener instead of polling for transaction statuses. The use of polling may consume unnecessary resources on both your end, and on the OneSpan Sign service.

Retrieving Transaction Within Specified Date Ranges

To download the full code sample see our Code Share site.

The first step in retrieving a list of transactions that fall within a specified date range is to define the range of dates. The following code will do this:

DateTime START_DATE = DateTime.Now.AddDays(-100); //Retrieve packages for last 100 days
DateTime END_DATE = DateTime.Now;

Then, you can retrieve your transactions within this date range sorted by status. For example,  COMPLETED, DRAFT, ARCHIVED, SENT, and DECLINED). The following code will do this:

Page<DocumentPackage> draftPage = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus.DRAFT, new PageRequest(1), START_DATE, END_DATE);

Retrieving a List of Transactions IDs

To download the full code sample see our Code Share site.

Retrieving a list of transaction IDs returns a Page object containing a List of Map types, with each Map Type containing the PackageID.

The following code will do this:

            PageRequest pageRequest = new PageRequest(1, 100);
            bool hasNext = false;
            do
            {
                Page<Dictionary<String, String>> packages = eslClient.PackageService.GetPackagesFields(DocumentPackageStatus.COMPLETED,
                        pageRequest, new HashSet<String>() { "id" });
                hasNext = packages.HasNextPage();
                pageRequest = pageRequest.Next;
                IList<Dictionary<String, String>> results = packages.Results;
                foreach (var map in results)
                {
                    String packageId = map["id"];
                    Debug.WriteLine(packageId);
                }
            } while (hasNext);

REST API

It is strongly recommended that you use a Callback Listener instead of polling for transaction statuses. The use of polling may consume unnecessary resources on both your end, and on the OneSpan Sign service.

Retrieving Transaction Within Specified Date Ranges

To download the full code sample see our Code Share site.

The first step in retrieving a list of transactions that fall within a specified date range is to define the range of dates. The following code will do this:

HTTP Request

GET /api/packages?query={status}&startDate={date}&endDate={date}

HTTP Headers

Accept: application/json
Content-Type: application/json
Authorization: Basic api_key

The JSON objects of each transaction will be returned to you. The following are the possible values for each parameter:

Response Payload

{
  "results": [
  		{
  		    "id": "mC3p1FENigGItiL3Zmojtr64e0Y=","status": "DRAFT",
		    "description": "",
		    "language": "en",
		    ...
  		},
  		{...},
  		{...},
  		...
   ],
  "count": 216

}
  • query: ARCHIVED, COMPLETED, DRAFT, SENT, EXPIRED, OPTED_OUT, AND DECLINED.

  • startDate: Used for pagination.

  • endDate: Used for pagination. (Note: A maximum of 100 transactions can be returned)

Retrieving a List of Transactions IDs

The following code will do this. Note the following:

  • fields: The only available value is "id".

HTTP Request

GET /api/packages?query={status}&startDate={date}&endDate={date}&fields=id

HTTP Headers

Accept: application/json
Content-Type: application/json
Authorization: Basic api_key

Response Payload

{
    "results": [
        {
            "id": "uchWJej65gbJsVaWmibQHGc8_rA="
        },
        {
    "id": "jUfE05dJsa6d3A_oYxixt0gf2SI="
        },
        ...
    ],"count": 216
}

APEX SDK

To download the full code sample see our Code Share site.

It is strongly recommended that you use a Callback Listener instead of polling for transaction statuses. The use of polling may consume unnecessary resources on both your end, and on the OneSpan Sign service.

Retrieving a List of Transactions

You can retrieve a list of transaction by passing a map of query parameters.

public List<ESignLiveAPIObjects.Package_x> getPackages(Map<String,String> queryParameters)

For example:

List < ESignLiveAPIObjects.Package_x > packages = new TestRetrievePackagesWithinDateRanges().getPackages(new Map<String, String> {
	'lastUpdatedStartDate' => '2023-11-01', 'lastUpdatedEndDate' => '2023-11-10', 'from' => '1', 'to' => '100', 'query' => 'SENT'
});

query: ARCHIVED, COMPLETED, DRAFT, SENT, EXPIRED, OPTED_OUT, AND DECLINED.

from: Used for pagination.

to: Used for pagination. (Note: A maximum of 100 packages can be returned)

StartDate: The date to begin retrieving transactions (for example, 2023-01-01)

EndDate: The last date transactions are to be retrieved for example, 2023-12-31).

fields: The only available value is id.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Ozzy, our interactive help assistant