Nexmo Ruby v6.3.0 Release: Static Type Checking and Host Overriding

Published February 26, 2020 by Ben Greenberg

The Nexmo Ruby SDK recently released v6.3.0, which adds support for overriding the host used for API requests.

The new release also introduces static type checking into the codebase for the first time. Static type checking is a new area in the Ruby ecosystem, and we are excited to be incorporating it to build a more explicit developer experience for those using the SDK in their applications.

Host Overriding

Before v6.3.0, the default hosts for Nexmo APIs, api.nexmo.com, and rest.nexmo.com, were not able to be directly changed inside the Ruby SDK. The most common reason why a developer would want to specify the host is to make their HTTP requests to the API directly towards one of the location-specific data centers.

You can read the recent Node.js SDK Update blog post for further detail on how this change could benefit your development.

To demonstrate this new ability in the Ruby SDK, we will examine the “Make an outbound call with an NCCO” Ruby Code Snippet and alter it to use the US East Coast Data Center for the phone call:

The only change we needed to make was to add the api_host parameter in the client instance. You do not need to specify the api_host parameter during initialization. If you do not, then the default host will be used. This is true for specifying the rest_host as well. However, if you want to direct your requests to a specific geo-located data center, you can now do so with the Ruby SDK.

Static Type Checking

In the development of our SDKs, we are always looking for ways that we can increase the productivity and joy of developers using the tools we create. Creating applications and services with external APIs presents its own set of particular circumstances when it comes to debugging your work.

The introduction of static type checking in the Ruby SDK works to increase confidence in the API calls you are making with the SDK, and helps to both decrease and identify bugs as they occur.

In this SDK release, the Sorbet Gem was installed into the codebase, and we have type checked the Nexmo::SMS class.

We did so by adding a method signature to Nexmo::SMS#send and a method signature to the private method, #unicode?.

The method signature for Nexmo::SMS#send confirms that the method returns an instance of Nexmo::SMS::Response and that the method parameters are in received in the form of a Hash:

In future releases of the Ruby SDK, we will gradually introduce more type checks of classes and the methods within. We also released a 3-part YouTube video series on static type checking in Ruby, if you would like to explore the subject further.

What’s Next?

We are always iterating on our Ruby SDK to improve the experience of using it. Plans for future releases of the Ruby SDK include incorporating support for the Messages and Dispatch APIs, along with increasing our coverage of type checking.

We welcome your comments, input, and suggestions. You can come to join the conversation on GitHub or the community Slack.

Leave a Reply

Your email address will not be published.

Get the latest posts from Nexmo’s next-generation communications blog delivered to your inbox.

By signing up to our communications blog, you accept our privacy policy , which sets out how we use your data and the rights you have in respect of your data. You can opt out of receiving our updates by clicking the unsubscribe link in the email or by emailing us at [email protected].