Class: Inforouter::Responses::Folders

Inherits:
Base
  • Object
show all
Defined in:
lib/inforouter/responses/folders.rb

Overview

Returns the list of sub folders in the specified path in short form.

www.inforouter.com/web-services-80/default.aspx?op=GetFolders1

Instance Attribute Summary

Attributes inherited from Base

#raw

Class Method Summary collapse

Methods inherited from Base

error_message, #initialize, #match, parse_datetime, response_success, set_dsl

Constructor Details

This class inherits a constructor from Inforouter::Responses::Base

Class Method Details

.parse(savon_response) ⇒ Array<Inforouter::Folder>

Parse an infoRouter response.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/inforouter/responses/folders.rb', line 16

def parse(savon_response)
  response = new(savon_response)
  data = response.match('get_folders1_response/get_folders1_result/response')
  return [] if data[:@itemcount].to_i == 0
  # Single folder returned as a Hash.
  data[:f] = [data[:f]] if data[:f].is_a?(Hash)
  data[:f].map do |folder|
    Inforouter::Folder.new(
      id: folder[:@id].to_i,
      name: folder[:@n].strip
    )
  end
end