require 'real_page/utils/array_fetcher' require_relative 'base' module RealPage module DocumentParser # Parse a Picklist response class Picklist < Base # @param soap_action [String] the action requested def initialize(soap_action) @soap_action = soap_action end private attr_reader :soap_action # @param body [Hash] the body of the XML response parsed # into a Hash # @return [Array] the pick list items # parsed from the response # @raise [RealPage::Error::Base] if the response is invalid def parse_body(body) Utils::ArrayFetcher.new( hash: items(body), key: 'PicklistItem', model: Model::PicklistItem ).fetch end def items(body) response_key = "#{soap_action.downcase}Response" result_key = "#{soap_action.downcase}Result" body[response_key][result_key][soap_action]['Contents'] end end end end