-
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 #44 from clearbit/master
Add support for querying `customField` objects
- Loading branch information
Showing
8 changed files
with
104 additions
and
6 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
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
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Pardot | ||
module Objects | ||
module CustomFields | ||
|
||
def custom_fields | ||
@custom_fields ||= CustomFields.new self | ||
end | ||
|
||
class CustomFields | ||
|
||
def initialize client | ||
@client = client | ||
end | ||
|
||
def query params | ||
result = get "/do/query", params, "result" | ||
result["total_results"] = result["total_results"].to_i if result["total_results"] | ||
result | ||
end | ||
|
||
protected | ||
|
||
def get path, params = {}, result = "customField" | ||
response = @client.get "customField", path, params | ||
result ? response[result] : response | ||
end | ||
|
||
def post path, params = {}, result = "user" | ||
response = @client.post "customField", path, params | ||
result ? response[result] : response | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
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,3 +1,3 @@ | ||
module Pardot | ||
VERSION = "1.3.1" | ||
VERSION = "1.3.2" | ||
end |
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') | ||
|
||
describe Pardot::Objects::CustomFields do | ||
|
||
before do | ||
@client = create_client | ||
end | ||
|
||
describe "query" do | ||
|
||
def sample_results | ||
%(<?xml version="1.0" encoding="UTF-8"?>\n<rsp stat="ok" version="1.0"> | ||
<result> | ||
<total_results>1</total_results> | ||
<customField> | ||
<created_at>2019-11-26 13:40:37</created_at> | ||
<crm_id null="true" /> | ||
<field_id>CustomObject1574793618883</field_id> | ||
<id>8932</id> | ||
<is_record_multiple_responses>false</is_record_multiple_responses> | ||
<is_use_values>false</is_use_values> | ||
<name>Ω≈ç√∫˜µ≤≥÷</name> | ||
<type>Text</type> | ||
<type_id>1</type_id> | ||
<updated_at>2019-11-26 13:40:37</updated_at> | ||
</customField> | ||
</result> | ||
</rsp>) | ||
end | ||
|
||
before do | ||
@client = create_client | ||
end | ||
|
||
it "should take in some arguments" do | ||
fake_get "/api/customField/version/3/do/query?id_greater_than=200&format=simple", sample_results | ||
|
||
@client.custom_fields.query(:id_greater_than => 200).should == {"total_results" => 1, | ||
"customField"=> | ||
{ | ||
"id"=>"8932", | ||
"name"=>"Ω≈ç√∫˜µ≤≥÷", | ||
"field_id"=>"CustomObject1574793618883", | ||
"type"=>"Text", | ||
"type_id"=>"1", | ||
"crm_id"=>{"null"=>"true"}, | ||
"is_record_multiple_responses"=>"false", | ||
"is_use_values"=>"false", | ||
"created_at"=>"2019-11-26 13:40:37", | ||
"updated_at"=>"2019-11-26 13:40:37" | ||
} | ||
} | ||
assert_authorization_header | ||
end | ||
|
||
end | ||
|
||
end |
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 |
---|---|---|
|
@@ -51,12 +51,12 @@ def sample_results | |
end | ||
|
||
it "should return the prospect" do | ||
fake_post "/api/prospect/version/3/do/create/email/user@test.com?format=simple&first_name=Jim", sample_results | ||
fake_post "/api/prospect/version/3/do/create/email/user%40test.com?first_name=Jim&format=simple", sample_results | ||
|
||
@client.prospects.create("[email protected]", :first_name => "Jim").should == {"last_name"=>"Smith", "first_name"=>"Jim"} | ||
assert_authorization_header | ||
end | ||
|
||
end | ||
|
||
end | ||
end |