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

Included in:
Customer, Enrichment::DeprecatedCustomer, Plan, PlanGroup
Defined in:
lib/chartmogul/api/actions/update.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
# File 'lib/chartmogul/api/actions/update.rb', line 7

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#update!Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/chartmogul/api/actions/update.rb', line 11

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, immutable_keys: self.class.immutable_keys)

  assign_all_attributes(json)
end