Class: WIS::DOM::AccountIssues

Inherits:
Results
  • Object
show all
Defined in:
lib/dom/account_issues.rb

Instance Attribute Summary collapse

Attributes inherited from Results

#hits

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hits, account, issues) ⇒ AccountIssues

Returns a new instance of AccountIssues.



4
5
6
7
8
# File 'lib/dom/account_issues.rb', line 4

def initialize(hits, , issues)
	super(hits)
	@account = 
	@issues = issues
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



2
3
4
# File 'lib/dom/account_issues.rb', line 2

def 
  @account
end

#issuesObject (readonly)

Returns the value of attribute issues.



2
3
4
# File 'lib/dom/account_issues.rb', line 2

def issues
  @issues
end

Class Method Details

.adapt_json(data) ⇒ Object



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
47
48
49
50
51
# File 'lib/dom/account_issues.rb', line 10

def self.adapt_json(data)
	 = WIS::DOM::Account.new(data["Account"]["ID"], data["Account"]["Name"], data["Account"]["Description"])
	issues = []
	
	data["Issues"].each do |i|
		issue_result = WIS::DOM::IssueResult.new
		issue_result.issue = WIS::DOM::Issue.new(i["Issue"]["ID"], i["Issue"]["Description"])
			
		unless i["Approved"].nil?
			opinion = WIS::DOM::AccountIssues.convert_hash_to_opinion(i["Approved"])
			issue_result.approved = WIS::DOM::ApprovedOpinion.new(opinion., opinion.issue)
			issue_result.approved.position = opinion.position
			issue_result.approved.narrative = opinion.narrative
			issue_result.approved.taken = opinion.taken
		end
		
		unless i["Unverified"].nil?
			opinion = WIS::DOM::AccountIssues.convert_hash_to_opinion(i["Unverified"])
			issue_result.unverified = WIS::DOM::UnverifiedOpinion.new(opinion., opinion.issue)
			issue_result.unverified.position = opinion.position
			issue_result.approved.narrative = opinion.narrative
		end
		
		unless i["Expressed"].nil?
			opinion = WIS::DOM::AccountIssues.convert_hash_to_opinion(i["Expressed"])
			issue_result.expressed = WIS::DOM::ExpressedOpinion.new(opinion., opinion.issue)
			issue_result.expressed.position = opinion.position
			issue_result.expressed.narrative = opinion.narrative
			issue_result.expressed.taken = opinion.taken
		end
		
		unless i["Unknown"].nil?
			opinion = WIS::DOM::AccountIssues.convert_hash_to_opinion(i["Unknown"])
			issue_result.unknown = WIS::DOM::UnknownOpinion.new(opinion.issue)
			issue_result.unknown.position = opinion.position
		end
		
		issues << issue_result
	end
	
	WIS::DOM::AccountIssues.new(data["Hits"], , issues)
end

.convert_hash_to_opinion(hash) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/dom/account_issues.rb', line 53

def self.convert_hash_to_opinion(hash)
	 = WIS::DOM::Account.new(hash["Account"]["ID"], hash["Account"]["Name"], hash["Account"]["Description"]) unless hash["Account"].nil?
	issue = WIS::DOM::Issue.new(hash["Issue"]["ID"], hash["Issue"]["Description"])
	opinion = WIS::DOM::Opinion.new(, issue)
	opinion.narrative = hash["Narrative"] unless hash["Narrative"].nil?
	opinion.taken = hash["Taken"] unless hash["Taken"].nil?
	opinion.position = hash["Position"] unless hash["Position"].nil?
	opinion
end