class Yardi::DocumentParser::GuestCardImportResponseObject
Parse the GetFloorPlanList response
Constants
- SOAP_ACTION
Attributes
body[R]
Private Instance Methods
message_nodes()
click to toggle source
If there is only one message, we get a hash, otherwise we get an array of messages. Wrap everything to be an Array so we can use the same logic for finding and parsing out error messages. Successful agent info responses do not include a messages node, but successful guestcard responses use the messages section to include their CustomerID and to tell us that the guestcard was imported.
# File lib/yardi/document_parser/guest_card_import_response_object.rb, line 28 def message_nodes Array(result_node['Messages']['Message']) end
messages()
click to toggle source
Convert from this: [
{ "messageType"=>"FYI", "__content__"=>"Xml Imported: 6/27/2016 8:12:19 PM" }, { "messageType"=>"FYI", "__content__"=>"Inserted Prospect CustomerID: p0123456789" }
] to this: [
{ 'FYI' => 'Xml Imported: 6/27/2016 8:12:19 PM' }, { 'FYI' => 'Inserted Prospect CustomerID: p0123456789' }
]
# File lib/yardi/document_parser/guest_card_import_response_object.rb, line 48 def messages message_array = [] message_nodes.each do |node| message_array << { node['messageType'] => node['__content__'] } end message_array end
parse_body(body)
click to toggle source
@param body [Hash<String, Object>] the body of the XML response parsed
into a Hash
@return [Yardi::Model::GuestcardResponse] @raise [Yardi::Error::Base] if the response is invalid
# File lib/yardi/document_parser/guest_card_import_response_object.rb, line 17 def parse_body(body) @body = body Model::GuestCardResponse.new(messages: messages, remote_id: remote_id) end
remote_id()
click to toggle source
# File lib/yardi/document_parser/guest_card_import_response_object.rb, line 57 def remote_id id_message = message_nodes.detect do |node| node['messageType'].downcase == 'fyi' && node['__content__'] =~ /(Inserted|Updated) Prospect CustomerID:/ end unless id_message.nil? id_regex = /(Inserted|Updated) Prospect CustomerID: (?<remote_id>p\d+)/ id_match = id_message['__content__'].match(id_regex) !id_match.nil? ? id_match[:remote_id] : nil end end