Releases: trolley/java-sdk
v2.1.1
v2.0.1
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
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
-
The method now returns a
Recipients
object, instead of aList<Recipient>
object.- The
Recipients
object further contains a List of Recipient that you can access withList<Recipient> recipients.getRecipients()
method to iterate over. - That object also contains a
Meta
object that you can access withMeta recipients.getMeta()
method. It allows you to paginate over the results.
- The
-
The Recipient class now also has an overloaded
search()
method that returns aRecipientsIterator
object, which allows auto-pagination.- 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. - For more details, refer to the documentation or
tests/RecipientTest.java
.
- You can use it in a
2. Recipient.findLogs()
method renamed
- The method
Recipient.findLogs()
has been renamed toRecipient.getAllLogs()
.- It also now returns an object of
Logs
class, with aList<Log>
andMeta
object for manual pagination. - There's also an overloaded
getAllLogs()
method that returns an iterator (LogsIterator
) for auto-pagination. - For more details, refer to the documentation or
tests/RecipientTest.java
.
- It also now returns an object of
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.
-
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.- The
Batches
object further contains a List of Batches that you can access withList<Batch> Batches.getBatches()
method to iterate over. - That object also contains a
Meta
object that you can access withMeta batches.getMeta()
method. It allows you to paginate over the results.
- The
-
Another overloaded version of the same method -
BatchesIterator Batch.search(String searchTerm)
- lets you search within a batch and paginate automatically.- 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. - For more details, refer to the documentation or
tests/RecipientTest.java
.
- You can use it in a
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.
-
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.- The
Payments
object further contains a List of Payments that you can access withList<Payment> Payments.getPayments()
method to iterate over. - That object also contains a
Meta
object that you can access withMeta batches.getMeta()
method. It allows you to paginate over the results.
- The
-
Another overloaded version of the same method -
PaymentsIterator Payment.search(String, batchId, String searchTerm)
- lets you search within a batch and paginate automatically.- 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. - For more details, refer to the documentation or
tests/BatchTest.java
.
- You can use it in a
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:
List<Balances> Balances.getAllBalances()
- Gets balances of all your accounts.List<Balances> Balances.getTrolleyAccountBalances()
- Gets all balances of your Trolley account.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...
v1.1.4
Changelog
- fix: Add missing fields to Payment by @mortondaniel in #32
- RC 1.1.4 by @Aman-Aalam in #33
Full Changelog: 1.1.3...1.1.4
v1.1.3
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
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 typeBatch
instead ofObject
- Bumped semver
v1.1.1
- Added missing Recipient attribute
contactEmails
- Updated README to be on brand
- Updated InvoiceTest for readability
v1.1.0
Changelog
- Added support for Invoice API, InvoiceLine API, and InvoicePayment API.
v1.0.2
v1.0.2 Changelog
- Improved Pagination
- Rebranded non-class elements to Trolley
- Added tests for
routeMinimum
- Added
Trolley-Source
header