Module: RazorRisk::Cassini::Applications::RouteVerbAdaptors::Utilities::Portfolios
- Includes:
- Razor::Connectivity::Search::Parsers
- Included in:
- Portfolios::CollectionGet, Portfolios::HierarchyGet, Portfolios::ItemPost, Portfolios::ItemPut
- Defined in:
- lib/razor_risk/cassini/applications/route_verb_adaptors/utilities/portfolios.rb
Overview
########################################################################## classes
Instance Method Summary collapse
Instance Method Details
#validate_request_body(rq_body, **options) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/razor_risk/cassini/applications/route_verb_adaptors/utilities/portfolios.rb', line 35 def validate_request_body rq_body, ** check_parameter rq_body, 'rq_body', types: [ ::Nokogiri::XML::Document, ::Nokogiri::XML::Element ] require_id = [:require_id] case rq_body.children.count when 0 halt 400, {'Content-Type' => 'text/plain'}, 'not a valid body' when 1 x_portfolio = rq_body.at_xpath('./portfolios/portfolio') x_portfolio ||= rq_body.at_xpath('./portfolio') unless x_portfolio halt 422, {'Content-Type' => 'text/plain'}, 'given request does not appear to contain a valid portfolio definition' end if require_id porf_id = x_portfolio['id'].to_i unless porf_id > 0 halt 422, {'Content-Type' => 'text/plain'}, 'given request does not appear to contain a valid portfolio definition' end end return rq_body else halt 400, {'Content-Type' => 'text/plain'}, 'too many children' end end |