Class: Doyoubuzz::Showcase

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/doyoubuzz/showcase.rb,
lib/doyoubuzz/showcase/error.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Constructor Details

#initialize(api_key, api_secret) ⇒ Showcase

Construction with mandatory api key and api secret



13
14
15
16
# File 'lib/doyoubuzz/showcase.rb', line 13

def initialize(api_key, api_secret)
  @api_key = api_key
  @api_secret = api_secret
end

Instance Method Details

#sso_redirect_url(application_name, timestamp, sso_key, user_attributes) ⇒ Object

SSO redirection



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/doyoubuzz/showcase.rb', line 26

def sso_redirect_url(application_name, timestamp, sso_key, user_attributes)
  # Check mandatory attributes are given
  missing_attributes = [:email, :external_id, :firstname, :lastname].reject{|key| user_attributes[key]}

  if missing_attributes.length > 0
    raise ArgumentError, "Missing mandatory attributes for SSO : #{missing_attributes.join(', ')}"
  end

  params = sign_sso_params(user_attributes.merge(timestamp: timestamp), sso_key)

  "http://showcase.doyoubuzz.com/p/fr/#{application_name}/sso?#{URI.encode_www_form(params)}"
end