Module: RHapi::Connection
- Included in:
- Lead
- Defined in:
- lib/r_hapi/connection.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#put(url, payload) ⇒ Object
Instance methods —————————————————————————.
Instance Method Details
#put(url, payload) ⇒ Object
Instance methods —————————————————————————
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/r_hapi/connection.rb', line 8 def put(url, payload) data = payload.to_json response = Curl::Easy.http_put(url, data) do |curl| curl.headers["Content-Type"] = "application/json" curl.on_failure do |response, err| RHapi::ConnectionError.raise_error("#{response.response_code}\n Error is: #{err.inspect}") end end RHapi::ConnectionError.raise_error(response.header_str) unless response.header_str =~ /2\d\d/ end |