Class: MPI::Messages::FindProfileByIdentifier

Inherits:
Object
  • Object
show all
Defined in:
lib/mpi/messages/find_profile_by_identifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier:, identifier_type:, search_type: Constants::CORRELATION_WITH_RELATIONSHIP_DATA) ⇒ FindProfileByIdentifier

Returns a new instance of FindProfileByIdentifier.



12
13
14
15
16
# File 'lib/mpi/messages/find_profile_by_identifier.rb', line 12

def initialize(identifier:, identifier_type:, search_type: Constants::CORRELATION_WITH_RELATIONSHIP_DATA)
  @identifier = identifier
  @identifier_type = identifier_type
  @search_type = search_type
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



10
11
12
# File 'lib/mpi/messages/find_profile_by_identifier.rb', line 10

def identifier
  @identifier
end

#identifier_typeObject (readonly)

Returns the value of attribute identifier_type.



10
11
12
# File 'lib/mpi/messages/find_profile_by_identifier.rb', line 10

def identifier_type
  @identifier_type
end

#search_typeObject (readonly)

Returns the value of attribute search_type.



10
11
12
# File 'lib/mpi/messages/find_profile_by_identifier.rb', line 10

def search_type
  @search_type
end

Instance Method Details

#build_bodyObject (private)



47
48
49
50
51
52
# File 'lib/mpi/messages/find_profile_by_identifier.rb', line 47

def build_body
  body = RequestHelper.build_control_act_process_element
  body << RequestHelper.build_code(code: Constants::FIND_PROFILE_CONTROL_ACT_PROCESS)
  body << query_by_parameter
  body
end

#build_parameter_listObject (private)



59
60
61
62
# File 'lib/mpi/messages/find_profile_by_identifier.rb', line 59

def build_parameter_list
  el = RequestHelper.build_parameter_list_element
  el << RequestHelper.build_identifier(identifier: correlation_identifier, root:)
end

#correlation_identifierObject (private)



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/mpi/messages/find_profile_by_identifier.rb', line 34

def correlation_identifier
  case identifier_type
  when Constants::ICN
    identifier
  when Constants::IDME_UUID
    "#{identifier}^#{Constants::IDME_FULL_IDENTIFIER}"
  when Constants::LOGINGOV_UUID
    "#{identifier}^#{Constants::LOGINGOV_FULL_IDENTIFIER}"
  when Constants::MHV_UUID
    "#{identifier}^#{Constants::MHV_FULL_IDENTIFIER}"
  end
end

#performObject



18
19
20
21
22
23
24
# File 'lib/mpi/messages/find_profile_by_identifier.rb', line 18

def perform
  validate_types
  Messages::RequestBuilder.new(extension: Constants::FIND_PROFILE, body: build_body).perform
rescue => e
  Rails.logger.error "[FindProfileByIdentifier] Failed to build request: #{e.message}"
  raise e
end

#query_by_parameterObject (private)



54
55
56
57
# File 'lib/mpi/messages/find_profile_by_identifier.rb', line 54

def query_by_parameter
  query_by_parameter = RequestHelper.build_query_by_parameter(search_type:)
  query_by_parameter << build_parameter_list
end

#rootObject (private)



64
65
66
# File 'lib/mpi/messages/find_profile_by_identifier.rb', line 64

def root
  Constants::VA_ROOT_OID
end

#validate_typesObject (private)



28
29
30
31
32
# File 'lib/mpi/messages/find_profile_by_identifier.rb', line 28

def validate_types
  unless Constants::QUERY_IDENTIFIERS.include?(identifier_type)
    raise Errors::ArgumentError, "Identifier type is not supported, identifier_type=#{identifier_type}"
  end
end