Skip to content

v1.0.1

Compare
Choose a tag to compare
@Aman-Aalam Aman-Aalam released this 04 May 13:09
· 13 commits to master since this release
eb726c9

Trolley Ruby SDK Major Update (May 1, 2023)

With this update we're making some important changes to our Ruby SDK.
This update covers all the remaining API endpoints our SDk didn't cover earlier. We are also renaming all classes to Trolley to complete our rebranding.

To mark this milestone we're moving to our first major version 1.0.0, and are releasing this version under a new name.

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

Breaking Changes

1. New package on RubyGems

Our Ruby SDK is now available under a new namespace on RubyGems, which is as per our new name 'Trolley' : https://rubygems.org/gems/trolley/

With this update, you'll have to make changes to how Trolley SDK is referenced and used in your code:

  • The command you used to install the SDK now changes:
Old Installation New Installation
gem install paymentrails gem install trolley
  • If you're adding the gem directly in your Gemfile, you'll need to replace it with the new gem's name:
Old Gem New Gem
gem 'paymentrails' gem 'trolley'
  • You'll also need to update the gem import in your code:
Old Gem New Gem
require 'paymentrails' require 'trolley'

2. All “PaymentRails” classes rebranded to “Trolley”

To complete our rebranding, all the classes called PaymentRails are now called Trolley. You'll need to rename all the class usage in your code.

Example: Old usage

require 'paymentrails'

client = PaymentRails.client('ACCESS-KEY', 'ACCESS-SECRET')

recipient = client.recipient.find('R-1234567abcdefg')
print recipient.id

Example: New usage

require 'trolley'

client = Trolley.client('ACCESS-KEY', 'ACCESS-SECRET')

recipient = client.recipient.find('R-1234567abcdefg')
print recipient.id

A simple find-and-replace should be helpful in replacing the class names.

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.

Old way

client = Trolley.client('ACCESS-KEY', 'SECRET-KEY', 'production', proxy_uri: 'peter_the_proxy.com')

New way

client = Trolley.client('ACCESS-KEY', 'SECRET-KEY', proxy_uri: 'peter_the_proxy.com')

Updates 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 error can be accessed through TrolleyError.validation_errors object.

Example: Consuming error Array

...
  rescue ::Trolley::TrolleyError => e
    print e.validation_errors.count
    print e.validation_errors.first['field']
    print e.validation_errors.first['message']
    print e.validation_errors.first['code']
...

You don't need to make any code changes, your old code will still work.
This just gives more options to you to process error messages should you want.

2. Improvements to Pagination

We have made improvements to how our SDKs handle pagination.
Now you can paginate easily through index functions such as Search.
View an example below.

Example: Paginating through results

...
	collection = client.recipient.search(1, 100)

	# Iterate over all your records
	collection.pages.times do |page|
		collection = client.recipient.search(page + 1, 100)
  		collection.each do |recipient|
			puts recipient.email
	  	end
	end
...

You don't need to make any code changes, your old code will still work.
This just gives more options to you to process error messages should you want.

New Methods/API Coverage

We have added support for more API endpoints that our Ruby SDK wasn't supporting earlier. Here's a rundown of the new API endpoints covered:

1. Delete multiple recipients

@client.recipient.delete([first_recipient.id, second_recipient.id, ...])

2. Find payments by recipient id

@client.recipient.find_payments(recipient.id)

3. Find a recipient's activity logs

@client.recipient.find_logs(recipient.id)

4. Delete multiple batches

@client.batch.delete([first_batch.id, second_batch.id, ...])

Housekeeping updates

Apart form covering new APIs, we also updated the dependencies to improve the functionality and security of the SDK:

  1. Minimum required ruby version updated from 2.4 to 2.7
  2. Bumped rake from v12 to v13
  3. Updated Rubocop config and updated from version 0.77.0 to 1.0.0
  4. Added dotenv package to load keys and optional server url from .env file

We hope these new updates help you build Trolley integration faster and more reliably.
If you have any questions or find any bugs, please open an issue or reach out to us at developers@trolley.com
Collaborations and PRs are welcome.