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
17 18 19 20 21 22 |
# File 'lib/orcid/configuration/provider.rb', line 17 def authentication_scope @authentication_scope ||= store.fetch('ORCID_APP_AUTHENTICATION_SCOPE') do '/authenticate /orcid-works/create /orcid-works/update' end end |
#authorize_url ⇒ Object
54 55 56 57 58 |
# File 'lib/orcid/configuration/provider.rb', line 54 def ||= store.fetch('ORCID_AUTHORIZE_URL') do 'https://sandbox.orcid.org/oauth/authorize' end end |
#host_url ⇒ Object
46 47 48 49 50 51 |
# File 'lib/orcid/configuration/provider.rb', line 46 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
61 62 63 64 65 |
# File 'lib/orcid/configuration/provider.rb', line 61 def id @id ||= store.fetch('ORCID_APP_ID') rescue KeyError raise ConfigurationError, 'ORCID_APP_ID' end |
#secret ⇒ Object
68 69 70 71 72 |
# File 'lib/orcid/configuration/provider.rb', line 68 def secret @secret ||= store.fetch('ORCID_APP_SECRET') rescue KeyError raise ConfigurationError, 'ORCID_APP_SECRET' end |
#signin_via_json_url ⇒ Object
39 40 41 42 43 |
# File 'lib/orcid/configuration/provider.rb', line 39 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
25 26 27 28 29 |
# File 'lib/orcid/configuration/provider.rb', line 25 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
32 33 34 35 36 |
# File 'lib/orcid/configuration/provider.rb', line 32 def token_url @token_url ||= store.fetch('ORCID_TOKEN_URL') do 'https://api.sandbox.orcid.org/oauth/token' end end |