Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SIMPLE-FORMS] doc: update form_submission_pdf_backups.md #19436

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

This documentation covers the setup and usage of the PDF upload/download solution, designed to handle individual form submissions as PDF files within an AWS S3 bucket.

The following image depicts how this solution is architected:

![Error Remediation Architecture](./error_remediation_architecture.png)

---

## Table of Contents
Expand All @@ -17,6 +13,7 @@ The following image depicts how this solution is architected:
- [Configuration](#configuration)
- [Usage](#usage)
- [Individual Processing](#individual-processing)
- [S3 Pre-Signed URL Retrieval](#s3-pre-signed-url-retrieval)
- [Extending Functionality](#extending-functionality)
- [Overrideable Classes](#overrideable-classes)
- [Directory and File Structure](#directory-and-file-structure)
Expand Down Expand Up @@ -82,20 +79,21 @@ By default, the solution uses the `:benefits_intake_uuid` identifier to query `F

### Individual Processing

To handle a single PDF upload for a form submission, instantiate the `S3Client` directly with the appropriate configuration and submission ID:
To handle a single PDF upload for a form submission, instantiate the `S3Client` directly with the appropriate configuration and submission ID. For backup purposes, specify `type: :submission` during initialization. This ensures that only the original form PDF is uploaded and a presigned URL is generated:

```ruby
config = YourTeamsConfig.new
client = SimpleFormsApi::FormRemediation::S3Client.new(config:, id: <YOUR_SUBMISSION_ID>)
client = SimpleFormsApi::FormRemediation::S3Client.new(config:, id: <YOUR_SUBMISSION_ID>, type: :submission)
client.upload
```

For backup purposes, specify `type: :submission` during initialization. This ensures that only the original form PDF is uploaded and a presigned URL is generated:
### S3 Pre-Signed URL Retrieval

To handle a single PDF download for an already archived form submission, call the `fetch_presigned_url` class method on the `S3Client` class with the appropriate configuration and submission ID:

```ruby
config = YourTeamsConfig.new
client = SimpleFormsApi::FormRemediation::S3Client.new(config:, id: <YOUR_SUBMISSION_ID>, type: :submission)
client.upload
SimpleFormsApi::FormRemediation::S3Client.fetch_presigned_url(<YOUR_SUBMISSION_ID>, config:)
```

---
Expand All @@ -108,10 +106,12 @@ Each component of this solution can be extended or customized to meet team requi
2. Create subclasses for required functionality.
3. Register the subclass in your configuration:

Extending the uploader:

```ruby
# frozen_string_literal: true

require 'simple_forms_api/form_remediation/configuration/base'
require 'simple_forms_api/form_remediation/uploader'

class NewUploader < SimpleFormsApi::FormRemediation::Uploader
def size_range
Expand All @@ -120,6 +120,8 @@ class NewUploader < SimpleFormsApi::FormRemediation::Uploader
end
```

Using the new uploader within your own team's configuration:

```ruby
# frozen_string_literal: true

Expand All @@ -136,6 +138,8 @@ class NewConfig < SimpleFormsApi::FormRemediation::Configuration::Base
end
```

Instantiate the client with your team's configuration:

```ruby
config = NewConfig.new
client = SimpleFormsApi::FormRemediation::S3Client.new(config:, id: <YOUR_SUBMISSION_ID>, type: :submission)
Expand Down
Loading