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



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_urlObject



54
55
56
57
58
# File 'lib/orcid/configuration/provider.rb', line 54

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

#host_urlObject



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()
    "#{uri.scheme}://#{uri.host}"
  end
end

#idObject



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

#secretObject



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_urlObject



39
40
41
42
43
# File 'lib/orcid/configuration/provider.rb', line 39

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

#site_urlObject



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

#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



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