/home/desid573/public_html/gcdriver/square/lib/Api
Edit: /home/desid573/public_html/gcdriver/square/lib/Api/CheckoutApi.php (5949B)
getConfig()->setHost('https://connect.squareup.com');
}
$this->apiClient = $apiClient;
}
/**
* Get API client
* @return \SquareConnect\ApiClient get the API client
*/
public function getApiClient()
{
return $this->apiClient;
}
/**
* Set the API client
* @param \SquareConnect\ApiClient $apiClient set the API client
* @return CheckoutApi
*/
public function setApiClient(ApiClient $apiClient)
{
$this->apiClient = $apiClient;
return $this;
}
/**
* createCheckout
*
* CreateCheckout
*
* @param string $location_id The ID of the business location to associate the checkout with. (required)
* @param \SquareConnect\Model\CreateCheckoutRequest $body An object containing the fields to POST for the request. See the corresponding object definition for field details. (required)
* @return \SquareConnect\Model\CreateCheckoutResponse
* @throws \SquareConnect\ApiException on non-2xx response
*/
public function createCheckout($location_id, $body)
{
list($response, $statusCode, $httpHeader) = $this->createCheckoutWithHttpInfo ($location_id, $body);
return $response;
}
/**
* createCheckoutWithHttpInfo
*
* CreateCheckout
*
* @param string $location_id The ID of the business location to associate the checkout with. (required)
* @param \SquareConnect\Model\CreateCheckoutRequest $body An object containing the fields to POST for the request. See the corresponding object definition for field details. (required)
* @return Array of \SquareConnect\Model\CreateCheckoutResponse, HTTP status code, HTTP response headers (array of strings)
* @throws \SquareConnect\ApiException on non-2xx response
*/
public function createCheckoutWithHttpInfo($location_id, $body)
{
// verify the required parameter 'location_id' is set
if ($location_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $location_id when calling createCheckout');
}
// verify the required parameter 'body' is set
if ($body === null) {
throw new \InvalidArgumentException('Missing the required parameter $body when calling createCheckout');
}
// parse inputs
$resourcePath = "/v2/locations/{location_id}/checkouts";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));
$headerParams['Square-Version'] = "2019-08-14";
// path params
if ($location_id !== null) {
$resourcePath = str_replace(
"{" . "location_id" . "}",
$this->apiClient->getSerializer()->toPathValue($location_id),
$resourcePath
);
}
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, 'POST',
$queryParams, $httpBody,
$headerParams, '\SquareConnect\Model\CreateCheckoutResponse'
);
if (!$response) {
return array(null, $statusCode, $httpHeader);
}
return array(\SquareConnect\ObjectSerializer::deserialize($response, '\SquareConnect\Model\CreateCheckoutResponse', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = \SquareConnect\ObjectSerializer::deserialize($e->getResponseBody(), '\SquareConnect\Model\CreateCheckoutResponse', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
throw $e;
}
}
}