Class: TicketEvolution::Search
- Defined in:
- lib/ticket_evolution/search.rb
Constant Summary
Constants included from Endpoint::RequestHandler
Endpoint::RequestHandler::CODES
Instance Method Summary collapse
Methods inherited from Endpoint
#base_path, #connection, #endpoint_name, #has_connection?, #id, #initialize, #method_missing
Methods included from SingularClass
Methods included from Endpoint::RequestHandler
#build_request, #collection_handler, #naturalize_response, #raw_handler, #request, #upload_history_handler
Methods inherited from Base
Constructor Details
This class inherits a constructor from TicketEvolution::Endpoint
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class TicketEvolution::Endpoint
Instance Method Details
#build_for_search(response) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ticket_evolution/search.rb', line 7 def build_for_search(response) collection = TicketEvolution::Collection.new( :total_entries => response.body['total_entries'], :per_page => response.body['per_page'], :current_page => response.body['current_page'] ) response.body['results'].each do |result| type = result['_type'] =~ /order|purchase/i ? "Order" : result['_type'] collection.entries << "TicketEvolution::#{type}". constantize.new(result.merge({:connection => connection})) end collection end |
#list(params = {}) ⇒ Object
3 4 5 |
# File 'lib/ticket_evolution/search.rb', line 3 def list(params = {}) request(:GET, nil, params, &method(:build_for_search)) end |