Class: KeytechKit::Classes
- Inherits:
-
Object
- Object
- KeytechKit::Classes
- Includes:
- HTTParty
- Defined in:
- lib/keytechKit/classes/classes.rb
Instance Method Summary collapse
-
#initialize(base_url, username, password) ⇒ Classes
constructor
A new instance of Classes.
- #load(class_key, options = {}) ⇒ Object
- #loadAllClasses ⇒ Object
Constructor Details
#initialize(base_url, username, password) ⇒ Classes
Returns a new instance of Classes.
7 8 9 10 |
# File 'lib/keytechKit/classes/classes.rb', line 7 def initialize(base_url, username, password) self.class.base_uri(base_url) @auth = { username: username, password: password } end |
Instance Method Details
#load(class_key, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/keytechKit/classes/classes.rb', line 12 def load(class_key, = {}) # Returns a classclasses parameter = { query: } parameter.merge!({ basic_auth: @auth }) response = self.class.get("/classes/#{class_key}", parameter) if response.success? # create a class ClassDefinition.new(response) else raise response.response end end |
#loadAllClasses ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/keytechKit/classes/classes.rb', line 27 def loadAllClasses # Returns a classclasses parameter = { basic_auth: @auth } response = self.class.get("/classes", parameter) if response.success? # create a class classListData = response["ClassConfigurationList"] classDefinitions = Array.new classListData.each do |classData| classDefinitions.push ClassDefinition.new(classData) end classDefinitions else puts "Could not load a classlist #{response.response}" end end |