Skip to content

Commit

Permalink
Add endpoint for EVSS (#4370)
Browse files Browse the repository at this point in the history
* try out evss intakesite endpoint

* clean up unused code

* wip

* swagger specs

* rename intake_sites to separation_locations

* remove temp url string

* fixed pluralization

* fix spec

* document 403
  • Loading branch information
annaswims authored Jun 15, 2020
1 parent 7fa0186 commit 671a0b6
Show file tree
Hide file tree
Showing 25 changed files with 1,356 additions and 338 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ group :development do
gem 'benchmark-ips'
gem 'guard-rubocop'
gem 'seedbank'
gem 'socksify'
gem 'spring', platforms: :ruby # Spring speeds up development by keeping your application running in the background
gem 'spring-commands-rspec'

Expand Down
1 change: 0 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,6 @@ DEPENDENCIES
sidekiq-pro!
sidekiq-scheduler (~> 3.0)
simplecov (< 0.18)
socksify
spring
spring-commands-rspec
staccato
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v0/apidocs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ class ApidocsController < ApplicationController
Swagger::Schemas::ConnectedApplications,
Swagger::Schemas::Dependents,
Swagger::Schemas::DismissedStatus,
Swagger::Schemas::Form526::RatedDisabilities,
Swagger::Schemas::Email,
Swagger::Schemas::Errors,
Swagger::Schemas::EVSSAuthError,
Expand All @@ -184,6 +183,7 @@ class ApidocsController < ApplicationController
Swagger::Schemas::Form526::Form4142,
Swagger::Schemas::Form526::Form526SubmitV2,
Swagger::Schemas::Form526::Form8940,
Swagger::Schemas::Form526::SeparationLocations,
Swagger::Schemas::Form526::JobStatus,
Swagger::Schemas::Form526::RatedDisabilities,
Swagger::Schemas::Form526::SubmitDisabilityForm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ def rated_disabilities
serializer: RatedDisabilitiesSerializer
end

def separation_locations
response = EVSS::ReferenceData::Service.new(@current_user).get_separation_locations
render json: response, each_serializer: EVSSSeparationLocationSerializer
end

def suggested_conditions
results = DisabilityContention.suggested(params[:name_part])
render json: results, each_serializer: DisabilityContentionSerializer
Expand Down
5 changes: 5 additions & 0 deletions app/serializers/evss_separation_location_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

class EVSSSeparationLocationSerializer < ActiveModel::Serializer
attribute :separation_locations
end
27 changes: 27 additions & 0 deletions app/swagger/requests/disability_compensation_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,33 @@ class DisabilityCompensationForm
end
end
end

swagger_path '/v0/disability_compensation_form/separation_locations' do
operation :get do
extend Swagger::Responses::AuthenticationError

key :description, 'Get the separation locations from EVSS'
key :operationId, 'getIntakeSites'
key :tags, %w[form_526]

parameter :authorization

response 200 do
key :description, 'Response is OK'
schema do
key :'$ref', :SeparationLocations
end
end

response 403 do
key :description, 'forbidden user'

schema do
key :'$ref', :Errors
end
end
end
end
end
end
end
22 changes: 22 additions & 0 deletions app/swagger/schemas/form526/separation_locations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module Swagger
module Schemas
module Form526
class SeparationLocations
include Swagger::Blocks
swagger_schema :SeparationLocations do
key :required, [:separation_locations]

property :separation_locations, type: :array do
items do
key :required, %i[code description]
property :code, type: :string, example: '98283'
property :description, type: :string, example: 'AF Academy'
end
end
end
end
end
end
end
21 changes: 0 additions & 21 deletions config/initializers/faraday_socks.rb

This file was deleted.

1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
post 'submit_all_claim'
get 'suggested_conditions'
get 'user_submissions'
get 'separation_locations'
end

resource :upload_supporting_evidence, only: :create
Expand Down
8 changes: 1 addition & 7 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ evss:
mock_pciu: true
mock_pciu_address: false
mock_ppiu: true
mock_reference: false
mock_itf: true
mock_disabilities_form: true
mock_common_service: true
Expand All @@ -194,9 +195,6 @@ evss:
cert_path: ~
key_path: ~
root_ca: ~
jwt:
issuer: fake_issuer
key: fake_key
reference_data_service:
enabled: false
international_postal_codes: 'config/evss/international_postal_codes.json'
Expand Down Expand Up @@ -444,10 +442,6 @@ betamocks:
cache_dir: /cache
services_config: config/betamocks/services_config.yml

faraday_socks_proxy:
enabled: false
uri: socks5://localhost:2002

google_analytics_tracking_id: ~

# Settings for search
Expand Down
45 changes: 0 additions & 45 deletions lib/evss/aws_configuration.rb

This file was deleted.

45 changes: 0 additions & 45 deletions lib/evss/jwt.rb

This file was deleted.

8 changes: 4 additions & 4 deletions lib/evss/reference_data/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ module ReferenceData
# HTTP client configuration for the {ReferenceData::Service} to
# set the base path and a service name for breakers and metrics
#
class Configuration < EVSS::AWSConfiguration
class Configuration < EVSS::Configuration
##
# @return [String] Base path for ReferenceData URLs.
#
def base_path
Settings.evss.aws.url.to_s
"#{Settings.evss.url}/wss-referencedata-services-web/rest/referencedata/v1"
end

##
# @return [String] Service name to use in breakers and metrics.
#
def service_name
'EVSS/AWS/ReferenceData'
'EVSS/ReferenceData'
end

##
# @return [Boolean] Should the service use mock data in lower environments.
#
def mock_enabled?
# TODO: create mock data
false
Settings.evss.mock_reference || false
end
end
end
Expand Down
25 changes: 25 additions & 0 deletions lib/evss/reference_data/intake_sites_response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require 'evss/response'

module EVSS
module ReferenceData
##
# Model for Intake Sites returned by reference_datea
#
# @param status [Integer] The HTTP status code
# @param response [Hash] The API response
#
# @!attribute countries
# @return [Array[String]] An array of intake sites
#
class IntakeSitesResponse < EVSS::Response
attribute :separation_locations, Array[Hash]

def initialize(status, response = nil)
separation_locations = response&.body&.dig('intake_sites')
super(status, separation_locations: separation_locations)
end
end
end
end
14 changes: 5 additions & 9 deletions lib/evss/reference_data/service.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'evss/jwt'

module EVSS
module ReferenceData
class Service < EVSS::Service
Expand Down Expand Up @@ -31,13 +29,11 @@ def get_states
end
end

private

# overrides EVSS::Service#headers_for_user
def headers_for_user(user)
{
Authorization: "Bearer #{EVSS::Jwt.new(user).encode}"
}
def get_separation_locations
with_monitoring_and_error_handling do
raw_response = perform(:get, 'intakesites')
EVSS::ReferenceData::IntakeSitesResponse.new(raw_response.status, raw_response)
end
end
end
end
Expand Down
11 changes: 0 additions & 11 deletions spec/lib/evss/aws_configuration_spec.rb

This file was deleted.

Loading

0 comments on commit 671a0b6

Please sign in to comment.