Method: CrAPI::Client#patch

Defined in:
lib/crapi/client.rb

#patch(path, headers: {}, query: {}, payload: {}) ⇒ Object

CRUD method: PATCH

Parameters:

  • path (String)

    The path to the resource to PATCH. Note that this path is always interpreted as relative to the client's base_uri's path, regardless of whether it begins with a "/".

  • headers (Hash) (defaults to: {})

    Additional headers to set in addition to the client's defaults. Any header given here and also appearing in the client's defaults will override said default value.

  • query (Hash, Array, String) (defaults to: {})

    Query string values, if any, to append to the given path. Strings are appended as-is; Hashes and Arrays are serialized as URI-encoded form data before appending.

  • payload (Hash, String) (defaults to: {})

    The payload to send, if any. Strings are used as-is; Hashes are serialized per the request's "Content-Type" header.

Returns:

  • (Object)


166
167
168
169
170
171
172
173
# File 'lib/crapi/client.rb', line 166

def patch(path, headers: {}, query: {}, payload: {})
  headers = @default_headers.merge(headers)
  payload = format_payload(payload, as: headers[:'Content-Type'])

  response = @http.patch(full_path(path, query: query), payload, headers)
  ensure_success!(response)
  parse_response(response)
end