Java compatible REST client in Ruby

840 views Asked by At

I need to create a client library to access a REST-based web service via HTTPS.

Not being overly familiar with Java, I would like to do this in Ruby, and then compile to a jar.

The payload I will send will be (in JSON) something like:

{
  "api-token": "12345",
  "org_number": 5,
  "name": "ABC corp",
  "users": {
    "employee_number": 1,
    "name": "bob jones",
    "email": "[email protected]"
  }
}

I assume the client library will need to:

  • Initialize a new API interface instance with API token
  • Give the instance organization information and set of users
  • Tell the instance to serialize the organization and users to JSON, and POST to the webservice /org/new

So my question is:

2

There are 2 answers

1
Selim On

Have you considered JRuby?

https://github.com/jruby/jruby/wiki

0
Paulo Henrique On

Have u heard of ApiClient?

It works well inside rails, making your controller as much thin as possible. But it also works on a non rails application.

It raises different exceptions for each type of http code response to make easy for u to control the client logic based on the server responses.

It automatically initializes an object using the api response for you and sends all the requests by json as well.

It still in development, so let me know of any feature u may need.

I use it to access an API which requires a token for OAUTH2 and it works pretty well so far.

Hope u enjoy. =)