Class: EVSS::IntentToFile::Service

Inherits:
Service show all
Defined in:
lib/evss/intent_to_file/service.rb

Overview

Proxy Service for Intent To File.

Examples:

Create a service and fetching intent to file for a user

itf_response = IntentToFile::Service.new.get_intent_to_file

Constant Summary collapse

ITF_SOURCE =
'VETS.GOV'

Constants inherited from Service

Service::STATSD_KEY_PREFIX

Instance Attribute Summary

Attributes inherited from Service

#transaction_id

Instance Method Summary collapse

Methods inherited from Service

#headers, #initialize, #perform, #save_error_details, service_is_up?, #with_monitoring_and_error_handling

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

Constructor Details

This class inherits a constructor from EVSS::Service

Instance Method Details

#create_intent_to_file(itf_type) ⇒ EVSS::IntentToFIle::IntentToFileResponse

Creates a new intent to file

Parameters:

  • itf_type (String)

    Type of intent to file

Returns:

  • (EVSS::IntentToFIle::IntentToFileResponse)

    Intent to file response object



57
58
59
60
61
62
# File 'lib/evss/intent_to_file/service.rb', line 57

def create_intent_to_file(itf_type)
  with_monitoring_and_error_handling do
    raw_response = perform(:post, itf_type.to_s, { source: ITF_SOURCE }.to_json, headers)
    EVSS::IntentToFile::IntentToFileResponse.new(raw_response.status, raw_response)
  end
end

#get_active(itf_type) ⇒ EVSS::IntentToFile::IntentToFilesResponse

Returns all active intents to file of a particular type

an array of intents to file

Parameters:

  • itf_type (String)

    Type of intent to file

Returns:



44
45
46
47
48
49
# File 'lib/evss/intent_to_file/service.rb', line 44

def get_active(itf_type)
  with_monitoring_and_error_handling do
    raw_response = perform(:get, "#{itf_type}/active")
    EVSS::IntentToFile::IntentToFileResponse.new(raw_response.status, raw_response)
  end
end

#get_intent_to_fileEVSS::IntentToFile::IntentToFilesResponse

Returns all intents to file for a user

an array of intents to file

Returns:



30
31
32
33
34
35
# File 'lib/evss/intent_to_file/service.rb', line 30

def get_intent_to_file
  with_monitoring_and_error_handling do
    raw_response = perform(:get, '')
    EVSS::IntentToFile::IntentToFilesResponse.new(raw_response.status, raw_response)
  end
end

#handle_error(error) ⇒ Object (private)



66
67
68
69
70
71
72
73
# File 'lib/evss/intent_to_file/service.rb', line 66

def handle_error(error)
  if error.is_a?(Common::Client::Errors::ClientError) && error.status != 403 && error.body.is_a?(Hash)
    save_error_details(error)
    raise EVSS::IntentToFile::ServiceException, error.body
  else
    super(error)
  end
end