12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/gooddata/mixins/md_id_to_uri.rb', line 12
def identifier_to_uri(opts = { :client => GoodData.connection, :project => GoodData.project }, *ids)
client, project = GoodData.get_client_and_project(opts)
response = nil
begin
uri = project.md[IDENTIFIERS_CFG]
response = client.post(uri, 'identifierToUri' => ids)
rescue => ex
raise ex
end
if response['identifiers'].empty?
nil
else
identifiers = response['identifiers']
ids_lookup = identifiers.reduce({}) do |a, e|
a[e['identifier']] = e['uri']
a
end
uris = ids.map { |x| ids_lookup[x] }
uris.count == 1 ? uris.first : uris
end
end
|