Class: OrcidClient::ExternalIdentifier
- Inherits:
-
Object
- Object
- OrcidClient::ExternalIdentifier
- Defined in:
- lib/orcid_client/external_identifier.rb
Constant Summary collapse
- SCHEMA =
File.("../../../resources/record_#{API_VERSION}/person-external-identifier-#{API_VERSION}.xsd", __FILE__)
Constants included from Api
Instance Attribute Summary collapse
-
#orcid ⇒ Object
readonly
Returns the value of attribute orcid.
-
#orcid_token ⇒ Object
readonly
Returns the value of attribute orcid_token.
-
#put_code ⇒ Object
readonly
Returns the value of attribute put_code.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#validation_errors ⇒ Object
readonly
Returns the value of attribute validation_errors.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(type:, value:, url:, orcid:, orcid_token:, **options) ⇒ ExternalIdentifier
constructor
A new instance of ExternalIdentifier.
- #insert_external_identifier(xml) ⇒ Object
- #insert_id(xml) ⇒ Object
- #root_attributes ⇒ Object
Methods included from Api
#create_external_identifier, #create_notification, #create_work, #delete_external_identifier, #delete_notification, #delete_work, #get_notification, #get_notification_access_token, #get_works, #update_work
Constructor Details
#initialize(type:, value:, url:, orcid:, orcid_token:, **options) ⇒ ExternalIdentifier
Returns a new instance of ExternalIdentifier.
14 15 16 17 18 19 20 21 |
# File 'lib/orcid_client/external_identifier.rb', line 14 def initialize(type:, value:, url:, orcid:, orcid_token:, **) @type = type @value = value @url = url @orcid = orcid @orcid_token = orcid_token @put_code = .fetch(:put_code, nil) end |
Instance Attribute Details
#orcid ⇒ Object (readonly)
Returns the value of attribute orcid.
12 13 14 |
# File 'lib/orcid_client/external_identifier.rb', line 12 def orcid @orcid end |
#orcid_token ⇒ Object (readonly)
Returns the value of attribute orcid_token.
12 13 14 |
# File 'lib/orcid_client/external_identifier.rb', line 12 def orcid_token @orcid_token end |
#put_code ⇒ Object (readonly)
Returns the value of attribute put_code.
12 13 14 |
# File 'lib/orcid_client/external_identifier.rb', line 12 def put_code @put_code end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
12 13 14 |
# File 'lib/orcid_client/external_identifier.rb', line 12 def schema @schema end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
12 13 14 |
# File 'lib/orcid_client/external_identifier.rb', line 12 def type @type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
12 13 14 |
# File 'lib/orcid_client/external_identifier.rb', line 12 def url @url end |
#validation_errors ⇒ Object (readonly)
Returns the value of attribute validation_errors.
12 13 14 |
# File 'lib/orcid_client/external_identifier.rb', line 12 def validation_errors @validation_errors end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
12 13 14 |
# File 'lib/orcid_client/external_identifier.rb', line 12 def value @value end |
Instance Method Details
#data ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/orcid_client/external_identifier.rb', line 25 def data Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| xml.send(:'external-identifier:external-identifier', root_attributes) do insert_external_identifier(xml) end end.to_xml end |
#insert_external_identifier(xml) ⇒ Object
33 34 35 |
# File 'lib/orcid_client/external_identifier.rb', line 33 def insert_external_identifier(xml) insert_id(xml) end |
#insert_id(xml) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/orcid_client/external_identifier.rb', line 37 def insert_id(xml) xml.send(:'common:external-id-type', type) xml.send(:'common:external-id-value', value) xml.send(:'common:external-id-url', url) xml.send(:'common:external-id-relationship', "self") end |
#root_attributes ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/orcid_client/external_identifier.rb', line 44 def root_attributes { :'put-code' => put_code, :'visibility' => 'public', :'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', :'xsi:schemaLocation' => 'http://www.orcid.org/ns/external-identifier ../person-external-identifier-3.0.xsd', :'xmlns:common' => 'http://www.orcid.org/ns/common', :'xmlns:external-identifier' => 'http://www.orcid.org/ns/external-identifier' }.compact end |