lib/ticket_evolution/core/endpoint/request_handler.rb
# Response Code Mappings From TicketEvolution API
Response Code Mappings From TicketEvolution API
Response Code Mappings From TicketEvolution API
def request(method, path, params = nil, &response_handler)
        params = params.to_ordered_hash if params.is_a?(Hash)
        redirecting = caller.first =~ /request_handler/ ? false : true
        request = self.build_request(method, path, params, redirecting)
        if TicketEvolution::TestResponse.connection_in_test_mode(parent)
          response = TicketEvolution::TestResponse.new(path, request.url_prefix.to_s, self.connection.url)
          response = self.naturalize_response(response)
        else
          response = self.naturalize_response do
            method = method.to_s.downcase.to_sym
            if method == :get
              request.send(method)
            else
              request.send(method) do |req|
                req.body = MultiJson.encode(params) if params.present?
              end
            end
          end
        end
        if [301, 302].include?(response.response_code)
          new_path = response.header['location'].match(/^https?:\/\/[a-zA-Z_]+[\.a-zA-Z_]+(\/[\w\/]+)[\?]*/).to_a[1]
          self.request(method, new_path, params, &response_handler)
        elsif response.response_code >= 300
          TicketEvolution::ApiError.new(response)
        else
          response_handler.call(response)
        end
      end
def request ( method , path , params = nil , & response_handler ) params = params . to_ordered_hash if params . is_a? ( Hash ) redirecting = caller . first =~ / request_handler / ? false : true request = self . build_request ( method , path , params , redirecting ) if TicketEvolution :: TestResponse . connection_in_test_mode ( parent ) response = TicketEvolution :: TestResponse . new ( path , request . url_prefix . to_s , self . connection . url ) response = self . naturalize_response ( response ) else response = self . naturalize_response do method = method . to_s . downcase . to_sym if method == :get request . send ( method ) else request . send ( method ) do | req | req . body = MultiJson . encode ( params ) if params . present? end end end end if [ 301 , 302 ] . include? ( response . response_code ) new_path = response . header [ 'location' ] . match ( / ^https?: \/ \/ [a-zA-Z_]+[ \. a-zA-Z_]+( \/ [ \w \/ ]+)[ \? ]* / ) . to_a [ 1 ] self . request ( method , new_path , params , & response_handler ) elsif response . response_code >= 300 TicketEvolution :: ApiError . new ( response ) else response_handler . call ( response ) end end
Response Code Mappings From TicketEvolution API
Response Code Mappings From TicketEvolution API
method
<not_specific>
path
<not_specific>
params
<not_specific>
response_handler
<not_specific>