Class: CapitalIQ::ApiResponse
- Inherits:
-
Object
- Object
- CapitalIQ::ApiResponse
show all
- Defined in:
- lib/capital-iq/api_response.rb
Defined Under Namespace
Classes: IdentifierResultGroup
Instance Method Summary
collapse
Constructor Details
#initialize(response_data) ⇒ ApiResponse
Returns a new instance of ApiResponse.
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/capital-iq/api_response.rb', line 32
def initialize(response_data)
@response_data = response_data
@results = []
@identifier_results = Hash.new {|hash, key| hash[key] = IdentifierResultGroup.new(key)}
raw_results = response_data["GDSSDKResponse"]
return if !raw_results.is_a?(Array)
@results = raw_results.collect { |r| RequestResult.new(r) }
@results.each { |r| @identifier_results[r.Identifier] << r }
end
|
Instance Method Details
#[](identifier) ⇒ Object
51
52
53
54
|
# File 'lib/capital-iq/api_response.rb', line 51
def [](identifier)
return nil unless @identifier_results.has_key?(identifier)
@identifier_results[identifier]
end
|
#has_errors?(header = nil) ⇒ Boolean
46
47
48
49
|
# File 'lib/capital-iq/api_response.rb', line 46
def has_errors?(=nil)
return true if @response_data.include?("Errors")
@results.find { |r| r.has_errors?()}
end
|
#identifiers ⇒ Object
61
62
63
|
# File 'lib/capital-iq/api_response.rb', line 61
def identifiers
@identifier_results.keys
end
|
#scalar ⇒ Object
56
57
58
59
|
# File 'lib/capital-iq/api_response.rb', line 56
def scalar
return nil if @identifier_results.length == 0
@identifier_results.first[1]
end
|
#to_hash ⇒ Object
65
66
67
|
# File 'lib/capital-iq/api_response.rb', line 65
def to_hash
Hash[self.identifiers.collect { |id| [id, self[id]] }]
end
|
#to_s ⇒ Object
69
70
71
|
# File 'lib/capital-iq/api_response.rb', line 69
def to_s
to_hash().to_s()
end
|