Created
May 8, 2015 13:33
-
-
Save paluchas/eb0680d6d303b12fcea4 to your computer and use it in GitHub Desktop.
DataCite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
# Based on | |
class Datacite | |
include HTTParty | |
base_uri 'https://test.datacite.org' | |
# PRODUCTION # base_uri 'https://mds.datacite.org' | |
def initialize | |
@auth = {:username => Rails.application.secrets.mduser, :password => Rails.application.secrets.mdpassword} | |
end | |
# mint DOI | |
def mint(url, doi) | |
options = { :query => {:doi => doi, :url => url}, | |
:basic_auth => @auth, :headers => {'Content-Type' => 'text/plain'} } | |
self.class.post('/mds/doi', options) | |
# PRODUCTION # self.class.post('/doi', options) | |
end | |
# register metadata | |
def metadata(xml) | |
options = { :body => xml, :basic_auth => @auth, | |
:headers => {'Content-Type' => 'application/xml;charset=UTF-8'} } | |
self.class.post('/mds/metadata', options) | |
# PRODUCTION # self.class.post('/metadata', options) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment