-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ART] Serialize POA form data with POA request
- Loading branch information
Showing
14 changed files
with
492 additions
and
120 deletions.
There are no files selected for viewing
This file contains 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 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 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
25 changes: 25 additions & 0 deletions
25
...ntative_portal/app/serializers/accredited_representative_portal/application_serializer.rb
This file contains 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,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module AccreditedRepresentativePortal | ||
class ApplicationSerializer | ||
include JSONAPI::Serializer | ||
|
||
# We're not building to JSONAPI. | ||
def serializable_hash | ||
data = super[:data] | ||
|
||
case data | ||
when Array | ||
data.map(&method(:unwrap_serializable_hash)) | ||
when Hash | ||
unwrap_serializable_hash(data) | ||
end | ||
end | ||
|
||
private | ||
|
||
def unwrap_serializable_hash(data) | ||
data[:attributes].merge!(id: data[:id]) | ||
end | ||
end | ||
end |
22 changes: 0 additions & 22 deletions
22
...alizers/accredited_representative_portal/power_of_attorney_request_decision_serializer.rb
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
...izers/accredited_representative_portal/power_of_attorney_request_expiration_serializer.rb
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
...izers/accredited_representative_portal/power_of_attorney_request_resolution_serializer.rb
This file was deleted.
Oops, something went wrong.
16 changes: 10 additions & 6 deletions
16
.../app/serializers/accredited_representative_portal/power_of_attorney_request_serializer.rb
This file contains 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 |
---|---|---|
@@ -1,23 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module AccreditedRepresentativePortal | ||
class PowerOfAttorneyRequestSerializer | ||
include JSONAPI::Serializer | ||
class PowerOfAttorneyRequestSerializer < ApplicationSerializer | ||
attributes :claimant_id, :claimant_type, :created_at | ||
|
||
attributes :claimant_id, :created_at | ||
attribute :power_of_attorney_form do |poa_request| | ||
poa_request.power_of_attorney_form.parsed_data | ||
end | ||
|
||
attribute :resolution do |poa_request| | ||
next unless poa_request.resolution | ||
|
||
serializer = | ||
case poa_request.resolution.resolving | ||
when PowerOfAttorneyRequestDecision | ||
PowerOfAttorneyRequestDecisionSerializer | ||
DecisionSerializer | ||
when PowerOfAttorneyRequestExpiration | ||
PowerOfAttorneyRequestExpirationSerializer | ||
ExpirationSerializer | ||
end | ||
|
||
serializer.new(poa_request.resolution) | ||
serializer | ||
.new(poa_request.resolution) | ||
.serializable_hash | ||
end | ||
end | ||
end |
26 changes: 26 additions & 0 deletions
26
...redited_representative_portal/power_of_attorney_request_serializer/decision_serializer.rb
This file contains 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,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module AccreditedRepresentativePortal | ||
class PowerOfAttorneyRequestSerializer | ||
class DecisionSerializer < ResolutionSerializer | ||
attribute(:type) { 'decision' } | ||
|
||
attribute :decision_type do |resolution| | ||
case resolution.resolving.type | ||
when PowerOfAttorneyRequestDecision::Types::ACCEPTANCE | ||
'acceptance' | ||
when PowerOfAttorneyRequestDecision::Types::DECLINATION | ||
'declination' | ||
end | ||
end | ||
|
||
attribute :reason, if: proc { |resolution| | ||
resolution.resolving.type == PowerOfAttorneyRequestDecision::Types::DECLINATION | ||
} | ||
|
||
attribute :creator_id do |resolution| | ||
resolution.resolving.creator_id | ||
end | ||
end | ||
end | ||
end |
9 changes: 9 additions & 0 deletions
9
...dited_representative_portal/power_of_attorney_request_serializer/expiration_serializer.rb
This file contains 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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
module AccreditedRepresentativePortal | ||
class PowerOfAttorneyRequestSerializer | ||
class ExpirationSerializer < ResolutionSerializer | ||
attribute(:type) { 'expiration' } | ||
end | ||
end | ||
end |
9 changes: 9 additions & 0 deletions
9
...dited_representative_portal/power_of_attorney_request_serializer/resolution_serializer.rb
This file contains 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,9 @@ | ||
# frozen_string_literal: true | ||
|
||
module AccreditedRepresentativePortal | ||
class PowerOfAttorneyRequestSerializer | ||
class ResolutionSerializer < ApplicationSerializer | ||
attributes :created_at | ||
end | ||
end | ||
end |
58 changes: 54 additions & 4 deletions
58
modules/accredited_representative_portal/spec/factories/power_of_attorney_form.rb
This file contains 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 |
---|---|---|
@@ -1,10 +1,60 @@ | ||
# frozen_string_literal: true | ||
|
||
form_data = <<~JSON | ||
{ | ||
"authorizations": { | ||
"record_disclosure": true, | ||
"record_disclosure_limitations": [], | ||
"address_change": true | ||
}, | ||
"dependent": { | ||
"name": { | ||
"first": "John", | ||
"middle": "Middle", | ||
"last": "Doe" | ||
}, | ||
"address": { | ||
"address_line1": "123 Main St", | ||
"address_line2": "Apt 1", | ||
"city": "Springfield", | ||
"state_code": "IL", | ||
"country": "US", | ||
"zip_code": "62704", | ||
"zip_code_suffix": "6789" | ||
}, | ||
"date_of_birth": "1980-12-31", | ||
"relationship": "Spouse", | ||
"phone": "1234567890", | ||
"email": "[email protected]" | ||
}, | ||
"veteran": { | ||
"name": { | ||
"first": "John", | ||
"middle": "Middle", | ||
"last": "Doe" | ||
}, | ||
"address": { | ||
"address_line1": "123 Main St", | ||
"address_line2": "Apt 1", | ||
"city": "Springfield", | ||
"state_code": "IL", | ||
"country": "US", | ||
"zip_code": "62704", | ||
"zip_code_suffix": "6789" | ||
}, | ||
"ssn": "123456789", | ||
"va_file_number": "123456789", | ||
"date_of_birth": "1980-12-31", | ||
"service_number": "123456789", | ||
"service_branch": "ARMY", | ||
"phone": "1234567890", | ||
"email": "[email protected]" | ||
} | ||
} | ||
JSON | ||
|
||
FactoryBot.define do | ||
factory :power_of_attorney_form, class: 'AccreditedRepresentativePortal::PowerOfAttorneyForm' do | ||
data_ciphertext { 'Test encrypted data' } | ||
city_bidx { Faker::Alphanumeric.alphanumeric(number: 44) } | ||
state_bidx { Faker::Alphanumeric.alphanumeric(number: 44) } | ||
zipcode_bidx { Faker::Alphanumeric.alphanumeric(number: 44) } | ||
data { form_data } | ||
end | ||
end |
This file contains 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.