Class: Rest::BaseWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/rest/wrappers/base_wrapper.rb

Instance Method Summary collapse

Instance Method Details

#closeObject

if wrapper has a close/shutdown, override this



33
34
35
# File 'lib/rest/wrappers/base_wrapper.rb', line 33

def close

end

#post_file(url, req_hash = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rest/wrappers/base_wrapper.rb', line 5

def post_file(url, req_hash={})
  response = nil
  begin
    if req_hash[:body]
      req_hash = req_hash.merge(req_hash[:body])
      req_hash.delete(:body)
    end

    headers = {}
    if req_hash[:headers]
      headers = req_hash[:headers]
      req_hash.delete(:headers)
    end

    r2 = Rest::InternalClient.post(url, req_hash, headers)
    response = Rest::Wrappers::InternalClientResponseWrapper.new(r2)
  rescue Rest::InternalClient::Exception => ex
    raise Rest::Wrappers::InternalClientExceptionWrapper.new(ex)
  end
  response
end

#to_json_parts(h) ⇒ Object

if body is a hash, it will convert it to json



28
29
30
# File 'lib/rest/wrappers/base_wrapper.rb', line 28

def to_json_parts(h)
  h[:body] = h[:body].to_json if h[:body] && h[:body].is_a?(Hash)
end