Class: SimpleFormsApi::FormRemediation::Configuration::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_forms_api/form_remediation/configuration/base.rb

Direct Known Subclasses

VffConfig

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



11
12
13
14
15
16
17
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 11

def initialize
  @id_type = :benefits_intake_uuid  # The field to query the FormSubmission by
  @include_manifest = true          # Include a CSV file containing manifest data
  @include_metadata = false         # Include a JSON file containing form submission metadata
  @parent_dir = ''                  # The base directory in the S3 bucket where the archive will be stored
  @presign_s3_url = true            # Once archived to S3, the service should generate & return a presigned_url
end

Instance Attribute Details

#id_typeObject (readonly)

Returns the value of attribute id_type.



9
10
11
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 9

def id_type
  @id_type
end

#include_manifestObject (readonly)

Returns the value of attribute include_manifest.



9
10
11
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 9

def include_manifest
  @include_manifest
end

#include_metadataObject (readonly)

Returns the value of attribute include_metadata.



9
10
11
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 9

def 
  @include_metadata
end

#parent_dirObject (readonly)

Returns the value of attribute parent_dir.



9
10
11
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 9

def parent_dir
  @parent_dir
end

#presign_s3_urlObject (readonly)

Returns the value of attribute presign_s3_url.



9
10
11
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 9

def presign_s3_url
  @presign_s3_url
end

Instance Method Details

#attachment_typeObject

The attachment model to query for form submission attachments



46
47
48
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 46

def attachment_type
  PersistentAttachment
end

#handle_error(message, error, **details) ⇒ Object

Utility method, override to add your own team’s preferred error handling approach



73
74
75
76
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 73

def handle_error(message, error, **details)
  log_error(message, error, **details)
  raise SimpleFormsApi::FormRemediation::Error.new(message:, error:)
end

#log_error(message, error, **details) ⇒ Object

Utility method, override to add your own team’s preferred error logging approach



68
69
70
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 68

def log_error(message, error, **details)
  Rails.logger.error({ message:, error: error.message, backtrace: error.backtrace.first(5) }.merge(details))
end

#log_info(message, **details) ⇒ Object

Utility method, override to add your own team’s preferred logging approach



63
64
65
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 63

def log_info(message, **details)
  Rails.logger.info({ message: }.merge(details))
end

#remediation_data_classObject

Override to inject your team’s own submission data builder



30
31
32
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 30

def remediation_data_class
  SimpleFormsApi::FormRemediation::SubmissionRemediationData
end

#s3_clientObject

Override to inject your team’s own s3 client



25
26
27
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 25

def s3_client
  SimpleFormsApi::FormRemediation::S3Client
end

#s3_settingsObject

Used in the SimpleFormsApi::FormRemediation::Uploader S3 uploader

Raises:

  • (NotImplementedError)


58
59
60
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 58

def s3_settings
  raise NotImplementedError, 'Class must implement s3_settings method'
end

#submission_archive_classObject

Override to inject your team’s own submission archive



20
21
22
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 20

def submission_archive_class
  SimpleFormsApi::FormRemediation::SubmissionArchive
end

#submission_typeObject

The FormSubmission model to query against



41
42
43
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 41

def submission_type
  FormSubmission
end

#temp_directory_pathObject

The temporary directory where form submissions will be hydrated and stored. This directory will automatically be deleted once the archive process completes



53
54
55
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 53

def temp_directory_path
  Rails.root.join("tmp/#{SecureRandom.hex}-archive/").to_s
end

#uploader_classObject

Override to inject your team’s own file uploader If overriding this, s3_settings method doesn’t have to be set



36
37
38
# File 'lib/simple_forms_api/form_remediation/configuration/base.rb', line 36

def uploader_class
  SimpleFormsApi::FormRemediation::Uploader
end