Skip to content

Releases: trolley/java-sdk

v2.1.1

17 Dec 03:51
7425cd7
Compare
Choose a tag to compare

Changelog

Fixes

Types updated to Boolean to allow null values, for:

  1. Types.InvoiceLine.taxReportable
  2. Types.InvoiceLine.forceUsTaxActivity
  3. Types.Supporting.InvoicePaymentPart.coverFees

v2.0.1

13 Sep 00:49
a98d345
Compare
Choose a tag to compare

InvoicePayment Related Updates

We recently made improvements to the InvoicePayment.Create API to allow adding Payment related fields to through the InvoicePayment.Create API.

This update includes a new method that improves how you create a new Invoice Payment with the Java SDK, and deprecates the old method.

The deprecated method will be removed in early 2025.

Old Usage

...
InvoicePayment invoicePayment = client.invoicePayment.create("batch-id", paymentPart);
...

New Usage

We have introduced a new class called InvoicePaymentRequest that contains all the request parameters the updated InvoicePayment API allows.
The InvoicePayment.Create() method now accepts an InvoicePaymentRequest() object.

...
InvoicePaymentRequest invoicePaymentRequest = new InvoicePaymentRequest(
            "batch-id",
            false,
            "Created Payment's Memo",
            "payment-external-id",
            tags,
            paymentPart);       

InvoicePayment invoicePayment = client.invoicePayment.create(invoicePaymentRequest);
...

For an example of how to use the new method, please refer to this integration test.

If you have any questions, reach out to us on developers@trolley.com

v2.0.0

17 Nov 04:48
17817b7
Compare
Choose a tag to compare

Trolley Java SDK Major Update (November 16, 2023)

With this update we're making some important changes to our Java SDK.
This update covers all the API endpoints our SDK didn't cover before, and makes some important updates to how our packages are organized.

To mark this milestone we're bumping up the MAJOR version 2.0.0.

Please read this Update Guide to understand what changed and how to adopt these changes.

Breaking Changes

1. Types have been moved to a different package

The Java SDK packages have been reorganized and all classes representing types have been moved to the types package.

This will throw compile time error in your code base, but reorganizing imports should solve this.

Here's an example of how it used to be before vs how it is now:

Old Package New Installation
import com.trolley.trolley.Payment import com.trolley.Payment
import com.trolley.trolley.Payments import com.trolley.type.Payments
import com.trolley.types.Meta import com.trolley.types.supporting.Meta

2. Method Parameters Changed

To conform with Java ways, all Gateway methods now accept only Objects as request bodies and not Strings.

As an example, here's how some methods worked earlier versus how they work now:

Old Way New Way
String body = "{\"firstName\": \"Bob\"}";
boolean response = client.recipient.update(recipient.getId(), body);
Recipient recipientUpdateRequest = new Recipient();
recipientUpdateRequest.setFirstName("Bob");
boolean response = client.recipient.update(recipient.getId(), recipientUpdateRequest);

3. Recipient Gateway Changes

1. Recipient.search() method

  1. The method now returns a Recipients object, instead of a List<Recipient> object.

    1. The Recipients object further contains a List of Recipient that you can access with List<Recipient> recipients.getRecipients() method to iterate over.
    2. That object also contains a Meta object that you can access with Meta recipients.getMeta() method. It allows you to paginate over the results.
  2. The Recipient class now also has an overloaded search() method that returns a RecipientsIterator object, which allows auto-pagination.

    1. You can use it in a while() loop to go over all pages in a result set without manually paginating. Every single page contains 10 items, and as soon as you reach the end of the page it automatically fetches a new page as long as there is one.
    2. For more details, refer to the documentation or tests/RecipientTest.java.

2. Recipient.findLogs() method renamed

  1. The method Recipient.findLogs() has been renamed to Recipient.getAllLogs().
    1. It also now returns an object of Logs class, with a List<Log> and Meta object for manual pagination.
    2. There's also an overloaded getAllLogs() method that returns an iterator (LogsIterator) for auto-pagination.
    3. For more details, refer to the documentation or tests/RecipientTest.java.

4. Batch Gateway Changes

1. Method Batch.query() replaced by Batch.search()

The method Batch.query() and many different versions of it have been replaced by two variants of Batch.search() method.

  1. Much like the Recipient class's version, Batches Batch.search(int page, int pageSize, String searchTerm) method lets you manually paginate and provide a search keyword.

    1. The Batches object further contains a List of Batches that you can access with List<Batch> Batches.getBatches() method to iterate over.
    2. That object also contains a Meta object that you can access with Meta batches.getMeta() method. It allows you to paginate over the results.
  2. Another overloaded version of the same method - BatchesIterator Batch.search(String searchTerm) - lets you search within a batch and paginate automatically.

    1. You can use it in a while() loop to go over all pages in a result set without manually paginating. Every single page contains 10 items, and as soon as you reach the end of the page it automatically fetches a new page as long as there is one.
    2. For more details, refer to the documentation or tests/RecipientTest.java.

2. Method Batch.create(String body) removed

As mentioned above, to conform with Java ways of accessing methods, the Batch.create(String body) method has been removed.

Please use Batch.create(Batch requestBody) instead, and refer test/BatchTest.java for an example.

3. Method Batch.update(String, String) replaced

As mentioned above, to conform with Java ways of accessing methods, the Batch.update(String batchId, String body) method has been replaced by Batch.update(String batchId, Batch updatedBatch).

Please look at the documentation or test/BatchTest.java for an example.

5. Payment Gateway Changes

