Class: WhosGotDirt::Responses::Relation::OpenCorporates
- Inherits:
-
Helpers::OpenCorporatesHelper
- Object
- SimpleDelegator
- WhosGotDirt::Response
- Helpers::OpenCorporatesHelper
- WhosGotDirt::Responses::Relation::OpenCorporates
- Defined in:
- lib/whos_got_dirt/responses/relation/open_corporates.rb
Overview
Converts corporate officerships from the OpenCorporates API to Popolo format.
Instance Method Summary collapse
-
#item_url(result) ⇒ String
Returns a relation's URL.
-
#to_a ⇒ Array<Hash>
Transforms the parsed response body into results.
Constructor Details
This class inherits a constructor from WhosGotDirt::Response
Instance Method Details
#item_url(result) ⇒ String
Returns a relation's URL.
68 69 70 71 72 73 74 75 |
# File 'lib/whos_got_dirt/responses/relation/open_corporates.rb', line 68 def item_url(result) query = CGI.parse(env.url.query.to_s) url = "#{env.url.scheme}://#{env.url.host}/officers/#{result['identifiers'][0]['identifier']}" if query['api_token'].any? url += "?api_token=#{CGI.escape(query['api_token'][0].to_s)}" end url end |