Class: MPI::Service

Inherits:
Common::Client::Base show all
Includes:
Common::Client::Concerns::Monitoring
Defined in:
lib/mpi/service.rb

Constant Summary collapse

STATSD_KEY_PREFIX =
'api.mvi'
CONNECTION_ERRORS =
[Faraday::ConnectionFailed,
Common::Client::Errors::ClientError,
Common::Exceptions::GatewayTimeout,
Breakers::OutageException].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common::Client::Concerns::Monitoring

#increment, #increment_failure, #increment_total, #with_monitoring

Methods inherited from Common::Client::Base

#config, configuration, #connection, #delete, #get, #perform, #post, #put, #raise_backend_exception, #raise_not_authenticated, #request, #sanitize_headers!, #service_name

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata

Class Method Details

.service_is_up?Boolean

rubocop:enable Metrics/ParameterLists

Returns:

  • (Boolean)


205
206
207
208
# File 'lib/mpi/service.rb', line 205

def self.service_is_up?
  last_mvi_outage = Breakers::Outage.find_latest(service: MPI::Configuration.instance.breakers_service)
  last_mvi_outage.blank? || last_mvi_outage.end_time.present?
end

Instance Method Details

#add_person_implicit_search(first_name:, last_name:, ssn:, birth_date:, email: nil, address: nil, idme_uuid: nil, logingov_uuid: nil) ⇒ Object

rubocop:disable Metrics/ParameterLists



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/mpi/service.rb', line 57

def add_person_implicit_search(first_name:,
                               last_name:,
                               ssn:,
                               birth_date:,
                               email: nil,
                               address: nil,
                               idme_uuid: nil,
                               logingov_uuid: nil)
  with_monitoring do
    raw_response = perform(
      :post, '',
      MPI::Messages::AddPersonImplicitSearchMessage.new(last_name:,
                                                        ssn:,
                                                        birth_date:,
                                                        email:,
                                                        address:,
                                                        idme_uuid:,
                                                        logingov_uuid:,
                                                        first_name:).perform,
      soapaction: Constants::ADD_PERSON
    )
    MPI::Services::AddPersonResponseCreator.new(type: Constants::ADD_PERSON_IMPLICIT_TYPE,
                                                response: raw_response).perform
  end
rescue *CONNECTION_ERRORS => e
  MPI::Services::AddPersonResponseCreator.new(type: Constants::ADD_PERSON_IMPLICIT_TYPE, error: e).perform
end

#add_person_proxy(last_name:, ssn:, birth_date:, icn:, edipi:, search_token:, first_name:) ⇒ Object

rubocop:disable Metrics/ParameterLists



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/mpi/service.rb', line 35

def add_person_proxy(last_name:, ssn:, birth_date:, icn:, edipi:, search_token:, first_name:)
  with_monitoring do
    raw_response = perform(
      :post, '',
      MPI::Messages::AddPersonProxyAddMessage.new(last_name:,
                                                  ssn:,
                                                  birth_date:,
                                                  icn:,
                                                  edipi:,
                                                  search_token:,
                                                  first_name:).perform,
      soapaction: Constants::ADD_PERSON
    )
    MPI::Services::AddPersonResponseCreator.new(type: Constants::ADD_PERSON_PROXY_TYPE,
                                                response: raw_response).perform
  end
rescue *CONNECTION_ERRORS => e
  MPI::Services::AddPersonResponseCreator.new(type: Constants::ADD_PERSON_PROXY_TYPE, error: e).perform
end

#find_profile_by_attributes(first_name:, last_name:, birth_date:, ssn:, search_type: Constants::CORRELATION_WITH_RELATIONSHIP_DATA) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/mpi/service.rb', line 151

def find_profile_by_attributes(first_name:,
                               last_name:,
                               birth_date:,
                               ssn:,
                               search_type: Constants::CORRELATION_WITH_RELATIONSHIP_DATA)
  with_monitoring do
    raw_response = perform(:post, '',
                           MPI::Messages::FindProfileByAttributes.new(first_name:,
                                                                      last_name:,
                                                                      birth_date:,
                                                                      ssn:,
                                                                      search_type:).perform,
                           soapaction: Constants::FIND_PROFILE)
    MPI::Services::FindProfileResponseCreator.new(type: Constants::FIND_PROFILE_BY_ATTRIBUTES_TYPE,
                                                  response: raw_response).perform
  end
rescue *CONNECTION_ERRORS => e
  MPI::Services::FindProfileResponseCreator.new(type: Constants::FIND_PROFILE_BY_ATTRIBUTES_TYPE, error: e).perform
end

#find_profile_by_attributes_with_orch_search(first_name:, last_name:, birth_date:, ssn:, edipi:) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/mpi/service.rb', line 129

