Simple Ruby wrapper for the Formstack (née Formspring) API.
sudo gem install formstack
You'll need a Formstack API key with appropriate permissions.
require 'formstack'
client = Formstack::Client.new("your_api_key")
forms = client.forms
form = client.form(1234)
data = client.data(1234, :page => 2)
Here's where we apply some Ruby magic. The API requires you to know the IDs of your custom form fields (e.g. field_123=blue
). You're more than welcome to use IDs for your hash keys if you like, but you don't have to:
# hash keys correspond to the value of the `name` key in `form.fields`
answers = {
:name => 'Wynn Netherland',
:rating => 5
}
# submit answers to form 1234 - field IDs are looked up on-the-fly
client.submit(1234, :data => answers)
# hash keys correspond to the value of the `name` key in `form.fields`
answers = {
:name => 'Wynn Netherland',
:rating => 5
}
# edit answers for submission 10001
client.edit(10001, :data => answers)
client.delete(10001)
- Handle file uploads for submissions
- Intelligent permission handling for different API key access levels
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version unintentionally.
- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
- Send me a pull request. Bonus points for topic branches.
Copyright (c) 2010 Wynn Netherland. See LICENSE for details.