-
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.
Merge branch 'master' into add-extra-date-stamp-for-4142
- Loading branch information
Showing
26 changed files
with
713 additions
and
59 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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
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
65 changes: 65 additions & 0 deletions
65
...n_management/app/controllers/representation_management/v0/power_of_attorney_controller.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,65 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'lighthouse/benefits_claims/service' | ||
|
||
module RepresentationManagement | ||
module V0 | ||
class PowerOfAttorneyController < ApplicationController | ||
service_tag 'representation-management' | ||
|
||
def index | ||
@active_poa = lighthouse_service.get_power_of_attorney | ||
|
||
if @active_poa.blank? || record.blank? | ||
render json: { data: {} }, status: :ok | ||
else | ||
render json: record, serializer:, status: :ok | ||
end | ||
end | ||
|
||
private | ||
|
||
def lighthouse_service | ||
BenefitsClaims::Service.new(icn) | ||
end | ||
|
||
def icn | ||
@current_user&.icn | ||
end | ||
|
||
def poa_code | ||
@poa_code ||= @active_poa.dig('data', 'attributes', 'code') | ||
end | ||
|
||
def poa_type | ||
@poa_type ||= @active_poa.dig('data', 'type') | ||
end | ||
|
||
def record | ||
return @record if defined? @record | ||
|
||
@record ||= if poa_type == 'organization' | ||
organization | ||
else | ||
representative | ||
end | ||
end | ||
|
||
def serializer | ||
if poa_type == 'organization' | ||
RepresentationManagement::PowerOfAttorney::OrganizationSerializer | ||
else | ||
RepresentationManagement::PowerOfAttorney::RepresentativeSerializer | ||
end | ||
end | ||
|
||
def organization | ||
Veteran::Service::Organization.find_by(poa: poa_code) | ||
end | ||
|
||
def representative | ||
Veteran::Service::Representative.where('? = ANY(poa_codes)', poa_code).order(created_at: :desc).first | ||
end | ||
end | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
...management/app/serializers/representation_management/power_of_attorney/base_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,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module RepresentationManagement | ||
module PowerOfAttorney | ||
class BaseSerializer < ActiveModel::Serializer | ||
attribute :address_line1 | ||
attribute :address_line2 | ||
attribute :address_line3 | ||
attribute :address_type | ||
attribute :city | ||
attribute :country_name | ||
attribute :country_code_iso3 | ||
attribute :province | ||
attribute :international_postal_code | ||
attribute :state_code | ||
attribute :zip_code | ||
attribute :zip_suffix | ||
attribute :phone | ||
end | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
...nt/app/serializers/representation_management/power_of_attorney/organization_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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module RepresentationManagement | ||
module PowerOfAttorney | ||
class OrganizationSerializer < BaseSerializer | ||
attribute :type | ||
attribute :name | ||
|
||
def type | ||
'organization' | ||
end | ||
end | ||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
.../app/serializers/representation_management/power_of_attorney/representative_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,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module RepresentationManagement | ||
module PowerOfAttorney | ||
class RepresentativeSerializer < BaseSerializer | ||
attribute :type | ||
attribute :name | ||
attribute :email | ||
|
||
def type | ||
'representative' | ||
end | ||
|
||
def name | ||
object.full_name | ||
end | ||
|
||
def phone | ||
object.phone_number | ||
end | ||
end | ||
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.