Skip to content

Update "method" to "endpoint" in MailChimp.php #306

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
44 changes: 22 additions & 22 deletions src/MailChimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,88 +134,88 @@ public function getLastRequest()
/**
* Make an HTTP DELETE request - for deleting data
*
* @param string $method URL of the API request method
* @param string $endpoint Endpoint (URL) of the API request
* @param array $args Assoc array of arguments (if any)
* @param int $timeout Timeout limit for request in seconds
*
* @return array|false Assoc array of API response, decoded from JSON
*/
public function delete($method, $args = array(), $timeout = self::TIMEOUT)
public function delete($endpoint, $args = array(), $timeout = self::TIMEOUT)
{
return $this->makeRequest('delete', $method, $args, $timeout);
return $this->makeRequest('delete', $endpoint, $args, $timeout);
}

/**
* Make an HTTP GET request - for retrieving data
*
* @param string $method URL of the API request method
* @param string $endpoint Endpoint (URL) of the API request
* @param array $args Assoc array of arguments (usually your data)
* @param int $timeout Timeout limit for request in seconds
*
* @return array|false Assoc array of API response, decoded from JSON
*/
public function get($method, $args = array(), $timeout = self::TIMEOUT)
public function get($endpoint, $args = array(), $timeout = self::TIMEOUT)
{
return $this->makeRequest('get', $method, $args, $timeout);
return $this->makeRequest('get', $endpoint, $args, $timeout);
}

/**
* Make an HTTP PATCH request - for performing partial updates
*
* @param string $method URL of the API request method
* @param string $endpoint Endpoint (URL) of the API request
* @param array $args Assoc array of arguments (usually your data)
* @param int $timeout Timeout limit for request in seconds
*
* @return array|false Assoc array of API response, decoded from JSON
*/
public function patch($method, $args = array(), $timeout = self::TIMEOUT)
public function patch($endpoint, $args = array(), $timeout = self::TIMEOUT)
{
return $this->makeRequest('patch', $method, $args, $timeout);
return $this->makeRequest('patch', $endpoint, $args, $timeout);
}

/**
* Make an HTTP POST request - for creating and updating items
*
* @param string $method URL of the API request method
* @param string $endpoint Endpoint (URL) of the API request
* @param array $args Assoc array of arguments (usually your data)
* @param int $timeout Timeout limit for request in seconds
*
* @return array|false Assoc array of API response, decoded from JSON
*/
public function post($method, $args = array(), $timeout = self::TIMEOUT)
public function post($endpoint, $args = array(), $timeout = self::TIMEOUT)
{
return $this->makeRequest('post', $method, $args, $timeout);
return $this->makeRequest('post', $endpoint, $args, $timeout);
}

/**
* Make an HTTP PUT request - for creating new items
*
* @param string $method URL of the API request method
* @param string $endpoint Endpoint (URL) of the API request
* @param array $args Assoc array of arguments (usually your data)
* @param int $timeout Timeout limit for request in seconds
*
* @return array|false Assoc array of API response, decoded from JSON
*/
public function put($method, $args = array(), $timeout = self::TIMEOUT)
public function put($endpoint, $args = array(), $timeout = self::TIMEOUT)
{
return $this->makeRequest('put', $method, $args, $timeout);
return $this->makeRequest('put', $endpoint, $args, $timeout);
}

/**
* Performs the underlying HTTP request. Not very exciting.
*
* @param string $http_verb The HTTP verb to use: get, post, put, patch, delete
* @param string $method The API method to be called
* @param string $endpoint The API endpoint (URL) to be called
* @param array $args Assoc array of parameters to be passed
* @param int $timeout
*
* @return array|false Assoc array of decoded result
*/
private function makeRequest($http_verb, $method, $args = array(), $timeout = self::TIMEOUT)
private function makeRequest($http_verb, $endpoint, $args = array(), $timeout = self::TIMEOUT)
{
$url = $this->api_endpoint . '/' . $method;
$url = $this->api_endpoint . '/' . $endpoint;

$response = $this->prepareStateForRequest($http_verb, $method, $url, $timeout);
$response = $this->prepareStateForRequest($http_verb, $endpoint, $url, $timeout);

$httpHeader = array(
'Accept: application/vnd.api+json',
Expand Down Expand Up @@ -283,13 +283,13 @@ private function makeRequest($http_verb, $method, $args = array(), $timeout = se

/**
* @param string $http_verb
* @param string $method
* @param string $endpoint
* @param string $url
* @param integer $timeout
*
* @return array
*/
private function prepareStateForRequest($http_verb, $method, $url, $timeout)
private function prepareStateForRequest($http_verb, $endpoint, $url, $timeout)
{
$this->last_error = '';

Expand All @@ -303,7 +303,7 @@ private function prepareStateForRequest($http_verb, $method, $url, $timeout)

$this->last_request = array(
'method' => $http_verb,
'path' => $method,
'path' => $endpoint,
'url' => $url,
'body' => '',
'timeout' => $timeout,
Expand Down