def find_profile_by_attributes_with_orch_search(first_name:,
                                                last_name:,
                                                birth_date:,
                                                ssn:,
                                                edipi:)
  with_monitoring do
    raw_response = perform(:post, '',
                           MPI::Messages::FindProfileByAttributes.new(first_name:,
                                                                      last_name:,
                                                                      birth_date:,
                                                                      ssn:,
                                                                      orch_search: true,
                                                                      edipi:).perform,
                           soapaction: Constants::FIND_PROFILE)
    MPI::Services::FindProfileResponseCreator.new(type: Constants::FIND_PROFILE_BY_ATTRIBUTES_ORCH_SEARCH_TYPE,
                                                  response: raw_response).perform
  end
rescue *CONNECTION_ERRORS => e
  MPI::Services::FindProfileResponseCreator.new(type: Constants::FIND_PROFILE_BY_ATTRIBUTES_ORCH_SEARCH_TYPE,
                                                error: e).perform
end

#find_profile_by_edipi(edipi:, search_type: Constants::CORRELATION_WITH_RELATIONSHIP_DATA) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/mpi/service.rb', line 102

def find_profile_by_edipi(edipi:, search_type: Constants::CORRELATION_WITH_RELATIONSHIP_DATA)
  with_monitoring do
    raw_response = perform(:post, '',
                           MPI::Messages::FindProfileByEdipi.new(edipi:,
                                                                 search_type:).perform,
                           soapaction: Constants::FIND_PROFILE)
    MPI::Services::FindProfileResponseCreator.new(type: Constants::FIND_PROFILE_BY_EDIPI_TYPE,
                                                  response: raw_response).perform
  end
rescue *CONNECTION_ERRORS => e
  MPI::Services::FindProfileResponseCreator.new(type: Constants::FIND_PROFILE_BY_EDIPI_TYPE, error: e).perform
end

#find_profile_by_facility(facility_id:, vista_id:, search_type: Constants::CORRELATION_WITH_RELATIONSHIP_DATA) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/mpi/service.rb', line 115

def find_profile_by_facility(facility_id:, vista_id:, search_type: Constants::CORRELATION_WITH_RELATIONSHIP_DATA)
  with_monitoring do
    raw_response = perform(:post, '',
                           MPI::Messages::FindProfileByFacility.new(facility_id:,
                                                                    vista_id:,
                                                                    search_type:).perform,
                           soapaction: Constants::FIND_PROFILE)
    MPI::Services::FindProfileResponseCreator.new(type: Constants::FIND_PROFILE_BY_FACILITY_TYPE,
                                                  response: raw_response).perform
  end
rescue *CONNECTION_ERRORS => e
  MPI::Services::FindProfileResponseCreator.new(type: Constants::FIND_PROFILE_BY_FACILITY_TYPE, error: e).perform
end

#find_profile_by_identifier(identifier:, identifier_type:, search_type: Constants::CORRELATION_WITH_RELATIONSHIP_DATA) ⇒ Object

rubocop:enable Metrics/ParameterLists



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/mpi/service.rb', line 86

def find_profile_by_identifier(identifier:,
                               identifier_type:,
                               search_type: Constants::CORRELATION_WITH_RELATIONSHIP_DATA)
  with_monitoring do
    raw_response = perform(:post, '',
                           MPI::Messages::FindProfileByIdentifier.new(identifier:,
                                                                      identifier_type:,
                                                                      search_type:).perform,
                           soapaction: Constants::FIND_PROFILE)
    MPI::Services::FindProfileResponseCreator.new(type: Constants::FIND_PROFILE_BY_IDENTIFIER_TYPE,
                                                  response: raw_response).perform
  end
rescue *CONNECTION_ERRORS => e
  MPI::Services::FindProfileResponseCreator.new(type: Constants::FIND_PROFILE_BY_IDENTIFIER_TYPE, error: e).perform
end

#update_profile(last_name:, ssn:, birth_date:, icn:, email:, address:, idme_uuid:, logingov_uuid:, edipi:, first_name:) ⇒ Object

rubocop:disable Metrics/ParameterLists



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/mpi/service.rb', line 172

def update_profile(last_name:,
                   ssn:,
                   birth_date:,
                   icn:,
                   email:,
                   address:,
                   idme_uuid:,
                   logingov_uuid:,
                   edipi:,
                   first_name:)
  with_monitoring do
    raw_response = perform(
      :post, '',
      MPI::Messages::UpdateProfileMessage.new(last_name:,
                                              ssn:,
                                              birth_date:,
                                              icn:,
                                              email:,
                                              address:,
                                              idme_uuid:,
                                              logingov_uuid:,
                                              edipi:,
                                              first_name:).perform,
      soapaction: Constants::UPDATE_PROFILE
    )
    MPI::Services::AddPersonResponseCreator.new(type: Constants::UPDATE_PROFILE_TYPE,
                                                response: raw_response).perform
  end
rescue *CONNECTION_ERRORS => e
  MPI::Services::AddPersonResponseCreator.new(type: Constants::UPDATE_PROFILE_TYPE, error: e).perform
end