Sha256: 927809c79c674a904c09b7869dfa1c0f864b4ddc8b90fd62282f084bd863505e
Contents?: true
Size: 1.22 KB
Versions: 4
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module ChartMogul module API module Actions module Update def self.included(base) base.extend ClassMethods end def update! resp = handling_errors do connection.patch("#{resource_path.apply(instance_attributes)}/#{uuid}") do |req| req.headers['Content-Type'] = 'application/json' req.body = JSON.dump(serialize_for_write) end end json = ChartMogul::Utils::JSONParser.parse(resp.body, skip_case_conversion: self.class.skip_case_conversion) assign_all_attributes(json) end module ClassMethods 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, skip_case_conversion: skip_case_conversion) new_from_json(json) end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems