Module: ChartMogul::API::Actions::Update::ClassMethods

Defined in:
lib/chartmogul/api/actions/update.rb

Instance Method Summary collapse

Instance Method Details

#update!(uuid, attributes = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/chartmogul/api/actions/update.rb', line 25

def update!(uuid, attributes = {})
  resource = new(attributes)

  resp = handling_errors do
    connection.patch("#{resource_path.apply(attributes)}/#{uuid}") do |req|
      req.headers['Content-Type'] = 'application/json'
      req.body = JSON.dump(resource.serialize_for_write)
    end
  end
  json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: immutable_keys)

  new_from_json(json)
end