Skip to content
Open
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
25 changes: 24 additions & 1 deletion class.contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,29 @@ public function update_contact($vid, $params){
}
}

/**
* Create or Update a Contact
*
* @param params: array of properties and property values for contact
*
* @return Response body from HTTP POST request
*
* @throws HubSpot_Exception
**/
public function create_or_update_contact($email, $params){
$endpoint = 'contact/createOrUpdate/email/'.urlencode($email).'/';
$properties = array();
foreach ($params as $key => $value) {
array_push($properties, array("property"=>$key,"value"=>$value));
}
$properties = json_encode(array("properties"=>$properties));
try{
return json_decode($this->execute_JSON_post_request($this->get_request_url($endpoint,null),$properties));
} catch (HubSpot_Exception $e) {
throw new HubSpot_Exception('Unable to create or update contact: ' . $e);
}
}

/**
* Delete a Contact
*
Expand Down Expand Up @@ -229,4 +252,4 @@ public function get_contacts_statistics(){

}

?>
?>