Class: KeytechKit::DataDictionaryHandler

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/keytechKit/elements/data_dictionary/data_dictionary_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keytechkit, base_url, username, password) ⇒ DataDictionaryHandler

Returns a new instance of DataDictionaryHandler.



9
10
11
12
13
# File 'lib/keytechKit/elements/data_dictionary/data_dictionary_handler.rb', line 9

def initialize(keytechkit, base_url, username, password)
  self.class.base_uri(base_url)
  @auth = { username: username, password: password }
  @keytechkit = keytechkit
end

Instance Attribute Details

#keytechkitObject

Returns the value of attribute keytechkit.



7
8
9
# File 'lib/keytechKit/elements/data_dictionary/data_dictionary_handler.rb', line 7

def keytechkit
  @keytechkit
end

Instance Method Details

#getData(datadictionary_id) ⇒ Object

Returns a hashed value with data



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/keytechKit/elements/data_dictionary/data_dictionary_handler.rb', line 28

def getData(datadictionary_id)
  # /DataDictionaries/{ID}|{Name}/data
  parameter = { basic_auth: @auth }

  response = self.class.get("/datadictionaries/#{datadictionary_id}/data", parameter)
  if response.success?
    response['Data']
  else
    raise response.response
  end
end

#getDefinition(datadictionary_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/keytechKit/elements/data_dictionary/data_dictionary_handler.rb', line 15

def getDefinition(datadictionary_id)
  # /DataDictionaries/{ID}|{Name}
  parameter = { basic_auth: @auth }

  response = self.class.get("/datadictionaries/#{datadictionary_id}", parameter)
  if response.success?
    parse_dataDictionaryDefinition(response['AttributeDefinition'])
  else
    raise response.response
  end
end