Frameio-API
Very basic (and wip) Frame.io API wrapper Only OAuth2 authentification available at the moment.
Installation
Add this line to your application's Gemfile:
gem "frameio-api"
And then execute:
$ bundle
Or install it yourself as:
$ gem install frameio-api
Usage
This gem uses and bundles omniauth-frameio
Omniauth configuration:
This Strategy is meant to be used with Omniauth and has been tested and used with Devise
If using Devise, add this in your Devise.setup in /config/initializers/devise.rb
config.omniauth :frameio,
ENV['FRAME_CLIENT_ID'], # Your app client ID (on Frame.io Oauth app mgmt)
ENV['FRAME_CLIENT_SECRET'], # Your app client Secret (on Frame.io Oauth app mgmt)
scope: 'offline' # list of availables scopes to find on Frame.io dev doc
Please follow Omniauth & Devise instructions for complete configuration.
Wrapper configuration:
class User < ApplicationRecord
act_as_frameio_user
end
By default, frame_io wrapper is expecting the model to respond_to? :access_token, :refresh_token and :expires_at
If you want to change the column names:
class User < ApplicationRecord
act_as_frameio_user access_token: :some_column, refresh_token: :some_other_column, expires_at: :oh_so_other_column
end
That's all! You now have access to a frame.io client:
current_user.frame_io #=> FrameioApi::Client
current_user.frame_io.accounts #=> All accounts for user frame.io account
Due to the nature of the 'tree' on Frame.io, objects needs to be retrieved in chain
current_user.accounts.first.teams.first.projects.first.assets.first.children
Each step is cached by default. If you need to refresh, you can pass:
cache: false
at any moment, like that:
current_user.frame_io.accounts.first.teams.first.projects(cache: false).first.assets
It will refresh from projects and downward.
Lastly, all objects are findable by ID without the need of the 'chain', like that:
current_user.frame_io.asset(id: 'some_id')
It obviously works if and only current_user has access to the file in Frame.io
Contributing
Please raise issues at will, and suggest better ways to handle this!
License
The gem is available as open source under the terms of the MIT License.