Skip to content

send email to prospect using email #15

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
9 changes: 7 additions & 2 deletions lib/pardot/objects/emails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ def read_by_id id
get "/do/read/id/#{id}"
end

def send_to_prospect prospect_id, params
post "/do/send/prospect_id/#{prospect_id}", params
def send_to_prospect_id id, params
post "/do/send/prospect_id/#{id}", params
end
alias_method :send_to_prospect, :send_to_prospect_id

def send_to_prospect_email email, params
post "/do/send/prospect_email/#{email}", params
end

def send_to_list params
Expand Down
16 changes: 11 additions & 5 deletions spec/pardot/objects/emails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ def sample_response
</rsp>)
end

before do
@client = create_client
end

it "should take in the email ID" do
fake_get "/api/email/version/3/do/read/id/12?user_key=bar&api_key=my_api_key&format=simple", sample_response
@client.emails.read_by_id(12).should == {"name" => "My Email"}
Expand All @@ -28,9 +24,19 @@ def sample_response
@client.emails.send_to_prospect(42, :campaign_id => 765, :email_template_id => 86).should == {"name" => "My Email"}
end

it 'should send to a prospect id' do
fake_post '/api/email/version/3/do/send/prospect_id/42?campaign_id=765&email_template_id=86&user_key=bar&api_key=my_api_key&format=simple', sample_response
@client.emails.send_to_prospect_id(42, :campaign_id => 765, :email_template_id => 86).should == {"name" => "My Email"}
end

it 'should send to a prospect email' do
fake_post '/api/email/version/3/do/send/prospect_email/joe@example.com?campaign_id=765&email_template_id=86&user_key=bar&api_key=my_api_key&format=simple', sample_response
@client.emails.send_to_prospect_email('joe@example.com', :campaign_id => 765, :email_template_id => 86).should == {"name" => "My Email"}
end

it 'should send to a list' do
fake_post '/api/email/version/3/do/send?email_template_id=200&list_ids[]=235&campaign_id=654&user_key=bar&api_key=my_api_key&format=simple', sample_response
@client.emails.send_to_list(:email_template_id => 200, 'list_ids[]' => 235, :campaign_id => 654).should == {"name" => "My Email"}
end

end
end