module ChartMogul::API::Actions::Create::ClassMethods

Public Instance Methods

create!(attributes = {}) click to toggle source
# File lib/chartmogul/api/actions/create.rb, line 24
def create!(attributes = {})
  resource = new(attributes)

  resp = handling_errors do
    connection.post(resource_path.apply(attributes)) 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