Method: PrintNode::Client#patch

Defined in:
lib/printnode/client.rb

#patch(end_point_url, data = nil) ⇒ Object

Sends a PATCH request to the specified URL.

Returns:

A response object of the request.

Parameters:

  • end_point_url (String)

    To be appended onto api_url to be used in the request.

  • data (defaults to: nil)

    Data object to be encoded into JSON. If not used, nothing is put in the body of the request.



149
150
151
152
153
154
155
156
157
158
159
# File 'lib/printnode/client.rb', line 149

def patch(end_point_url, data = nil)
  uri = URI(@api_url + end_point_url)
  request = Net::HTTP::Patch.new uri
  @headers.each_with_index do |(k, v)|
    request[k] = v
  end
  request.basic_auth(@auth.credentials[0], @auth.credentials[1])
  request['Content-Type'] = 'application/json'
  request.body = data.to_json if data
  start_response(request, uri)
end