Source of file WebhookApi.php
Size: 20,854 Bytes - Last Modified: 2021-12-24T05:18:55+00:00
/var/www/docs.ssmods.com/process/src/src/Api/Api/WebhookApi.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593 | <?php /** * WebhookApi * * @package BigCommerce\Api\v3 */ /** * Copied from Modern Tribes BigCommerce SDK. This API was not in the package * */ namespace IQnection\BigCommerceApp\Api\Api; use \BigCommerce\Api\v3\Configuration; use \BigCommerce\Api\v3\ApiClient; use \BigCommerce\Api\v3\ApiException; use \BigCommerce\Api\v3\ObjectSerializer; class WebhookApi { /** * API Client * * @var \BigCommerce\Api\v3\ApiClient instance of the ApiClient */ protected $apiClient; /** * Constructor * * @param \BigCommerce\Api\v3\ApiClient $apiClient The api client to use */ public function __construct(\BigCommerce\Api\v3\ApiClient $apiClient) { $this->apiClient = $apiClient; } /** * Get API client * * @return \BigCommerce\Api\v3\ApiClient get the API client */ public function getApiClient() { return $this->apiClient; } /** * Set the API client * * @param \BigCommerce\Api\v3\ApiClient $apiClient set the API client * * @return WebhookApi */ public function setApiClient(\BigCommerce\Api\v3\ApiClient $apiClient) { $this->apiClient = $apiClient; return $this; } /** * Operation createWebhook * Creates a webhook. * * * @param \BigCommerce\Api\v3\Model\WebhookPost $webhook_body (required) * @param array $params = [] * @return \BigCommerce\Api\v3\Model\WebhookResponse * @throws \BigCommerce\Api\v3\ApiException on non-2xx response * @throws \InvalidArgumentException */ public function createWebhook($webhook_body, array $params = []) { list($response) = $this->createWebhookWithHttpInfo( $webhook_body, $params); return $response; } /** * Operation createWebhookWithHttpInfo * * @see self::createWebhook() * @param \BigCommerce\Api\v3\Model\WebhookPost $webhook_body (required) * @param array $params = [] * @throws \BigCommerce\Api\v3\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \BigCommerce\Api\v3\Model\WebhookResponse, HTTP status code, HTTP response headers (array of strings) */ public function createWebhookWithHttpInfo( $webhook_body, array $params = []) { // verify the required parameter 'webhook_body' is set if (!isset($webhook_body)) { throw new \InvalidArgumentException('Missing the required parameter $webhook_body when calling createWebhook'); } // parse inputs $resourcePath = "/hooks"; $httpBody = ''; $queryParams = []; $headerParams = []; $formParams = []; $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params foreach ( $params as $key => $param ) { $queryParams[ $key ] = $this->apiClient->getSerializer()->toQueryValue( $param ); } // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); // body params $_tempBody = null; if (isset($webhook_body)) { $_tempBody = $webhook_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) } // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'POST', $queryParams, $httpBody, $headerParams, '\IQnection\BigCommerceApp\Api\Model\WebhookResponse', '/hooks' ); return [$this->apiClient->getSerializer()->deserialize($response, '\IQnection\BigCommerceApp\Api\Model\WebhookResponse', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\IQnection\BigCommerceApp\Api\Model\WebhookResponse', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 422: $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\BigCommerce\Api\v3\Model\ErrorResponse', $e->getResponseHeaders()); $e->setResponseObject($data); break; } throw $e; } } /** * Operation deleteWebhook * Deletes a webhook. * * * @param string $id The identifier for a specific webhook. (required) * @param array $params = [] * @return null * @throws \BigCommerce\Api\v3\ApiException on non-2xx response * @throws \InvalidArgumentException */ public function deleteWebhook($id, array $params = []) { list($response) = $this->deleteWebhookWithHttpInfo($id, $params); return $response; } /** * Operation deleteWebhookWithHttpInfo * * @see self::deleteWebhook() * @param string $id The identifier for a specific webhook. (required) * @param array $params = [] * @throws \BigCommerce\Api\v3\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function deleteWebhookWithHttpInfo($id, array $params = []) { // verify the required parameter 'id' is set if (!isset($id)) { throw new \InvalidArgumentException('Missing the required parameter $id when calling deleteWebhook'); } // parse inputs $resourcePath = "/hooks/{id}"; $httpBody = ''; $queryParams = []; $headerParams = []; $formParams = []; $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params foreach ( $params as $key => $param ) { $queryParams[ $key ] = $this->apiClient->getSerializer()->toQueryValue( $param ); } // path params if (isset($id)) { $resourcePath = str_replace( "{" . "id" . "}", $this->apiClient->getSerializer()->toPathValue($id), $resourcePath ); } // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); // 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) } // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'DELETE', $queryParams, $httpBody, $headerParams, null, '/hooks/{id}' ); return [null, $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 404: $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\BigCommerce\Api\v3\Model\ErrorResponse', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 422: $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\BigCommerce\Api\v3\Model\ErrorResponse', $e->getResponseHeaders()); $e->setResponseObject($data); break; } throw $e; } } /** * Operation getWebhook * Gets a webhook. * * * @param string $id The identifier for a specific webhook. (required) * @param array $params = [] * @return \BigCommerce\Api\v3\Model\WebhookResponse * @throws \BigCommerce\Api\v3\ApiException on non-2xx response * @throws \InvalidArgumentException */ public function getWebhook($id, array $params = []) { list($response) = $this->getWebhookWithHttpInfo($id, $params); return $response; } /** * Operation getWebhookWithHttpInfo * * @see self::getWebhook() * @param string $id The identifier for a specific webhook. (required) * @param array $params = [] * @throws \BigCommerce\Api\v3\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \BigCommerce\Api\v3\Model\WebhookResponse, HTTP status code, HTTP response headers (array of strings) */ public function getWebhookWithHttpInfo($id, array $params = []) { // verify the required parameter 'id' is set if (!isset($id)) { throw new \InvalidArgumentException('Missing the required parameter $id when calling getWebhook'); } // parse inputs $resourcePath = "/hooks/{id}"; $httpBody = ''; $queryParams = []; $headerParams = []; $formParams = []; $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params foreach ( $params as $key => $param ) { $queryParams[ $key ] = $this->apiClient->getSerializer()->toQueryValue( $param ); } // path params if (isset($id)) { $resourcePath = str_replace( "{" . "id" . "}", $this->apiClient->getSerializer()->toPathValue($id), $resourcePath ); } // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); // 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) } // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'GET', $queryParams, $httpBody, $headerParams, '\IQnection\BigCommerceApp\Api\Model\WebhookResponse', '/hooks/{id}' ); return [$this->apiClient->getSerializer()->deserialize($response, '\IQnection\BigCommerceApp\Api\Model\WebhookResponse', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\IQnection\BigCommerceApp\Api\Model\WebhookResponse', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\BigCommerce\Api\v3\Model\ErrorResponse', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 422: $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\BigCommerce\Api\v3\Model\ErrorResponse', $e->getResponseHeaders()); $e->setResponseObject($data); break; } throw $e; } } /** * Operation getWebhooks * Gets all webhooks. * * * @param array $params = [] * - page int Specifies the page number in a limited (paginated) list of products. (optional) * - limit int Controls the number of items per page in a limited (paginated) list of products. (optional) * - sort string Webhooks field name to sort by. (optional) * - direction string Sort direction. Acceptable values are: `asc`, `desc`. (optional) * @return \BigCommerce\Api\v3\Model\WebhooksResponse * @throws \BigCommerce\Api\v3\ApiException on non-2xx response * @throws \InvalidArgumentException */ public function getWebhooks(array $params = []) { list($response) = $this->getWebhooksWithHttpInfo($params); return $response; } /** * Operation getWebhooksWithHttpInfo * * @see self::getWebhooks() * @param array $params = [] * @throws \BigCommerce\Api\v3\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \BigCommerce\Api\v3\Model\WebhooksResponse, HTTP status code, HTTP response headers (array of strings) */ public function getWebhooksWithHttpInfo(array $params = []) { // parse inputs $resourcePath = "/hooks"; $httpBody = ''; $queryParams = []; $headerParams = []; $formParams = []; $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params foreach ( $params as $key => $param ) { $queryParams[ $key ] = $this->apiClient->getSerializer()->toQueryValue( $param ); } // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); // 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) } // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'GET', $queryParams, $httpBody, $headerParams, '\IQnection\BigCommerceApp\Api\Model\WebhooksCollectionResponse', '/hooks' ); return [$this->apiClient->getSerializer()->deserialize((object) ['data' => $response], '\IQnection\BigCommerceApp\Api\Model\WebhooksCollectionResponse', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\IQnection\BigCommerceApp\Api\Model\WebhooksCollectionResponse', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 422: $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\BigCommerce\Api\v3\Model\ErrorResponse', $e->getResponseHeaders()); $e->setResponseObject($data); break; } throw $e; } } /** * Operation updateWebhook * Updates a webhook. * * * @param string $id The identifier for a specific webhook. (required) * @param \BigCommerce\Api\v3\Model\WebhookPut $webhook_body (required) * @param array $params = [] * @return \BigCommerce\Api\v3\Model\WebhookResponse * @throws \BigCommerce\Api\v3\ApiException on non-2xx response * @throws \InvalidArgumentException */ public function updateWebhook($id, $webhook_body, array $params = []) { list($response) = $this->updateWebhookWithHttpInfo($id, $webhook_body, $params); return $response; } /** * Operation updateWebhookWithHttpInfo * * @see self::updateWebhook() * @param string $id The identifier for a specific webhook. (required) * @param \BigCommerce\Api\v3\Model\WebhookPut $webhook_body (required) * @param array $params = [] * @throws \BigCommerce\Api\v3\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \BigCommerce\Api\v3\Model\WebhookResponse, HTTP status code, HTTP response headers (array of strings) */ public function updateWebhookWithHttpInfo($id, $webhook_body, array $params = []) { // verify the required parameter 'id' is set if (!isset($id)) { throw new \InvalidArgumentException('Missing the required parameter $id when calling updateWebhook'); } // verify the required parameter 'webhook_body' is set if (!isset($webhook_body)) { throw new \InvalidArgumentException('Missing the required parameter $webhook_body when calling updateWebhook'); } // parse inputs $resourcePath = "/hooks/{id}"; $httpBody = ''; $queryParams = []; $headerParams = []; $formParams = []; $_header_accept = $this->apiClient->selectHeaderAccept(['application/json']); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']); // query params foreach ( $params as $key => $param ) { $queryParams[ $key ] = $this->apiClient->getSerializer()->toQueryValue( $param ); } // path params if (isset($id)) { $resourcePath = str_replace( "{" . "id" . "}", $this->apiClient->getSerializer()->toPathValue($id), $resourcePath ); } // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); // body params $_tempBody = null; if (isset($webhook_body)) { $_tempBody = $webhook_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) } // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'PUT', $queryParams, $httpBody, $headerParams, '\IQnection\BigCommerceApp\Api\Model\WebhookResponse', '/hooks/{id}' ); return [$this->apiClient->getSerializer()->deserialize($response, '\IQnection\BigCommerceApp\Api\Model\WebhookResponse', $httpHeader), $statusCode, $httpHeader]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\IQnection\BigCommerceApp\Api\Model\WebhookResponse', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 404: $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\BigCommerce\Api\v3\Model\ErrorResponse', $e->getResponseHeaders()); $e->setResponseObject($data); break; case 422: $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\BigCommerce\Api\v3\Model\ErrorResponse', $e->getResponseHeaders()); $e->setResponseObject($data); break; } throw $e; } } } |