Translate a simple API example from Node.js into Ruby
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Go to https://www.zipplease.com (project I'm working on) and scroll down to the Try It section. The backend example is available in Node.js - I need it in Ruby. You'll have to signup for Zipplease to complete this task, but it's free, I'll never email you, and I'll be wiping the database later this week.

Input from client side

Sent via AJAX is JSON formatted like:
{ images : [ array of urls represented as strings ] }

Response to Client Side

Take that input, send a valid request to zipplease, which will respond with json with a download URL. Forward that back to the front end in a JSON format like this:

{ url : "http://www.zipplease.com/ziplocation" }

awarded to Sirupsen

Crowdsource coding tasks.

3 Solutions


Hi, first of all!

I've translated the node.js example to ruby, and I tried it with my accountKey and accountSecret. But I got a 401 Unothorized.
It should still work as expected, provided you have the necessary gems installed.

Here is the link: https://gist.github.com/3905335

Joseph

Winning solution

Hello,

I've translated it into Ruby using only the standard library except Sinatra. Sinatra is a Ruby library for easily making simple websites. Most Rubyists are familiar with it, so it will seem more familiar than using pure Ruby with sockets to create a webserver to handle your logic.

The code is available here:

https://gist.github.com/7d5b4ea86cc8d343ffb9

View Timeline