Class: RubyRedtail::User

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-redtail/user.rb,
lib/ruby-redtail/user/contacts.rb,
lib/ruby-redtail/user/settings.rb

Defined Under Namespace

Classes: Contacts, Settings

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, *args) ⇒ User



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ruby-redtail/user.rb', line 11

def initialize type, *args
  if type == "Basic"
    self.api_hash = "Basic " + Base64.strict_encode64("#{RubyRedtail.config.api_key}:#{args[0]}:#{args[1]}")
  elsif type == "UserKey"
    self.api_hash = "Userkeyauth " + Base64.strict_encode64("#{RubyRedtail.config.api_key}:#{args[0]}")
  elsif type == "UserToken"
    self.api_hash = "UsertokenAuth " + Base64.strict_encode64("#{RubyRedtail.config.api_key}:#{args[0]}")
  else
    raise ArgumentError
  end
end

Instance Attribute Details

#api_hashObject

Returns the value of attribute api_hash.



8
9
10
# File 'lib/ruby-redtail/user.rb', line 8

def api_hash
  @api_hash
end

Class Method Details

.authenticate_via_basic(username, password) {|self.new('Basic',username,password)| ... } ⇒ Object

Yields:

  • (self.new('Basic',username,password))


23
24
25
# File 'lib/ruby-redtail/user.rb', line 23

def self.authenticate_via_basic(username, password)
  yield self.new('Basic',username,password)
end

.authenticate_via_user_key(key) {|self.new('UserKey',key)| ... } ⇒ Object

Yields:

  • (self.new('UserKey',key))


27
28
29
# File 'lib/ruby-redtail/user.rb', line 27

def self.authenticate_via_user_key(key)
  yield self.new('UserKey',key)
end

.authenticate_via_user_token(token) {|self.new('UserToken',token)| ... } ⇒ Object

Yields:

  • (self.new('UserToken',token))


31
32
33
# File 'lib/ruby-redtail/user.rb', line 31

def self.authenticate_via_user_token(token)
  yield self.new('UserToken',token)
end

Instance Method Details

#authenticationObject



41
42
43
# File 'lib/ruby-redtail/user.rb', line 41

def authentication
  RubyRedtail::Authentication.new(RubyRedtail::Query.run("authentication", self.api_hash, "GET"))
end

#contactsObject



56
57
58
# File 'lib/ruby-redtail/user.rb', line 56

def contacts
  RubyRedtail::User::Contacts.new self.api_hash
end

#settingsObject



60
61
62
# File 'lib/ruby-redtail/user.rb', line 60

def settings
  RubyRedtail::User::Settings.new self.api_hash
end

#ssoObject



52
53
54
# File 'lib/ruby-redtail/user.rb', line 52

def sso
  RubyRedtail::Sso.new(RubyRedtail::Query.run("sso", self.api_hash, "GET"))
end

#sso_return_urlObject

Single Sign-On help.redtailtechnology.com/entries/22602246 returns a URL for Single Sign-On based on the specified endpoint. TODO: pass endpoint and id parameters



49
50
51
# File 'lib/ruby-redtail/user.rb', line 49

def sso_return_url
  sso.return_url
end

#user_keyObject

UserKey Retrieval help.redtailtechnology.com/entries/22621068 returns a UserKey in exchange for the Username and Password specified in the Authentication.



38
39
40
# File 'lib/ruby-redtail/user.rb', line 38

def user_key
  authentication.user_key
end