Class: TicketEvolution::Clients::Addresses

Inherits:
Endpoint show all
Includes:
Modules::Create, Modules::Destroy, Modules::List, Modules::Show, Modules::Update
Defined in:
lib/ticket_evolution/clients/addresses.rb

Constant Summary

Constants included from Endpoint::RequestHandler

Endpoint::RequestHandler::CODES

Instance Method Summary collapse

Methods included from Modules::Destroy

#build_for_destroy, #destroy, included

Methods included from Modules::Update

#build_for_update, included, #update

Methods included from Modules::Show

#build_for_show, #show

Methods included from Modules::List

#list, #raw

Methods included from Modules::Create

#build_for_create, #create

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

#check(id, params = nil, &handler) ⇒ Object



10
11
12
13
# File 'lib/ticket_evolution/clients/addresses.rb', line 10

def check(id, params=nil, &handler)
  handler ||= method(:check_handler)
  request(:GET, "/#{id}/check", params, &handler)
end

#check_fields(params = nil, &handler) ⇒ Object



23
24
25
26
27
# File 'lib/ticket_evolution/clients/addresses.rb', line 23

def check_fields(params=nil, &handler)
  handler ||= method(:check_fields_handler)
  params = { endpoint_name.to_sym => [params] } if params.present?
  request(:POST, "/check_fields", params, &handler)
end

#check_fields_handler(response) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/ticket_evolution/clients/addresses.rb', line 29

def check_fields_handler(response)
  singular_class.new(response.body.merge({
    :status_code => response.response_code,
    :server_message => response.server_message,
    :connection => response.body[:connection]
  }))
end

#check_handler(response) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/ticket_evolution/clients/addresses.rb', line 15

def check_handler(response)
  singular_class.new(response.body.merge({
    :status_code => response.response_code,
    :server_message => response.server_message,
    :connection => response.body[:connection]
  }))
end