Class: Orcid::Remote::WorkService

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

Overview

Responsible for interacting with the Orcid works endpoint

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(orcid_profile_id, options = {}) ⇒ WorkService

Returns a new instance of WorkService.



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

def initialize(orcid_profile_id, options = {})
  @orcid_profile_id = orcid_profile_id
  @request_method = options.fetch(:request_method) { :get }
  @body = options.fetch(:body) { '' }
  @token = options.fetch(:token) { default_token }
  @headers = options.fetch(:headers) { default_headers }
  @path = options.fetch(:path) { default_path }
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



10
11
12
# File 'app/services/orcid/remote/work_service.rb', line 10

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



10
11
12
# File 'app/services/orcid/remote/work_service.rb', line 10

def headers
  @headers
end

#orcid_profile_idObject (readonly)

Returns the value of attribute orcid_profile_id.



10
11
12
# File 'app/services/orcid/remote/work_service.rb', line 10

def orcid_profile_id
  @orcid_profile_id
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'app/services/orcid/remote/work_service.rb', line 10

def path
  @path
end

#request_methodObject (readonly)

Returns the value of attribute request_method.



10
11
12
# File 'app/services/orcid/remote/work_service.rb', line 10

def request_method
  @request_method
end

#tokenObject (readonly)

Returns the value of attribute token.



10
11
12
# File 'app/services/orcid/remote/work_service.rb', line 10

def token
  @token
end

Class Method Details

.call(orcid_profile_id, options = {}) ⇒ Object



6
7
8
# File 'app/services/orcid/remote/work_service.rb', line 6

def self.call(orcid_profile_id, options = {})
  new(orcid_profile_id, options).call
end

Instance Method Details

#callObject

:post will append works to the Orcid Profile :put will replace the existing Orcid Profile works with the payload :get will retrieve the Orcid Profile support.orcid.org/knowledgebase/articles/177528-add-works-technical-developer



26
27
28
29
# File 'app/services/orcid/remote/work_service.rb', line 26

def call
  response = deliver
  response.body
end