Class: Orcid::Remote::ProfileCreationService

Inherits:
Service
  • Object
show all
Defined in:
app/services/orcid/remote/profile_creation_service.rb

Overview

Responsible for minting a new ORCID for the given payload.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Service

#callback

Constructor Details

#initialize(config = {}, &callback_config) ⇒ ProfileCreationService

Returns a new instance of ProfileCreationService.



13
14
15
16
17
18
19
20
# File 'app/services/orcid/remote/profile_creation_service.rb', line 13

def initialize(config = {}, &callback_config)
  super(&callback_config)
  @token = config.fetch(:token) do
    Orcid.client_credentials_token('/orcid-profile/create')
  end
  @path = config.fetch(:path) { 'v1.1/orcid-profile' }
  @headers = config.fetch(:headers) { default_headers }
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



12
13
14
# File 'app/services/orcid/remote/profile_creation_service.rb', line 12

def headers
  @headers
end

#pathObject (readonly)

Returns the value of attribute path.



12
13
14
# File 'app/services/orcid/remote/profile_creation_service.rb', line 12

def path
  @path
end

#tokenObject (readonly)

Returns the value of attribute token.



12
13
14
# File 'app/services/orcid/remote/profile_creation_service.rb', line 12

def token
  @token
end

Class Method Details

.call(payload, config = {}, &callback_config) ⇒ Object



8
9
10
# File 'app/services/orcid/remote/profile_creation_service.rb', line 8

def self.call(payload, config = {}, &callback_config)
  new(config, &callback_config).call(payload)
end

Instance Method Details

#call(payload) ⇒ Object



22
23
24
25
26
27
# File 'app/services/orcid/remote/profile_creation_service.rb', line 22

def call(payload)
  response = deliver(payload)
  parse(response)
rescue ::OAuth2::Error => e
  parse_exception(e)
end