class LUSI::API::Core::Code

Represents a LUSI code definition which can be retrieved through the LUSI API

Public Class Methods

get_instance(api = nil, lookup = nil, path = nil, endpoint = nil, method = nil, xml_root = nil, **kwargs) { |obj| ... } click to toggle source

Returns a Code instance for the specifiec LUSI API call @param api [LUSI:API::Core::API] the LUSI API instance @param lookup [LUSI::API::Core::Lookup::LookupService, nil] the lookup service for object resolution @param path [String] the LUSI API URL path @param endpoint [String] the LUSI API URL endpoint @param method [String] the LUSI API method @param xml_root [String] the XPath of the root element in the LUSI API response @param identity [any] the identity to search for @param description [String, nil] the description to search for @return [Array<LUSI::API::Core::Code>] the matching Code instances @yield [obj] Passes the Code instance to the block @yieldparam obj [LUSI::API::Core::Code] the Code instance

# File lib/lusi_api/core/code.rb, line 69
def self.get_instance(api = nil, lookup = nil, path = nil, endpoint = nil, method = nil, xml_root = nil, **kwargs)
  params = get_instance_params(**kwargs)
  xml = api.call(path, endpoint, method, **params)
  LUSI::API::Core::XML.xml(xml, xml_root) do |c|
    obj = new(c, lookup)
    begin
      yield(obj) if block_given?
    rescue StandardError => e
      puts e
    end
    obj
  end
end

Protected Class Methods

get_instance_params(**kwargs) click to toggle source

Returns a hash of parameters for the LUSI API call @param identity [any, nil] the identity code @param description [String. nil] the description @return [Hash<String, any>] the parameter hash for the LUSI API call

# File lib/lusi_api/core/code.rb, line 89
def self.get_instance_params(**kwargs)
  {
    Identity: kwargs[:identity] || '',
    Description: kwargs[:description] || ''
  }
end