Module: HTTPHelper
- Defined in:
- lib/tabbyx/helpers/http_helper.rb
Class Method Summary collapse
- .get_response(requestUrl, params = nil, query = nil) ⇒ Object
- .post_response(requestUrl, params = nil, serviceRequest = nil, query = nil) ⇒ Object
- .response_code(response) ⇒ Object
- .response_data(response) ⇒ Object
Class Method Details
.get_response(requestUrl, params = nil, query = nil) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/tabbyx/helpers/http_helper.rb', line 31 def self.get_response(requestUrl, params=nil, query=nil) params ? request = requestUrl+'?'+params : request = requestUrl query ? q = query.to_hash : q = query response = HTTParty.get(request, :query => q, :headers => @header) response end |
.post_response(requestUrl, params = nil, serviceRequest = nil, query = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tabbyx/helpers/http_helper.rb', line 13 def self.post_response(requestUrl,params=nil,serviceRequest=nil,query=nil) @body = { :serviceRequest => serviceRequest } params ? request = requestUrl+'?'+params : request = requestUrl puts "TABBYX: 请求: " + request if serviceRequest.nil? response = HTTParty.post(request, :query => query, :headers => @header) else response = HTTParty.post(request, :body => @body, :headers => @header) end response end |
.response_code(response) ⇒ Object
38 39 40 |
# File 'lib/tabbyx/helpers/http_helper.rb', line 38 def self.response_code(response) response.code end |
.response_data(response) ⇒ Object
42 43 44 |
# File 'lib/tabbyx/helpers/http_helper.rb', line 42 def self.response_data(response) response["Data"] || response["data"] end |