lib/bolognese/readers/datacite_reader.rb in bolognese-0.9.63 vs lib/bolognese/readers/datacite_reader.rb in bolognese-0.9.64

- old
+ new

@@ -4,16 +4,19 @@ def get_datacite(id: nil, **options) return nil unless id.present? doi = doi_from_url(id) search_url = doi_search(id, options) - search_url += "?q=doi:#{doi}&fl=doi,url,xml,state,allocator_symbol,datacentre_symbol,media,minted,updated&wt=json" + search_url += "/dois/#{doi}?include=client,provider" response = Maremma.get search_url - attributes = response.body.dig("data", "response", "docs").first + attributes = response.body.dig("data", "attributes") return nil 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', "PGhzaD48L2hzaD4=\n") string = Base64.decode64(string) if string.present? doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks) @@ -30,13 +33,13 @@ end { "string" => string, "url" => attributes.fetch("url", nil), "state" => attributes.fetch("state", nil), - "date_registered" => attributes.fetch("minted", nil), + "date_registered" => attributes.fetch("registered", nil), "date_updated" => attributes.fetch("updated", nil), - "provider_id" => attributes.fetch("allocator_symbol", nil), - "client_id" => attributes.fetch("datacentre_symbol", nil) } + "provider_id" => provider_id, + "client_id" => client_id } end def read_datacite(string: nil, **options) return { "errors" => "no content" } unless string.present?