Class: NNEClient::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/nne_client/result.rb

Overview

The Result is used to represent a single result from a result set. It can be seen roughly as an NNE CompanyBasic object. It provides transparent loading of attributes from the NNE Company object. It also provides methods for navigating the API further.

The Result can be instantiated with either a full result hash from an API query or with just a tdc_id in which case the attributes will be lazy loaded from the API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ad_protectionObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#cvr_noObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#districtObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#emailObject (readonly)



60
61
# File 'lib/nne_client/result.rb', line 60

extended_attributes :email, :homepage, :founded_year,
:number_of_employees, :tdf_name, :status_text

#founded_yearObject (readonly)



60
61
# File 'lib/nne_client/result.rb', line 60

extended_attributes :email, :homepage, :founded_year,
:number_of_employees, :tdf_name, :status_text

#homepageObject (readonly)



60
61
# File 'lib/nne_client/result.rb', line 60

extended_attributes :email, :homepage, :founded_year,
:number_of_employees, :tdf_name, :status_text

#number_of_employeesObject (readonly)



60
61
# File 'lib/nne_client/result.rb', line 60

extended_attributes :email, :homepage, :founded_year,
:number_of_employees, :tdf_name, :status_text

#official_nameObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#p_noObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#phoneObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#status_textObject (readonly)



60
61
# File 'lib/nne_client/result.rb', line 60

extended_attributes :email, :homepage, :founded_year,
:number_of_employees, :tdf_name, :status_text

#streetObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#tdf_nameObject (readonly)



60
61
# File 'lib/nne_client/result.rb', line 60

extended_attributes :email, :homepage, :founded_year,
:number_of_employees, :tdf_name, :status_text

#zip_codeObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

Instance Method Details

#==(other) ⇒ Object



125
126
127
# File 'lib/nne_client/result.rb', line 125

def ==(other)
  other.tdc_id == tdc_id
end

#additional_namesObject

List of additional_names



68
69
70
71
72
73
# File 'lib/nne_client/result.rb', line 68

def additional_names
  result = Fetch.new(tdc_id, :fetch_company_additional_names).result_set.to_hash
  Array(result[:array_ofstring][:item]).map(&:strip).sort
rescue Savon::InvalidResponseError
  []
end

#associatesObject

List of associates



86
87
88
89
90
91
92
93
# File 'lib/nne_client/result.rb', line 86

def associates
  subsidiaries = fetch_associates
  if subsidiaries.kind_of?(Hash)
    [Subsidiary.new(subsidiaries)]
  else
    subsidiaries.map{|subsidiary| Subsidiary.new(subsidiary) }
  end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/nne_client/result.rb', line 133

def eql?(other)
  hash == other.hash
end

#financesObject

List of finance records



116
117
118
119
120
121
122
123
# File 'lib/nne_client/result.rb', line 116

def finances
  finances = fetch_finances
  if finances.kind_of?(Hash)
    [Finance.new(finances)]
  else
    finances.map{|finance| Finance.new(finance) }
  end
end

#hashObject



129
130
131
# File 'lib/nne_client/result.rb', line 129

def hash
  tdc_id.hash
end

#house_noObject



63
64
65
# File 'lib/nne_client/result.rb', line 63

def house_no
  fetch_extended_attributes.fetch(:kvh, {}).fetch(:house_no, nil)
end

#ownershipsObject

List of ownerships



96
97
98
99
100
101
102
103
# File 'lib/nne_client/result.rb', line 96

def ownerships
  ownerships = fetch_ownerships
  if ownerships.kind_of?(Hash)
    [Ownership.new(ownerships)]
  else
    ownerships.map{|ownership| Ownership.new(ownership) }
  end
end

#subsidiariesObject

List of subsidiaries



106
107
108
109
110
111
112
113
# File 'lib/nne_client/result.rb', line 106

def subsidiaries
  subsidiaries = fetch_subsidiaries
  if subsidiaries.kind_of?(Hash)
    [Subsidiary.new(subsidiaries)]
  else
    subsidiaries.map{|subsidiary| Subsidiary.new(subsidiary) }
  end
end

#tradesObject

List of trades



76
77
78
79
80
81
82
83
# File 'lib/nne_client/result.rb', line 76

def trades
  trades = Fetch.new(tdc_id, :fetch_company_trade).result_set.to_hash[:trade] || []
  if trades.kind_of?(Hash)
    [Trade.new(trades)]
  else
    trades.map{|trade| Trade.new(trade) }
  end
end