Class: Orcid::Configuration::Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/orcid/configuration/provider.rb

Overview

Responsible for negotiating the retrieval of Orcid provider information. Especially important given that you have private auth keys. Also given that you may want to request against the sandbox versus the production Orcid service.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store = ::ENV) ⇒ Provider

Returns a new instance of Provider.



10
11
12
# File 'lib/orcid/configuration/provider.rb', line 10

def initialize(store = ::ENV)
  @store = store
end

Instance Attribute Details

#authentication_scopeObject



15
16
17
18
19
20
# File 'lib/orcid/configuration/provider.rb', line 15

def authentication_scope
  @authentication_scope ||=
  store.fetch('ORCID_APP_AUTHENTICATION_SCOPE') do
    '/authenticate,/orcid-works/create,/orcid-works/update,/read-public'
  end
end

#authorize_urlObject



52
53
54
55
56
# File 'lib/orcid/configuration/provider.rb', line 52

def authorize_url
  @authorize_url ||= store.fetch('ORCID_AUTHORIZE_URL') do
    'https://sandbox.orcid.org/oauth/authorize'
  end
end

#host_urlObject



44
45
46
47
48
49
# File 'lib/orcid/configuration/provider.rb', line 44

def host_url
  @host_url ||= store.fetch('ORCID_HOST_URL') do
    uri = URI.parse()
    "#{uri.scheme}://#{uri.host}"
  end
end

#idObject



59
60
61
62
63
# File 'lib/orcid/configuration/provider.rb', line 59

def id
  @id ||= store.fetch('ORCID_APP_ID')
rescue KeyError
  raise ConfigurationError, 'ORCID_APP_ID'
end

#secretObject



66
67
68
69
70
# File 'lib/orcid/configuration/provider.rb', line 66

def secret
  @secret ||= store.fetch('ORCID_APP_SECRET')
rescue KeyError
  raise ConfigurationError, 'ORCID_APP_SECRET'
end

#signin_via_json_urlObject



37
38
39
40
41
# File 'lib/orcid/configuration/provider.rb', line 37

def 
  @signin_via_json_url ||= store.fetch('ORCID_REMOTE_SIGNIN_URL') do
    'https://sandbox.orcid.org/signin/auth.json'
  end
end

#site_urlObject



23
24
25
26
27
# File 'lib/orcid/configuration/provider.rb', line 23

def site_url
  @site_url ||= store.fetch('ORCID_SITE_URL') do
    'http://api.sandbox.orcid.org'
  end
end

#storeObject (readonly)

Returns the value of attribute store.



9
10
11
# File 'lib/orcid/configuration/provider.rb', line 9

def store
  @store
end

#token_urlObject



30
31
32
33
34
# File 'lib/orcid/configuration/provider.rb', line 30

def token_url
  @token_url ||= store.fetch('ORCID_TOKEN_URL') do
    'https://api.sandbox.orcid.org/oauth/token'
  end
end