Skip to content

Commit

Permalink
code review of contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
ksvirkou-hubspot committed Jan 9, 2020
1 parent 507b621 commit c3510e4
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 101 deletions.
1 change: 1 addition & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @method \SevenShores\Hubspot\Resources\ContactProperties contactProperties()
* @method \SevenShores\Hubspot\Resources\Contacts contacts()
* @method \SevenShores\Hubspot\Resources\CrmAssociations crmAssociations()
* @method \SevenShores\Hubspot\Resources\CrmPipelines crmPipelines()
* @method \SevenShores\Hubspot\Resources\Email email()
* @method \SevenShores\Hubspot\Resources\EmailEvents emailEvents()
* @method \SevenShores\Hubspot\Resources\Engagements engagements()
Expand Down
37 changes: 37 additions & 0 deletions src/Resources/Contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

namespace SevenShores\Hubspot\Resources;

/**
* @see https://developers.hubspot.com/docs/methods/contacts/contacts-overview
*/
class Contacts extends Resource
{
/**
* Create a new contact.
*
* @param array $properties array of contact properties
*
* @return \SevenShores\Hubspot\Http\Response
Expand All @@ -21,6 +26,8 @@ public function create(array $properties)
}

/**
* Update an existing contact.
*
* @param int $id the contact id
* @param array $properties the contact properties to update
*
Expand All @@ -38,6 +45,8 @@ public function update($id, array $properties)
}

/**
* Update an existing contact by email.
*
* @param string $email the contact's email address
* @param array $properties the contact properties to update
*
Expand All @@ -55,6 +64,8 @@ public function updateByEmail($email, array $properties)
}

/**
* Create or update a contact.
*
* @param string $email the contact's email address
* @param array $properties the contact properties
*
Expand All @@ -72,6 +83,8 @@ public function createOrUpdate($email, array $properties = [])
}

/**
* Create or update a group of contacts.
*
* @param array $contacts the contacts and properties
* @param array $params Array of optional parameters ['auditId']
*
Expand All @@ -91,6 +104,8 @@ public function createOrUpdateBatch(array $contacts, array $params = [])
}

/**
* Delete a contact.
*
* @param int $id
*
* @return \SevenShores\Hubspot\Http\Response
Expand Down Expand Up @@ -172,6 +187,8 @@ public function recentNew(array $params = [])
}

/**
* Get a contact by vid(id).
*
* @param int $id
* @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode',
* 'showListMemberships']
Expand Down Expand Up @@ -216,6 +233,8 @@ public function getBatchByIds(array $vids, array $params = [])
}

/**
* Get a contact by email address.
*
* @param string $email
* @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode',
* 'showListMemberships']
Expand Down Expand Up @@ -259,6 +278,8 @@ public function getBatchByEmails($emails, array $params = [])
}

/**
* Get a contact by its user token.
*
* @param string $utk
* @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode',
* 'showListMemberships']
Expand Down Expand Up @@ -333,6 +354,8 @@ public function search($query, array $params = [])
}

/**
* @deprecated
*
* @return \SevenShores\Hubspot\Http\Response
*/
public function statistics()
Expand Down Expand Up @@ -362,4 +385,18 @@ public function merge($id, $vidToMerge)

return $this->client->request('post', $endpoint, $options);
}

/**
* Get Lifecycle Stage metrics for Contacts.
*
* @see https://developers.hubspot.com/docs/methods/contacts/get-lifecycle-stage-metrics-for-contacts
*
* @return \SevenShores\Hubspot\Http\Response
*/
public function getLifecycleStageMetrics(array $params = [])
{
$endpoint = 'https://api.hubapi.com/contacts/v1/contacts/statistics';

return $this->client->request('get', $endpoint, [], build_query_string($params));
}
}
Loading

0 comments on commit c3510e4

Please sign in to comment.