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.rc7 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc6 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb
fanforce-plugin-factory-2.0.0.rc5 lib/fanforce/plugin_factory/sinatra/helpers/fanforce.rb