Class: OSCRuby::Answer

Inherits:
ServiceClass show all
Defined in:
lib/osc_ruby/answer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ServiceClass

all, #create, #destroy, find, #update, url, where

Methods included from ClassFactoryModule

all, create, destroy, find, instantiate_multiple_objects, new_from_fetch, update, where

Methods included from ValidationsModule

attr_hash_exists_and_is_type_of, check_attributes, check_attributes_request, check_client, check_for_id, check_for_names, check_for_parents, check_interfaces, check_object_for_id, check_query, extract_attributes

Methods included from QueryModule

check_obj_for_errors, create, destroy, find, normalize, update

Constructor Details

#initialize(attributes = nil) ⇒ Answer

Returns a new instance of Answer.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/osc_ruby/answer.rb', line 8

def initialize(attributes = nil)

			if attributes.nil?

		@answerType = {}
		@summary = "Answer summary text"
		@language = {}
		@question = nil
		@categories = []

			else

				@id = attributes["id"]
				@lookupName = attributes["lookupName"]
				@createdTime = attributes["createdTime"]
				@updatedTime = attributes["updatedTime"]
				@accessLevels = attributes["accessLevels"]
				@name = attributes["name"]
				@adminLastAccessTime = attributes["adminLastAccessTime"]
				@answerType = attributes["answerType"]
				@expiresDate = attributes["expiresDate"]
				@guidedAssistance = attributes["guidedAssistance"]
				@keywords = attributes["keywords"]
				@language = attributes["language"]
				@lastAccessTime = attributes["lastAccessTime"]
				@lastNotificationTime = attributes["lastNotificationTime"]
				@nextNotificationTime = attributes["nextNotificationTime"]
				@originalReferenceNumber = attributes["originalReferenceNumber"]
				@positionInList = attributes["positionInList"]
				@publishOnDate = attributes["publishOnDate"]
				@question = attributes["question"]
				@solution = attributes["solution"]
				@summary = attributes["summary"]
				@updatedByAccount = attributes["updatedByAccount"]
				@uRL = attributes["uRL"]

			end

end

Instance Attribute Details

#accessLevelsObject

Returns the value of attribute accessLevels.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def accessLevels
  @accessLevels
end

#adminLastAccessTimeObject

Returns the value of attribute adminLastAccessTime.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def adminLastAccessTime
  @adminLastAccessTime
end

#answerTypeObject

Returns the value of attribute answerType.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def answerType
  @answerType
end

#categoriesObject

Returns the value of attribute categories.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def categories
  @categories
end

#createdTimeObject

Returns the value of attribute createdTime.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def createdTime
  @createdTime
end

#expiresDateObject

Returns the value of attribute expiresDate.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def expiresDate
  @expiresDate
end

#guidedAssistanceObject

Returns the value of attribute guidedAssistance.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def guidedAssistance
  @guidedAssistance
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def id
  @id
end

#keywordsObject

Returns the value of attribute keywords.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def keywords
  @keywords
end

#languageObject

Returns the value of attribute language.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def language
  @language
end

#lastAccessTimeObject

Returns the value of attribute lastAccessTime.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def lastAccessTime
  @lastAccessTime
end

#lastNotificationTimeObject

Returns the value of attribute lastNotificationTime.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def lastNotificationTime
  @lastNotificationTime
end

#lookupNameObject

Returns the value of attribute lookupName.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def lookupName
  @lookupName
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def name
  @name
end

#nextNotificationTimeObject

Returns the value of attribute nextNotificationTime.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def nextNotificationTime
  @nextNotificationTime
end

#originalReferenceNumberObject

Returns the value of attribute originalReferenceNumber.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def originalReferenceNumber
  @originalReferenceNumber
end

#positionInListObject

Returns the value of attribute positionInList.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def positionInList
  @positionInList
end

#publishOnDateObject

Returns the value of attribute publishOnDate.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def publishOnDate
  @publishOnDate
end

#questionObject

Returns the value of attribute question.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def question
  @question
end

#solutionObject

Returns the value of attribute solution.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def solution
  @solution
end

#summaryObject

Returns the value of attribute summary.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def summary
  @summary
end

#updatedByAccountObject

Returns the value of attribute updatedByAccount.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def updatedByAccount
  @updatedByAccount
end

#updatedTimeObject

Returns the value of attribute updatedTime.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def updatedTime
  @updatedTime
end

#uRLObject

Returns the value of attribute uRL.



5
6
7
# File 'lib/osc_ruby/answer.rb', line 5

def uRL
  @uRL
end

Class Method Details

.check_for_language_and_type(obj_attrs) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/osc_ruby/answer.rb', line 91

def self.check_for_language_and_type(obj_attrs)

	if ValidationsModule::attr_hash_exists_and_is_type_of(obj_attrs,'language','id',Fixnum)
		
		raise ArgumentError, 'Answer should at least the language, answerType, and summary set (new_answer.language = {"id" => 1}; new_answer.answerType = {"id" => 1}}; new_answer.summary = "This is the Answer Title")'
	
	end
	
	if ValidationsModule::attr_hash_exists_and_is_type_of(obj_attrs,'answerType','id',Fixnum) && 
		ValidationsModule::attr_hash_exists_and_is_type_of(obj_attrs,'answerType','lookupName',String)
		
		raise ArgumentError, 'Answer should at least the language, answerType, and summary set (new_answer.language = {"id" => 1}; new_answer.answerType = {"id" => 1}}; new_answer.summary = "This is the Answer Title")'

	end

	obj_attrs

end

.check_self(obj, is_update = false) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/osc_ruby/answer.rb', line 77

def self.check_self(obj,is_update = false)

	obj_attrs = ValidationsModule::extract_attributes(obj)

	if is_update == false

		obj_attrs = check_for_language_and_type(obj_attrs)
		
	end

	obj_attrs

end

Instance Method Details

#set_attributes(response_body) ⇒ Object

Convenience Methods for making the CRUD operations nicer to use



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/osc_ruby/answer.rb', line 51

def set_attributes(response_body)
   	self.id = response_body['id'].to_i
	self.lookupName = response_body['lookupName'].to_i
	self.createdTime = response_body['createdTime']
	self.updatedTime = response_body['updatedTime']
	self.accessLevels = response_body['accessLevels']
	self.adminLastAccessTime = response_body['adminLastAccessTime']
	self.answerType = response_body['answerType']
	self.expiresDate = response_body['expiresDate']
	self.guidedAssistance = response_body['guidedAssistance']
	self.keywords = response_body['keywords']
	self.language = response_body['language']
	self.lastAccessTime = response_body['lastAccessTime']
	self.lastNotificationTime = response_body['lastNotificationTime']
	self.name = response_body['name'].to_i
	self.nextNotificationTime = response_body['nextNotificationTime']
	self.originalReferenceNumber = response_body['originalReferenceNumber']
	self.positionInList = response_body['positionInList']
	self.publishOnDate = response_body['publishOnDate']
	self.question = response_body['question']
	self.solution = response_body['solution']
	self.summary = response_body['summary']
	self.updatedByAccount = response_body['updatedByAccount']
	self.uRL = response_body['uRL']
end