Class: NetSuite::Support::SearchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/netsuite/support/search_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, result_class) ⇒ SearchResult

<platformCore:searchResult xmlns:platformCore=“urn:core_2012_1.platform.webservices.netsuite.com”>

<platformCore:status isSuccess="true"/>
<platformCore:totalRecords>2770</platformCore:totalRecords>
<platformCore:pageSize>5</platformCore:pageSize>
<platformCore:totalPages>554</platformCore:totalPages>
<platformCore:pageIndex>1</platformCore:pageIndex>
<platformCore:searchId>WEBSERVICES_738944_SB2_03012013650784545962753432_28d96bd280</platformCore:searchId>


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/netsuite/support/search_result.rb', line 17

def initialize(response, result_class)
  @response = response
  @total_records = response.body[:total_records].to_i

  if @total_records > 0
    if @total_records == 1
      [response.body[:record_list][:record]]
    else
      response.body[:record_list][:record]
    end.each do |record|
      results << result_class.new(record)
    end
  end

  # search_results = []

  # if !!response.body[:search_row_list] && !response.body[:search_row_list].empty?
  #   response.body[:search_row_list][:search_row].each do |record|
  #     search_result = NetSuite::Support::SearchResult.new(record)

  #     search_results << search_result
  #   end
  # end

  # search_id = response.header[:ns_id]
  # page_index = response.body[:page_index]
  # total_pages = response.body[:total_pages]

  # response_hash[:search_id] = search_id
  # response_hash[:page_index] = page_index
  # response_hash[:total_pages] = total_pages
  # response_hash[:search_results] = search_results
  # puts response.body
  # response_hash
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



4
5
6
# File 'lib/netsuite/support/search_result.rb', line 4

def response
  @response
end

#total_recordsObject (readonly)

Returns the value of attribute total_records.



5
6
7
# File 'lib/netsuite/support/search_result.rb', line 5

def total_records
  @total_records
end

Instance Method Details

#all_pagesObject



61
62
63
# File 'lib/netsuite/support/search_result.rb', line 61

def all_pages
  
end

#next_pageObject



57
58
59
# File 'lib/netsuite/support/search_result.rb', line 57

def next_page
  
end

#resultsObject



53
54
55
# File 'lib/netsuite/support/search_result.rb', line 53

def results
  @results ||= []
end