Sha256: ec7d27181748fa3fb4cd4955c3f138b22faf17d4b8a2c2c66aa93003e29fd399

Contents?: true

Size: 671 Bytes

Versions: 23

Compression:

Stored size: 671 Bytes

Contents

module Fanforce::Plugin::Sinatra::FanforceHelpers
  require 'fanforce/api'

  def organization_id
    @organization_id ||= params[:organization_id] || (params[:bie_metadata][:oid] if params[:bie_metadata].is_a?(Hash))
  end

  def ff
    return @ff if @ff.present?
    api_key = Fanforce::Plugin::Sinatra::FanforceHelpers.find_api_key(organization_id) if organization_id
    auth_attrs = {api_key: api_key, organization_id: organization_id} if api_key
    @ff = Fanforce::API.new(auth_attrs)
  end

  def self.find_api_key(organization_id, addon_type=:plugin, addon_id=Plugin._id)
    Plugin.redis.get("installed:#{addon_type}-#{addon_id}:#{organization_id}")
  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
fanforce-plugin-factory-2.0.0.rc29 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc28 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc27 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc26 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc25 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc24 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc23 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc22 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc21 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc19 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc18 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc17 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc16 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc15 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc13 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc12 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc11 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc10 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc9 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc8 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb