Class: TicketEvolution::Quotes

Inherits:
Endpoint show all
Includes:
Modules::Create, Modules::List, Modules::Search, Modules::Show, Modules::Update
Defined in:
lib/ticket_evolution/quotes.rb

Constant Summary

Constants included from Endpoint::RequestHandler

Endpoint::RequestHandler::CODES

Instance Method Summary collapse

Methods included from Modules::Update

#build_for_update, included, #update

Methods included from Modules::Create

#build_for_create, #create

Methods included from Modules::Show

#build_for_show, #show

Methods included from Modules::Search

#search

Methods included from Modules::List

#list, #raw

Methods inherited from Endpoint

#base_path, #connection, #endpoint_name, #has_connection?, #id, #initialize, #method_missing

Methods included from SingularClass

#singular_class

Methods included from Endpoint::RequestHandler

#build_request, #collection_handler, #naturalize_response, #raw_handler, #request, #upload_history_handler

Methods inherited from Base

#method_missing

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

#autocomplete(params = {}) ⇒ Object



9
10
11
# File 'lib/ticket_evolution/quotes.rb', line 9

def autocomplete(params = {})
  request(:GET, "/autocomplete", params, &method(:build_for_search))
end

#build_for_search(response) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ticket_evolution/quotes.rb', line 24

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|
    collection.entries << result
  end

  collection
end

#resendObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/ticket_evolution/quotes.rb', line 13

def resend
  ensure_id
  request(:GET, "/resend", nil) do |response|
    singular_class.new(response.body.merge({
      :status_code => response.response_code,
      :server_message => response.server_message,
      :connection => response.body[:connection]
    }))
  end
end