-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from ted-hanson/master
Properly escape url entities passed in prospects API
- Loading branch information
Showing
1 changed file
with
47 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,111 @@ | ||
require 'cgi' | ||
|
||
module Pardot | ||
module Objects | ||
module Prospects | ||
|
||
def prospects | ||
@prospects ||= Prospects.new self | ||
end | ||
|
||
class Prospects | ||
|
||
def initialize client | ||
@client = client | ||
end | ||
|
||
def query search_criteria | ||
result = get "/do/query", search_criteria, "result" | ||
result["total_results"] = result["total_results"].to_i if result["total_results"] | ||
result | ||
end | ||
|
||
def assign_by_email email, params | ||
post "/do/assign/email/#{email}", params | ||
post "/do/assign/email/#{CGI.escape(email)}", params | ||
end | ||
|
||
def assign_by_id id, params | ||
post "/do/assign/id/#{id}", params | ||
post "/do/assign/id/#{CGI.escape(id)}", params | ||
end | ||
|
||
def assign_by_fid fid, params | ||
post "/do/assign/fid/#{fid}", params | ||
post "/do/assign/fid/#{CGI.escape(fid)}", params | ||
end | ||
|
||
def create email, params = {} | ||
post "/do/create/email/#{email}", params | ||
post "/do/create/email/#{CGI.escape(email)}", params | ||
end | ||
|
||
def delete_by_id id, params = {} | ||
post "/do/delete/id/#{id}", params | ||
post "/do/delete/id/#{CGI.escape(id)}", params | ||
end | ||
|
||
def delete_by_fid fid, params = {} | ||
post "/do/delete/fid/#{fid}", params | ||
post "/do/delete/fid/#{CGI.escape(fid)}", params | ||
end | ||
|
||
def read_by_email email, params = {} | ||
post "/do/read/email/#{email}", params | ||
post "/do/read/email/#{CGI.escape(email)}", params | ||
end | ||
|
||
def read_by_id id, params = {} | ||
post "/do/read/id/#{id}", params | ||
post "/do/read/id/#{CGI.escape(id)}", params | ||
end | ||
|
||
def read_by_fid fid, params = {} | ||
post "/do/read/fid/#{fid}", params | ||
post "/do/read/fid/#{CGI.escape(fid)}", params | ||
end | ||
|
||
def unassign_by_email email, params = {} | ||
post "/do/unassign/email/#{email}", params | ||
post "/do/unassign/email/#{CGI.escape(email)}", params | ||
end | ||
|
||
def unassign_by_id id, params = {} | ||
post "/do/unassign/id/#{id}", params | ||
post "/do/unassign/id/#{CGI.escape(id)}", params | ||
end | ||
|
||
def unassign_by_fid fid, params = {} | ||
post "/do/unassign/fid/#{fid}", params | ||
post "/do/unassign/fid/#{CGI.escape(fid)}", params | ||
end | ||
|
||
def update_by_email email, params = {} | ||
post "/do/update/email/#{email}", params | ||
post "/do/update/email/#{CGI.escape(email)}", params | ||
end | ||
|
||
def update_by_id id, params = {} | ||
post "/do/update/id/#{id}", params | ||
post "/do/update/id/#{CGI.escape(id)}", params | ||
end | ||
|
||
def update_by_fid fid, params = {} | ||
post "/do/update/fid/#{fid}", params | ||
post "/do/update/fid/#{CGI.escape(fid)}", params | ||
end | ||
|
||
def upsert_by_email email, params = {} | ||
post "/do/upsert/email/#{email}", params | ||
post "/do/upsert/email/#{CGI.escape(email)}", params | ||
end | ||
|
||
def upsert_by_id id, params = {} | ||
post "/do/upsert/id/#{id}", params | ||
post "/do/upsert/id/#{CGI.escape(id)}", params | ||
end | ||
|
||
def upsert_by_fid fid, params = {} | ||
post "/do/upsert/fid/#{fid}", params | ||
post "/do/upsert/fid/#{CGI.escape(fid)}", params | ||
end | ||
|
||
protected | ||
|
||
def get path, params = {}, result = "prospect" | ||
response = @client.get "prospect", path, params | ||
result ? response[result] : response | ||
end | ||
|
||
def post path, params = {}, result = "prospect" | ||
response = @client.post "prospect", path, params | ||
result ? response[result] : response | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |