Skip to content

Commit

Permalink
[ARP - lower camel responses - 1] set_key_transform :camel_lower (#…
Browse files Browse the repository at this point in the history
…20621)

* [ARP] `set_key_transform :camel_lower`

* lint fixes

* [ARP - lower camel responses - 2] camel case POA form persistence (#20622)

* [ARP] camel case POA form persistence

* lint fixes

* [ARP - lower camel responses - 3] handle camel params in ARP IPF controller (#20623)

* [ARP] handle camel params in ARP IPF controller

* [ARP - lower camel responses - 4] camel response in ARP users controller (#20624)

* [ARP] camel response in ARP users controller

* [ARP - lower camel responses - 5] bypass olive branch (#20625)

* [ARP] bypass olive branch

* lint fixes
  • Loading branch information
nihil2501 authored and ojbucao committed Feb 11, 2025
1 parent 496408b commit a115a22
Show file tree
Hide file tree
Showing 14 changed files with 293 additions and 216 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class InProgressFormsController < ApplicationController
def update
form = find_form || build_form
form.update!(
form_data: params[:form_data],
form_data: params[:formData],
metadata: params[:metadata]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ def show
# serialization layer.
render json: {
account: {
account_uuid: @current_user.user_account_uuid
accountUuid: @current_user.user_account_uuid
},
profile: {
first_name: @current_user.first_name,
last_name: @current_user.last_name,
firstName: @current_user.first_name,
lastName: @current_user.last_name,
verified: @current_user.user_account.verified?,
sign_in: {
service_name: @current_user.sign_in[:service_name]
signIn: {
serviceName: @current_user.sign_in[:service_name]
}
},
prefills_available: [],
in_progress_forms:
prefillsAvailable: [],
inProgressForms: in_progress_forms
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def set_location
return unless address

self.claimant_city = address['city']
self.claimant_state_code = address['state_code']
self.claimant_zip_code = address['zip_code']
self.claimant_state_code = address['stateCode']
self.claimant_zip_code = address['zipCode']
end

def data_must_comply_with_schema
Expand Down Expand Up @@ -83,11 +83,11 @@ def data_must_comply_with_schema
"authorizations": {
"type": "object",
"properties": {
"record_disclosure": {
"recordDisclosure": {
"type": "boolean",
"example": true
},
"record_disclosure_limitations": {
"recordDisclosureLimitations": {
"type": "array",
"items": {
"type": "string",
Expand All @@ -105,15 +105,15 @@ def data_must_comply_with_schema
"SICKLE_CELL"
]
},
"address_change": {
"addressChange": {
"type": "boolean",
"example": false
}
},
"required": [
"record_disclosure",
"record_disclosure_limitations",
"address_change"
"recordDisclosure",
"recordDisclosureLimitations",
"addressChange"
]
},
"dependent": {
Expand Down Expand Up @@ -144,46 +144,46 @@ def data_must_comply_with_schema
"address": {
"type": "object",
"properties": {
"address_line1": {
"addressLine1": {
"type": "string",
"example": "123 Main St"
},
"address_line2": {
"addressLine2": {
"type": ["string", "null"],
"example": "Apt 1"
},
"city": {
"type": "string",
"example": "Springfield"
},
"state_code": {
"stateCode": {
"type": "string",
"example": "IL"
},
"country": {
"type": "string",
"example": "US"
},
"zip_code": {
"zipCode": {
"type": "string",
"example": "62704"
},
"zip_code_suffix": {
"zipCodeSuffix": {
"type": ["string", "null"],
"example": "6789"
}
},
"required": [
"address_line1",
"address_line2",
"addressLine1",
"addressLine2",
"city",
"state_code",
"stateCode",
"country",
"zip_code",
"zip_code_suffix"
"zipCode",
"zipCodeSuffix"
]
},
"date_of_birth": {
"dateOfBirth": {
"type": "string",
"format": "date",
"example": "1980-12-31"
Expand All @@ -204,7 +204,7 @@ def data_must_comply_with_schema
"required": [
"name",
"address",
"date_of_birth",
"dateOfBirth",
"relationship",
"phone",
"email"
Expand Down Expand Up @@ -238,63 +238,63 @@ def data_must_comply_with_schema
"address": {
"type": "object",
"properties": {
"address_line1": {
"addressLine1": {
"type": "string",
"example": "123 Main St"
},
"address_line2": {
"addressLine2": {
"type": ["string", "null"],
"example": "Apt 1"
},
"city": {
"type": "string",
"example": "Springfield"
},
"state_code": {
"stateCode": {
"type": "string",
"example": "IL"
},
"country": {
"type": "string",
"example": "US"
},
"zip_code": {
"zipCode": {
"type": "string",
"example": "62704"
},
"zip_code_suffix": {
"zipCodeSuffix": {
"type": ["string", "null"],
"example": "6789"
}
},
"required": [
"address_line1",
"address_line2",
"addressLine1",
"addressLine2",
"city",
"state_code",
"stateCode",
"country",
"zip_code",
"zip_code_suffix"
"zipCode",
"zipCodeSuffix"
]
},
"ssn": {
"type": "string",
"example": "123456789"
},
"va_file_number": {
"vaFileNumber": {
"type": ["string", "null"],
"example": "123456789"
},
"date_of_birth": {
"dateOfBirth": {
"type": "string",
"format": "date",
"example": "1980-12-31"
},
"service_number": {
"serviceNumber": {
"type": ["string", "null"],
"example": "123456789"
},
"service_branch": {
"serviceBranch": {
"type": ["string", "null"],
"enum": [
"ARMY",
Expand All @@ -321,10 +321,10 @@ def data_must_comply_with_schema
"name",
"address",
"ssn",
"va_file_number",
"date_of_birth",
"service_number",
"service_branch",
"vaFileNumber",
"dateOfBirth",
"serviceNumber",
"serviceBranch",
"phone",
"email"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module AccreditedRepresentativePortal
class ApplicationSerializer
include JSONAPI::Serializer

set_key_transform :camel_lower

# We're not building to JSONAPI.
def serializable_hash
data = super[:data]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

module AccreditedRepresentativePortal
##
# `olive_branch` transforms (a) request and (b) response payloads.
#
# (a) It deeply transforms request and query param keys.
# At times it is convenient for params to act as snake-cased setters at a Ruby
# interface, but not always. Form resources are a possible example where not.
#
# For now, let's wait to encounter the cases where we really want this
# convenience. If we do encounter some, we may discover that we want a more
# explicit and collocated way to opt in.
#
# (b) It reloads the response from JSON, deeply transforms keys, and dumps
# back to JSON.
# This is superfluous because our serialization layer `jsonapi-serializer`
# already has a configuration option for key casing. This realizes our desired
# casing the one and only time it is visiting an object during serialization.
#
module BypassOliveBranch
def call(env)
exclude_arp_route?(env) ? @app.call(env) : super
end

private

ARP_PATH_INFO_PREFIX = '/accredited_representative_portal'

def exclude_arp_route?(env)
env['PATH_INFO'].to_s.start_with?(ARP_PATH_INFO_PREFIX)
end
end
end

module OliveBranch
class Middleware
prepend AccreditedRepresentativePortal::BypassOliveBranch
end
end
Loading

0 comments on commit a115a22

Please sign in to comment.