Class: Hydra::RemoteIdentifier::RemoteServices::Doi

Inherits:
Hydra::RemoteIdentifier::RemoteService show all
Defined in:
lib/hydra/remote_identifier/remote_services/doi.rb

Constant Summary collapse

TEST_CONFIGURATION =
{
  username: 'apitest',
  password: 'apitest',
  shoulder: 'doi:10.5072/FK2',
  url: "https://n2t.net/ezid/"
}
REQUIRED_ATTRIBUTES =
['target', 'creator', 'title', 'publisher', 'publicationyear' ].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Hydra::RemoteIdentifier::RemoteService

#accessor_name, #name, #to_s

Constructor Details

#initialize(configuration = {}) ⇒ Doi

Returns a new instance of Doi.



18
19
20
21
22
23
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 18

def initialize(configuration = {})
  @username = configuration.fetch(:username)
  @password = configuration.fetch(:password)
  @shoulder = configuration.fetch(:shoulder)
  @url = configuration.fetch(:url)
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



17
18
19
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 17

def password
  @password
end

#shoulderObject (readonly)

Returns the value of attribute shoulder.



17
18
19
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 17

def shoulder
  @shoulder
end

#urlObject (readonly)

Returns the value of attribute url.



17
18
19
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 17

def url
  @url
end

#usernameObject (readonly)

Returns the value of attribute username.



17
18
19
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 17

def username
  @username
end

Instance Method Details

#call(payload) ⇒ Object



34
35
36
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 34

def call(payload)
  request(data_for_create(payload.with_indifferent_access))
end

#remote_uri_for(identifier) ⇒ Object



25
26
27
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 25

def remote_uri_for(identifier)
  URI.parse(File.join(url, identifier))
end

#valid_attribute?(attribute_name) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/hydra/remote_identifier/remote_services/doi.rb', line 30

def valid_attribute?(attribute_name)
  REQUIRED_ATTRIBUTES.include?(attribute_name.to_s)
end