Class: NetSuite::Support::SearchResult
- Inherits:
-
Object
- Object
- NetSuite::Support::SearchResult
- Defined in:
- lib/netsuite/support/search_result.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
-
#total_records ⇒ Object
readonly
Returns the value of attribute total_records.
Instance Method Summary collapse
- #all_pages ⇒ Object
-
#initialize(response, result_class) ⇒ SearchResult
constructor
<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>.
- #next_page ⇒ Object
- #results ⇒ Object
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
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/netsuite/support/search_result.rb', line 4 def response @response end |
#total_records ⇒ Object (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_pages ⇒ Object
61 62 63 |
# File 'lib/netsuite/support/search_result.rb', line 61 def all_pages end |
#next_page ⇒ Object
57 58 59 |
# File 'lib/netsuite/support/search_result.rb', line 57 def next_page end |
#results ⇒ Object
53 54 55 |
# File 'lib/netsuite/support/search_result.rb', line 53 def results @results ||= [] end |