Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(CE): change destination_insert to create in salesforce crm #490

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integrations/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GIT
PATH
remote: .
specs:
multiwoven-integrations (0.15.5)
multiwoven-integrations (0.15.6)
MailchimpMarketing
activesupport
async-websocket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ def process_records(records, stream)
properties = stream.json_schema[:properties]
records.each do |record_object|
record = extract_data(record_object, properties)
request, response = *process_record(stream, record)
args = [stream.name, "Id", record]
response = send_data_to_salesforce(args)
write_success += 1
log_message_array << log_request_response("info", request, response)
log_message_array << log_request_response("info", args, response)
rescue StandardError => e
# TODO: add sync_id and sync_run_id to the logs
handle_exception(e, {
Expand All @@ -77,31 +78,14 @@ def process_records(records, stream)
sync_run_id: @sync_config.sync_run_id
})
write_failure += 1
log_message_array << log_request_response("error", request, e.message)
log_message_array << log_request_response("error", args, e.message)
end
tracking_message(write_success, write_failure, log_message_array)
end

def process_record(stream, record)
send_data_to_salesforce(stream.name, record)
end

def send_data_to_salesforce(stream_name, record = {})
method_name = "#{@action}!"
args = build_args(@action, stream_name, record)
response = @client.send(method_name, *args)
[args, response]
end

def build_args(action, stream_name, record)
case action
when :upsert
[stream_name, record[:external_key], record]
when :destroy
[stream_name, record[:id]]
else
[stream_name, record]
end
def send_data_to_salesforce(args)
method_name = "upsert!"
@client.send(method_name, *args)
end

def authenticate_client
Expand Down
2 changes: 1 addition & 1 deletion integrations/lib/multiwoven/integrations/rollout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Multiwoven
module Integrations
VERSION = "0.15.5"
VERSION = "0.15.6"

ENABLED_SOURCES = %w[
Snowflake
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ def build_record(id, name)
end

def stub_create_request(id, name, response_code)
stub_request(:post, "https://your-instance-url.salesforce.com/services/data/v59.0/sobjects/Account")
stub_request(:patch, "https://your-instance-url.salesforce.com/services/data/v59.0/sobjects/Account/Id/#{id}")
.with(
body: hash_including("Id" => id, "Name" => name),
body: hash_including({ "Name": name }),
headers: { "Accept" => "*/*", "Authorization" => "OAuth",
"Content-Type" => "application/json" }
).to_return(status: response_code, body: "", headers: {})
Expand Down