class SalesforceAdapter::Operations::Create

Public Class Methods

new(rforce_binding, table_name, attributes) click to toggle source
# File lib/salesforce_adapter/operations/create.rb, line 19
def initialize(rforce_binding, table_name, attributes)
  @table_name = table_name
  @attributes = attributes

  super(rforce_binding)
end

Private Instance Methods

context() click to toggle source
# File lib/salesforce_adapter/operations/create.rb, line 29
def context
  "creating salesforce #{@table_name} with attributes #{Helpers.hash_to_s(@attributes)}"
end
format_response() click to toggle source
# File lib/salesforce_adapter/operations/create.rb, line 52
def format_response
  # Return the id
  @response[:createResponse][:result][:id]
end
perform() click to toggle source
# File lib/salesforce_adapter/operations/create.rb, line 37
def perform
  rforce_binding.create( @table_name => Helpers.format_fields_for_create_or_update(@attributes) )
end
validate_request!() click to toggle source
# File lib/salesforce_adapter/operations/create.rb, line 33
def validate_request!
  raise ArgumentError.new("type must be specified for a Salesforce Create") unless @attributes[:type]
end
validate_response!() click to toggle source
# File lib/salesforce_adapter/operations/create.rb, line 41
def validate_response!
  super

  # Raise exception on update failure
  if !@response[:createResponse][:result][:success]
    sf_error_code     = @response[:createResponse][:result][:errors][:statusCode]
    sf_error_message  = @response[:createResponse][:result][:errors][:message]
    raise SalesforceFailedCreate.new(sf_error_code), "#{sf_error_message}\nContext : #{context}"
  end
end