By Pratham Makhni Alag
If you're planning to use the View and Data API to incorporate a 3D viewer in your Ruby on Rails app, there is a fully functional Ruby gem out, called adn_viewer. You can use it for authentication, bucket creation, uploading files and even registering your uploaded model for translation and subsequent viewing.
The source code and documentation may be found on adn_viewer.
This gem is installed in a Ruby script or Ruby or Rails app simply by adding the gem and its gem dependencies, namely curb, curb-fu, json and gon to the gemfile and installing the bundle.
The following functions are provided as of now:
1. Getting an access token (required for any call to the server):
2. Creating a bucket (required to store a model):
Adn_Viewer.create_bucket(token, name, policy)
3. Getting bucket details:
4. Getting a list of formats supported by the viewer (for pre-validification of uploaded files):
5. Uploading a file (replace name with name of bucket you want to upload the file to):
Adn_Viewer.upload_file(token, name, filename, filepath)
6. Register your uploaded file for translation:
The success responses on these calls are parsed, in usable JSON format and similar to the ones on the Quickstart Tutorial.
Also, the gem documentation contains a few notes on correct formatting, as required with a few commands such as to extract the key after calling the upload_file function.
This gem requires Ruby >= 2.0.0 and a key and secret generated from developer.autodesk.com! Finally, the current stable version of adn_viewer is 1.0.0.
Additionally, two sample apps that utilize the View and Data api are provided.
The adn_viewer_gem_test_app is a simple app that uses all the functions of the gem. It contains a tutorial on creating an RoR app with viewer incorporated: adn_viewer_gem_test_app
The sample-ruby-on-rails-app-prototyping is a more advanced app that doesn't use the gem, but shows what you can do with the API in RoR: sample-ruby-on-rails-app-prototyping
The app for the same is setup on viewanddata.herokuapp.com