A simple Ruby wrapper for the Gravity Forms Web API.
Add this line to your application's Gemfile:
gem 'gravityforms-api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install gravityforms-api
Add configuration:
# config/initializers/gravityforms_api.rb
Gravityforms::Api.configure do |config|
config.api_url = 'http://mydomain.com/gravityformsapi/'
config.api_key = 'api_key'
config.private_key = 'private_key'
end
Or in .env
:
API_URL="http://mydomain.com/gravityformsapi/"
API_KEY="api_key"
PRIVATE_KEY="private_key"
Get all forms:
Gravityforms::Api::Form.all
Get form with ID=1:
Gravityforms::Api::Form.find(1)
Submit a form with ID=1:
json = '{"input_values":{"input_1":"Hello","input_2_3":"John","input_2_6":"Smith"}}'
response = Gravityforms::Api::Form.submit(1, json)
Example response:
{
"is_valid": true,
"page_number": 0,
"source_page_number": 1,
"confirmation_message": "this is the confirmation [snipped]"
}
- Fork it ( https://github.com/[my-github-username]/gravityforms-api/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request