Class: Pardot::Client
Constant Summary collapse
- BASE_URIS =
{ production: 'https://pi.pardot.com/api/v5/objects', demo: 'https://pi.demo.pardot.com/api/v5/objects', login: 'https://login.salesforce.com' }
- LIST_CUSTOM_FIELDS =
"id,name,fieldId,updatedAt,type,isRecordMultipleResponses,salesforceId,isUseValues,isRequired"
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#token_refreshed ⇒ Object
readonly
Returns the value of attribute token_refreshed.
Instance Method Summary collapse
- #add_prospect_to_list_membership(prospect_id, list_id, opted_out) ⇒ Object
- #create_prospect(email, params = {}) ⇒ Object
- #get_account ⇒ Object
- #get_prospect_by_email(email, fields = 'id, createdAt', order_by = 'createdAt desc') ⇒ Object
-
#initialize(access_token, refresh_token, client_id, client_secret, pardot_business_unit_id, environment = :production) ⇒ Client
constructor
A new instance of Client.
- #list_custom_fields(fields = LIST_CUSTOM_FIELDS) ⇒ Object
- #update_prospect(prospect_id, params = {}) ⇒ Object
Constructor Details
#initialize(access_token, refresh_token, client_id, client_secret, pardot_business_unit_id, environment = :production) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pardot/client.rb', line 14 def initialize(access_token, refresh_token, client_id, client_secret, pardot_business_unit_id, environment = :production) @access_token = access_token @refresh_token = refresh_token @client_id = client_id @client_secret = client_secret @pardot_business_unit_id = pardot_business_unit_id @token_refreshed = false @environment = environment self.class.base_uri BASE_URIS[environment] end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
12 13 14 |
# File 'lib/pardot/client.rb', line 12 def access_token @access_token end |
#token_refreshed ⇒ Object (readonly)
Returns the value of attribute token_refreshed.
12 13 14 |
# File 'lib/pardot/client.rb', line 12 def token_refreshed @token_refreshed end |
Instance Method Details
#add_prospect_to_list_membership(prospect_id, list_id, opted_out) ⇒ Object
39 40 41 42 |
# File 'lib/pardot/client.rb', line 39 def add_prospect_to_list_membership(prospect_id, list_id, opted_out) query = { prospectId: prospect_id, listId: list_id, optedOut: opted_out } perform_request { self.class.post('/list-memberships?fields=id', body: query.to_json, headers: auth_headers) } end |
#create_prospect(email, params = {}) ⇒ Object
34 35 36 37 |
# File 'lib/pardot/client.rb', line 34 def create_prospect(email, params = {}) query = params.merge(email: email) perform_request { self.class.post('/prospects', body: query.to_json, headers: auth_headers) } end |
#get_account ⇒ Object
30 31 32 |
# File 'lib/pardot/client.rb', line 30 def get_account perform_request { self.class.get('/account?fields=id,company,website', headers: auth_headers) } end |
#get_prospect_by_email(email, fields = 'id, createdAt', order_by = 'createdAt desc') ⇒ Object
44 45 46 |
# File 'lib/pardot/client.rb', line 44 def get_prospect_by_email(email, fields='id, createdAt', order_by='createdAt desc') perform_request { self.class.get("/prospects?fields=#{fields}&email=#{email}&orderBy=#{order_by}", headers: auth_headers) } end |
#list_custom_fields(fields = LIST_CUSTOM_FIELDS) ⇒ Object
26 27 28 |
# File 'lib/pardot/client.rb', line 26 def list_custom_fields(fields=LIST_CUSTOM_FIELDS) perform_request { self.class.get("/custom-fields?fields=#{fields}", headers: auth_headers) } end |
#update_prospect(prospect_id, params = {}) ⇒ Object
48 49 50 51 |
# File 'lib/pardot/client.rb', line 48 def update_prospect(prospect_id, params = {}) query = params perform_request { self.class.patch("/prospects/#{prospect_id}", body: query.to_json, headers: auth_headers) } end |