lib/bolognese/readers/datacite_reader.rb in bolognese-0.9.92 vs lib/bolognese/readers/datacite_reader.rb in bolognese-0.9.93

- old
+ new

@@ -4,19 +4,16 @@ def get_datacite(id: nil, **options) return { "string" => nil, "state" => "not_found" } unless id.present? doi = doi_from_url(id) search_url = doi_search(id, options) - search_url += "/dois/#{doi}?include=client,provider" + search_url += "?q=doi:#{doi}&fl=doi,url,xml,state,allocator_symbol,datacentre_symbol,media,minted,updated&wt=json" response = Maremma.get search_url - attributes = response.body.dig("data", "attributes") + attributes = response.body.dig("data", "response", "docs").first return { "string" => nil, "state" => "not_found" } unless attributes.present? - client_id = response.body.dig("data", "relationships", "client", "data", "id").upcase - provider_id = response.body.dig("data", "relationships", "provider", "data", "id").upcase - string = attributes.fetch('xml', nil) string = Base64.decode64(string) if string.present? if string.present? doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks) @@ -33,13 +30,13 @@ end { "string" => string, "b_url" => attributes.fetch("url", nil), "state" => attributes.fetch("state", nil), - "date_registered" => attributes.fetch("registered", nil), + "date_registered" => attributes.fetch("minted", nil), "date_updated" => attributes.fetch("updated", nil), - "provider_id" => provider_id, - "client_id" => client_id } + "provider_id" => attributes.fetch("allocator_symbol", nil), + "client_id" => attributes.fetch("datacentre_symbol", nil) } end def read_datacite(string: nil, **options) meta = Maremma.from_xml(string).to_h.fetch("resource", {}) schema_version = meta.fetch("xmlns", nil)