Module: Gorillapi::CurlBuilder

Included in:
RequestBuilder
Defined in:
lib/gorillapi/curl_builder.rb

Instance Method Summary collapse

Instance Method Details

#acceptObject



14
15
16
# File 'lib/gorillapi/curl_builder.rb', line 14

def accept
  "-H \"Accept: #{accept_header}\""
end

#add_paramsObject



22
23
24
# File 'lib/gorillapi/curl_builder.rb', line 22

def add_params
  "-d '#{params.to_json}'" unless params.nil? || params.empty? || params == ''
end

#authorizationObject



10
11
12
# File 'lib/gorillapi/curl_builder.rb', line 10

def authorization
  "-H \"AUTHORIZATION: #{token}\""
end

#content_headerObject



18
19
20
# File 'lib/gorillapi/curl_builder.rb', line 18

def content_header
  "-H \"Content-Type: #{content_type}\""
end

#hostObject



26
27
28
# File 'lib/gorillapi/curl_builder.rb', line 26

def host
  "http://#{url}#{path}"
end

#request_stringObject



4
5
6
7
8
# File 'lib/gorillapi/curl_builder.rb', line 4

def request_string
  <<-EOF
curl -X #{request_method} -k -i -v #{content_header} #{accept} #{authorization} #{add_params} #{host}
  EOF
end