-
Notifications
You must be signed in to change notification settings - Fork 94
FDF 133550 forms service class separation #27391
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 0 additions & 77 deletions
77
modules/digital_forms_api/lib/digital_forms_api/service/forms.rb
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
modules/digital_forms_api/lib/digital_forms_api/service/schemas.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'digital_forms_api/service/base' | ||
|
|
||
| module DigitalFormsApi | ||
| module Service | ||
| # Schemas API | ||
| class Schemas < Base | ||
| # Cache TTL values for form schemas | ||
| CACHE_TTL = (Settings.digital_forms_api.cache_ttl.schema.to_i || 5).minutes | ||
|
|
||
| # Build the cache key for a given form template. | ||
| def self.cache_key(form_id) | ||
| "digital_forms_api:schema:#{form_id}" | ||
| end | ||
|
|
||
| # @see #schema | ||
| def self.get(form_id) | ||
| new.schema(form_id) | ||
| end | ||
|
|
||
| # GET a form schema (with caching) | ||
| # Caches only the parsed response body to avoid persisting sensitive | ||
| # request metadata (e.g., Authorization headers) from the Faraday::Env. | ||
| def schema(form_id) | ||
| cache_key = self.class.cache_key(form_id) | ||
|
|
||
| # @see DigitalFormsApi::Service::Base#context | ||
| tags = { form_id: } | ||
| @context = tags.merge(tags:) | ||
|
|
||
| Rails.cache.fetch(cache_key, expires_in: CACHE_TTL, race_condition_ttl: 10.seconds) do | ||
| perform(:get, "forms/#{form_id}/schema", {}, {}).body | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| # @see DigitalFormsApi::Service::Base#endpoint | ||
| def endpoint | ||
| 'schemas' | ||
| end | ||
|
|
||
| # end Schemas | ||
| end | ||
|
|
||
| # end Service | ||
| end | ||
|
|
||
| # end DigitalFormsApi | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
modules/digital_forms_api/lib/digital_forms_api/service/templates.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'digital_forms_api/service/base' | ||
|
|
||
| module DigitalFormsApi | ||
| module Service | ||
| # Templates API | ||
| class Templates < Base | ||
| # Cache TTL values for form templates | ||
| CACHE_TTL = (Settings.digital_forms_api.cache_ttl.template.to_i || 5).minutes | ||
|
|
||
| # Build the cache key for a given form template. | ||
| def self.cache_key(form_id) | ||
| "digital_forms_api:template:#{form_id}" | ||
| end | ||
|
|
||
| # @see #template | ||
| def self.get(form_id) | ||
| new.template(form_id) | ||
| end | ||
|
|
||
| # GET a form template (with caching) | ||
| # Caches only the parsed response body to avoid persisting sensitive | ||
| # request metadata (e.g., Authorization headers) from the Faraday::Env. | ||
| def template(form_id) | ||
| cache_key = self.class.cache_key(form_id) | ||
|
|
||
| # @see DigitalFormsApi::Service::Base#context | ||
| tags = { form_id: } | ||
| @context = tags.merge(tags:) | ||
|
|
||
| Rails.cache.fetch(cache_key, expires_in: CACHE_TTL, race_condition_ttl: 10.seconds) do | ||
| perform(:get, "forms/#{form_id}/template", {}, {}).body | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| # @see DigitalFormsApi::Service::Base#endpoint | ||
| def endpoint | ||
| 'templates' | ||
| end | ||
|
|
||
| # end Templates | ||
| end | ||
|
|
||
| # end Service | ||
| end | ||
|
|
||
| # end DigitalFormsApi | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any additional errors are captured by ApplicationsController, so this is unneeded
app/controllers/application_controller.rb
app/controllers/concerns/exception_handling.rb