Skip to content
Open
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
6 changes: 4 additions & 2 deletions lib/mrkt/concerns/crud_leads.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def get_leads(filter_type, filter_values, fields: nil, batch_size: nil, next_pag
get('/rest/v1/leads.json', params, optional)
end

def createupdate_leads(leads, action: 'createOrUpdate', lookup_field: nil, partition_name: nil, async_processing: nil)
def createupdate_leads(leads, action: 'createOrUpdate', lookup_field: nil, partition_name: nil, async_processing: nil,
program_name: nil)
post_json('/rest/v1/leads.json') do
params = {
action: action,
Expand All @@ -33,7 +34,8 @@ def createupdate_leads(leads, action: 'createOrUpdate', lookup_field: nil, parti
optional = {
lookupField: lookup_field,
partitionName: partition_name,
asyncProcessing: async_processing
asyncProcessing: async_processing,
programName: program_name # listed as optional so as to not break existing consumers of the gem.
}

merge_params(params, optional)
Expand Down
27 changes: 27 additions & 0 deletions spec/concerns/crud_leads_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,33 @@
end

it { is_expected.to eq(response_stub) }

context 'with programName' do
subject { client.createupdate_leads(leads, lookup_field: :email, program_name: 'programNameTest') }

let(:request_body) do
{
action: 'createOrUpdate',
input: [
{
firstName: 'John',
lastName: 'Snow',
email: 'sample@example.com'
}
],
lookupField: 'email',
programName: 'programNameTest'
}
end

before do
stub_request(:post, "https://#{host}/rest/v1/leads.json")
.with(json_stub(request_body))
.to_return(json_stub(response_stub))
end

it { is_expected.to eq(response_stub) }
end
end

describe '#delete_leads' do
Expand Down