Class: Rest::Wrappers::InternalClientWrapper
- Inherits:
-
BaseWrapper
- Object
- BaseWrapper
- Rest::Wrappers::InternalClientWrapper
- Defined in:
- lib/rest/wrappers/internal_client_wrapper.rb
Instance Method Summary collapse
- #default_headers ⇒ Object
- #delete(url, req_hash = {}) ⇒ Object
- #get(url, req_hash = {}) ⇒ Object
- #patch(url, req_hash = {}) ⇒ Object
- #post(url, req_hash = {}) ⇒ Object
- #put(url, req_hash = {}) ⇒ Object
Methods inherited from BaseWrapper
#close, #post_file, #to_json_parts
Instance Method Details
#default_headers ⇒ Object
36 37 38 |
# File 'lib/rest/wrappers/internal_client_wrapper.rb', line 36 def default_headers {} end |
#delete(url, req_hash = {}) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/rest/wrappers/internal_client_wrapper.rb', line 109 def delete(url, req_hash={}) response = nil begin req_hash[:method] = :delete req_hash[:url] = url req_hash[:payload] = req_hash[:body] if req_hash[:body] r2 = Rest::InternalClient::Request.execute(req_hash) response = InternalClientResponseWrapper.new(r2) # todo: make generic exception rescue Rest::InternalClient::Exception => ex raise InternalClientExceptionWrapper.new(ex) end response end |
#get(url, req_hash = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rest/wrappers/internal_client_wrapper.rb', line 40 def get(url, req_hash={}) response = nil begin req_hash[:method] = :get req_hash[:url] = url req_hash[:headers] ||= default_headers req_hash[:headers][:params] = req_hash[:params] if req_hash[:params] #p req_hash r2 = Rest::InternalClient::Request.execute(req_hash) response = InternalClientResponseWrapper.new(r2) rescue Rest::InternalClient::Exception => ex #p ex #if ex.http_code == 404 # return InternalClientResponseWrapper.new(ex.response) #end raise InternalClientExceptionWrapper.new(ex) end response end |
#patch(url, req_hash = {}) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/rest/wrappers/internal_client_wrapper.rb', line 94 def patch(url, req_hash={}) response = nil begin req_hash[:method] = :patch req_hash[:url] = url req_hash[:payload] = req_hash[:body] if req_hash[:body] r2 = Rest::InternalClient::Request.execute(req_hash) response = InternalClientResponseWrapper.new(r2) rescue Rest::InternalClient::Exception => ex raise InternalClientExceptionWrapper.new(ex) end response end |
#post(url, req_hash = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rest/wrappers/internal_client_wrapper.rb', line 60 def post(url, req_hash={}) response = nil begin req_hash[:method] = :post req_hash[:url] = url b = req_hash[:body] if b if b.is_a?(Hash) b = b.to_json end req_hash[:payload] = b end r2 = Rest::InternalClient::Request.execute(req_hash) response = InternalClientResponseWrapper.new(r2) rescue Rest::InternalClient::Exception => ex raise InternalClientExceptionWrapper.new(ex) end response end |
#put(url, req_hash = {}) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/rest/wrappers/internal_client_wrapper.rb', line 80 def put(url, req_hash={}) response = nil begin req_hash[:method] = :put req_hash[:url] = url req_hash[:payload] = req_hash[:body] if req_hash[:body] r2 = Rest::InternalClient::Request.execute(req_hash) response = InternalClientResponseWrapper.new(r2) rescue Rest::InternalClient::Exception => ex raise InternalClientExceptionWrapper.new(ex) end response end |