Skip to content

Instantly share code, notes, and snippets.

@paluchas
Created May 8, 2015 13:33
Show Gist options
  • Save paluchas/eb0680d6d303b12fcea4 to your computer and use it in GitHub Desktop.
Save paluchas/eb0680d6d303b12fcea4 to your computer and use it in GitHub Desktop.
DataCite
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