module ChartMogul::API::Actions::Create

Public Class Methods

included(base) click to toggle source
# File lib/chartmogul/api/actions/create.rb, line 7
def self.included(base)
  base.extend ClassMethods
end

Public Instance Methods

create!() click to toggle source
# File lib/chartmogul/api/actions/create.rb, line 11
def create!
  resp = handling_errors do
    connection.post(resource_path.apply(instance_attributes)) 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