1. Method Payment.query() replaced by Payment.search()

The method Payment.query() and many different versions of it have been replaced by two variants of Payment.search() method.

  1. Much like the Recipient class's version, Payments Payment.search(String batchId, int page, int pageSize, String searchTerm) method lets you manually paginate and provide a search keyword.

    1. The Payments object further contains a List of Payments that you can access with List<Payment> Payments.getPayments() method to iterate over.
    2. That object also contains a Meta object that you can access with Meta batches.getMeta() method. It allows you to paginate over the results.
  2. Another overloaded version of the same method - PaymentsIterator Payment.search(String, batchId, String searchTerm) - lets you search within a batch and paginate automatically.

    1. You can use it in a while() loop to go over all pages in a result set without manually paginating.
      Every single page contains 10 items, and as soon as you reach the end of the page it automatically fetches a new page as long as there is one.
    2. For more details, refer to the documentation or tests/BatchTest.java.

6. Balance Gateway Changes

1. Method Balances.find() replaced

The method Balance.find() has essentially been made private, and in it's place you now have individual methods to fetch Balances of your different accounts:

  1. List<Balances> Balances.getAllBalances() - Gets balances of all your accounts.
  2. List<Balances> Balances.getTrolleyAccountBalances() - Gets all balances of your Trolley account.
  3. List<Balances> Balances.getPaypalAccountBalances() - Gets all balances of your Paypal account.

Update to existing Methods

1. Support for Errors as Arrays

The API returns errors in a JSON array. To support this, we have added a way for you to access the errors as an Array as well.
This should make it easier for you to iterate through the array and process the errors.

The array can be accessed through the getErrorResponse() method available through all the Exceptions that Trolley SDK exposes.

Example: Consuming error Array

...
catch(MalformedException e){
      for (JsonNode node : e.getErrorResponse().get("errors")) {
          System.out.println("Error Message: "+node.get("message"));
      }
  }
...

2. Supply your own HtptClient object

While setting up the SDK, you can specify your own HttpClient object for the SDK to use.

This will be useful in cases where you have your own proxy and server setup, that you want to use through your own HttpClient object.

Configuration config = new Configuration("<YOUR_ACCESS_KEY>","<YOUR_SECRET_KEY>", customHttpClient);

Gateway client = new Gateway(config);

3. No need to specify environment now

The SDK now defaults to the production URL i.e. api.trolley.com.
Even while setting up a proxy you no longer need to provide an environment.

If you're running from the source and need to specify a server url, you now have to create a .env file in the project root and specify the BASE_URL there. Then, specify the environment as development for the SDK to start picking up the API url from .env file.

Old way

...
	Gateway client = new Gateway(new Configuration("<ACCESS_KEY>","<SECRET_KEY>","production"));
...

New way

...
	Gateway client = new Gateway(new Configuration("<ACCESS_KEY>","<SECRET_KEY>"));
...

New Methods/API Coverage

We have added support for more API endpoints that our Java SDK wasn't supporting earlier.

Here's a rundown of the new API endpoints covered:

Recipient

1. Get All Offline Payments

You can now fetch all offline payments belonging to a recipient.

You can choose to manually paginate through the results, or use the overloaded method which returns an iterator to auto-paginate through all the pages in the result set.

Gateway client = new Gateway(config);

String recipientId = getRecipientId();

//Manual pagination
OfflinePayments op = client.recipient.getAllOfflinePayments(recipientId, page, pageSize, "");

List<OfflinePayment> offlinePayments = op.getOfflinePayments();

for (OfflinePayment offlinePayment : offlinePayments) {
    System.out.println(offlinePayment.getId());
}
 
Meta meta = op.getMeta();

//Or, with auto-pagination
OfflinePaymentsIterator offlinePayments = client.recipient.getAllOfflinePayments(recipientId, "");

int itemCount = 0;
while(offlinePayments.hasNext()) {
    System.out.println(offlinePayme...
Read more

v1.1.4

13 Sep 18:08
e392438
Compare
Choose a tag to compare

Changelog

Full Changelog: 1.1.3...1.1.4

v1.1.3

29 Aug 04:41
bb860a7
Compare
Choose a tag to compare

Changelog

  • fix: Switch HttpClient to use System properties by @tobyheighway in #28
  • RC: Fix: Make HTTP PATCH requests to use system properties by @Aman-Aalam in #29
  • fix: Update searchInvoices to use array for external ids & use lower camel case for search param by @mortondaniel in #30
  • Fix: Invoice Search parameters

V1.1.2

16 Aug 17:36
deacca9
Compare
Choose a tag to compare

Changelog

  • Added checkNumber to payment object, and added relevant tests
  • Added ENUM for 'complianceStatus` to Recipient object, and added relevant tests.
  • Fixed Payment object so Payment.batch is now of type Batch instead of Object
  • Bumped semver

v1.1.1

13 Jul 16:03
4abbec8
Compare
Choose a tag to compare
  • Added missing Recipient attribute contactEmails
  • Updated README to be on brand
  • Updated InvoiceTest for readability

v1.1.0

14 Jun 18:24
72566dc
Compare
Choose a tag to compare

Changelog

  • Added support for Invoice API, InvoiceLine API, and InvoicePayment API.

v1.0.2

18 Mar 18:41
a4b3671
Compare
Choose a tag to compare

v1.0.2 Changelog


  1. Improved Pagination
  2. Rebranded non-class elements to Trolley
  3. Added tests for routeMinimum
  4. Added Trolley-Source header