Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ksvirkou-hubspot committed Jan 9, 2020
1 parent c3510e4 commit 6a320d7
Showing 1 changed file with 97 additions and 51 deletions.
148 changes: 97 additions & 51 deletions src/Resources/Contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ public function create(array $properties)
{
$endpoint = 'https://api.hubapi.com/contacts/v1/contact';

$options['json'] = ['properties' => $properties];

return $this->client->request('post', $endpoint, $options);
return $this->client->request(
'post',
$endpoint,
['json' => ['properties' => $properties]]
);
}

/**
Expand All @@ -39,9 +41,11 @@ public function update($id, array $properties)
{
$endpoint = "https://api.hubapi.com/contacts/v1/contact/vid/{$id}/profile";

$options['json'] = ['properties' => $properties];

return $this->client->request('post', $endpoint, $options);
return $this->client->request(
'post',
$endpoint,
['json' => ['properties' => $properties]]
);
}

/**
Expand All @@ -58,9 +62,11 @@ public function updateByEmail($email, array $properties)
{
$endpoint = "https://api.hubapi.com/contacts/v1/contact/email/{$email}/profile";

$options['json'] = ['properties' => $properties];

return $this->client->request('post', $endpoint, $options);
return $this->client->request(
'post',
$endpoint,
['json' => ['properties' => $properties]]
);
}

/**
Expand All @@ -77,9 +83,11 @@ public function createOrUpdate($email, array $properties = [])
{
$endpoint = "https://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/{$email}";

$options['json'] = ['properties' => $properties];

return $this->client->request('post', $endpoint, $options);
return $this->client->request(
'post',
$endpoint,
['json' => ['properties' => $properties]]
);
}

/**
Expand All @@ -96,11 +104,12 @@ public function createOrUpdateBatch(array $contacts, array $params = [])
{
$endpoint = 'https://api.hubapi.com/contacts/v1/contact/batch';

$queryString = build_query_string($params);

$options['json'] = $contacts;

return $this->client->request('post', $endpoint, $options, $queryString);
return $this->client->request(
'post',
$endpoint,
['json' => $contacts],
build_query_string($params)
);
}

/**
Expand Down Expand Up @@ -139,9 +148,12 @@ public function all(array $params = [])
{
$endpoint = 'https://api.hubapi.com/contacts/v1/lists/all/contacts/all';

$queryString = build_query_string($params);

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

/**
Expand All @@ -160,9 +172,12 @@ public function recent(array $params = [])
{
$endpoint = 'https://api.hubapi.com/contacts/v1/lists/recently_updated/contacts/recent';

$queryString = build_query_string($params);

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

/**
Expand All @@ -181,9 +196,12 @@ public function recentNew(array $params = [])
{
$endpoint = 'https://api.hubapi.com/contacts/v1/lists/all/contacts/recent';

$queryString = build_query_string($params);

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

/**
Expand All @@ -201,9 +219,12 @@ public function getById($id, array $params = [])
{
$endpoint = "https://api.hubapi.com/contacts/v1/contact/vid/{$id}/profile";

$queryString = build_query_string($params);

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

/**
Expand All @@ -227,9 +248,12 @@ public function getBatchByIds(array $vids, array $params = [])

$params['vid'] = $vids;

$queryString = build_query_string($params);

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

/**
Expand All @@ -247,9 +271,12 @@ public function getByEmail($email, array $params = [])
{
$endpoint = "https://api.hubapi.com/contacts/v1/contact/email/{$email}/profile";

$queryString = build_query_string($params);

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

/**
Expand All @@ -272,9 +299,12 @@ public function getBatchByEmails($emails, array $params = [])

$params['email'] = $emails;

$queryString = build_query_string($params);

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

/**
Expand All @@ -292,9 +322,12 @@ public function getByToken($utk, array $params = [])
{
$endpoint = "https://api.hubapi.com/contacts/v1/contact/utk/{$utk}/profile";

$queryString = build_query_string($params);

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

/**
Expand All @@ -321,9 +354,12 @@ public function getBatchByTokens(array $utks, array $params = [])

$params['utk'] = $utks;

$queryString = build_query_string($params);

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

/**
Expand All @@ -348,9 +384,12 @@ public function search($query, array $params = [])

$params['q'] = $query;

$queryString = build_query_string($params);

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

/**
Expand Down Expand Up @@ -381,9 +420,11 @@ public function merge($id, $vidToMerge)
{
$endpoint = "https://api.hubapi.com/contacts/v1/contact/merge-vids/{$id}/";

$options['json'] = ['vidToMerge' => $vidToMerge];

return $this->client->request('post', $endpoint, $options);
return $this->client->request(
'post',
$endpoint,
['json' => ['vidToMerge' => $vidToMerge]]
);
}

/**
Expand All @@ -397,6 +438,11 @@ public function getLifecycleStageMetrics(array $params = [])
{
$endpoint = 'https://api.hubapi.com/contacts/v1/contacts/statistics';

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

0 comments on commit 6a320d7

Please sign in to comment.