Class: Orcid::Configuration::Provider
- Inherits:
-
Object
- Object
- Orcid::Configuration::Provider
- 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
- #authentication_scope ⇒ Object
- #authorize_url ⇒ Object
- #host_url ⇒ Object
- #id ⇒ Object
- #secret ⇒ Object
- #signin_via_json_url ⇒ Object
- #site_url ⇒ Object
-
#store ⇒ Object
readonly
Returns the value of attribute store.
- #token_url ⇒ Object
Instance Method Summary collapse
-
#initialize(store = ::ENV) ⇒ Provider
constructor
A new instance of Provider.
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_scope ⇒ Object
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_url ⇒ Object
52 53 54 55 56 |
# File 'lib/orcid/configuration/provider.rb', line 52 def @authorize_url ||= store.fetch('ORCID_AUTHORIZE_URL') do 'https://sandbox.orcid.org/oauth/authorize' end end |
#host_url ⇒ Object
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(signin_via_json_url) "#{uri.scheme}://#{uri.host}" end end |
#id ⇒ Object
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 |
#secret ⇒ Object
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_url ⇒ Object
37 38 39 40 41 |
# File 'lib/orcid/configuration/provider.rb', line 37 def signin_via_json_url @signin_via_json_url ||= store.fetch('ORCID_REMOTE_SIGNIN_URL') do 'https://sandbox.orcid.org/signin/auth.json' end end |
#site_url ⇒ Object
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 |
#store ⇒ Object (readonly)
Returns the value of attribute store.
9 10 11 |
# File 'lib/orcid/configuration/provider.rb', line 9 def store @store end |
#token_url ⇒ Object
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 |