Class: KeytechKit::KeytechKit

Inherits:
Object
  • Object
show all
Defined in:
lib/keytechKit.rb

Overview

This class is the interface controller to the keytech Web API Use the helper functions to access various resources from the API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(baseurl, username = '', password = '') ⇒ KeytechKit

Initializes this class user baseurl, username and password to start accessing all other keytech API resources



30
31
32
33
34
# File 'lib/keytechKit.rb', line 30

def initialize(baseurl, username = '', password = '')
  @base_url = baseurl
  @username = username
  @password = password
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



21
22
23
# File 'lib/keytechKit.rb', line 21

def base_url
  @base_url
end

#passwordObject (readonly)

Returns the value of attribute password.



23
24
25
# File 'lib/keytechKit.rb', line 23

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



22
23
24
# File 'lib/keytechKit.rb', line 22

def username
  @username
end

Instance Method Details

#classesObject

Returns the classes object. A class in terms of keytech describes a type of elements. A class describes the attributes, its types and it supported layouts to make certain elements visible for a user.



77
78
79
80
# File 'lib/keytechKit.rb', line 77

def classes
  @classes = Classes.new(@base_url, @username, @password) if @classes.nil?
  @classes
end

#current_userObject

Returns the login in user. This is always the user with which you Initialized this classes Check this object to see if the user is active and have API access.



49
50
51
52
53
54
55
# File 'lib/keytechKit.rb', line 49

def current_user
  if @_curent_user.nil?
    user = User.new(@base_url, @username, @password)
    @_curent_user = user.load(@username)
  end
  @_curent_user
end

#data_dictionary_handlerObject

Returns the Data Dictionaries. Data Dictionary (DD) will give lookup tables you will need to fill various element fields.



68
69
70
71
# File 'lib/keytechKit.rb', line 68

def data_dictionary_handler
  @data_dictionary_handler = DataDictionaryHandler.new(self, @base_url, @username, @password) if @data_dictionary_handler.nil?
  @data_dictionary_handler
end

#element_handlerObject

Returns the Elements resource. You will need to specify alwys the concrete Element you want to access. keytech API does not support to return bulk Lists of Elements



61
62
63
64
# File 'lib/keytechKit.rb', line 61

def element_handler
  @_element_handler = ElementHandler.new(self, @base_url, @username, @password) if @_element_handler.nil?
  @_element_handler
end

#layoutsObject

TODO: Move Laoyuts under classes returns the layout class. Eveny class can have a layout which describes the attribues with its type, acccess, datadictionary and if it is visible to the user.



86
87
88
89
# File 'lib/keytechKit.rb', line 86

def layouts
  @_layouts = Layouts.new(@base_url, @username, @password) if @_layouts.nil?
  @_layouts
end

#searchObject

Returns the Search Object With the search you can start a fulltextsearch, search by field, type or access a predefined search on the server side for elements



95
96
97
98
# File 'lib/keytechKit.rb', line 95

def search
  @_search = Search.new(@base_url, @username, @password) if @_search.nil?
  @_search
end

#serverinfoObject

Returns the Serverinfo @see ServerInfo for details This should be always the first call whenever starting with keytech API. ServerInfo will give valuable information about server access, version number and functions



41
42
43
44
# File 'lib/keytechKit.rb', line 41

def serverinfo
  @serverinfo_handler = ServerInfoHandler.new(self, @base_url) if @serverinfo_handler.nil?
  @serverinfo_handler.load
end