From 515b722d094fd8a7772901dc2b0955ca61a9c0a1 Mon Sep 17 00:00:00 2001 From: Aleh Tanasiuk Date: Tue, 17 Dec 2019 15:57:13 +0300 Subject: [PATCH 1/2] Add owners client --- codegen/Crm/Owners/Api/DefaultApi.php | 683 ++++++++++++++++++ codegen/Crm/Owners/ApiException.php | 121 ++++ codegen/Crm/Owners/Configuration.php | 429 +++++++++++ codegen/Crm/Owners/HeaderSelector.php | 109 +++ .../Model/CollectionResponsePublicOwner.php | 334 +++++++++ codegen/Crm/Owners/Model/Error.php | 469 ++++++++++++ codegen/Crm/Owners/Model/ErrorDetail.php | 364 ++++++++++ codegen/Crm/Owners/Model/ModelInterface.php | 96 +++ codegen/Crm/Owners/Model/NextPage.php | 334 +++++++++ codegen/Crm/Owners/Model/Paging.php | 301 ++++++++ codegen/Crm/Owners/Model/PublicOwner.php | 556 ++++++++++++++ codegen/Crm/Owners/Model/PublicTeam.php | 401 ++++++++++ codegen/Crm/Owners/ObjectSerializer.php | 322 +++++++++ lib/Factory.php | 5 +- lib/Factory/Owners.php | 37 + 15 files changed, 4560 insertions(+), 1 deletion(-) create mode 100644 codegen/Crm/Owners/Api/DefaultApi.php create mode 100644 codegen/Crm/Owners/ApiException.php create mode 100644 codegen/Crm/Owners/Configuration.php create mode 100644 codegen/Crm/Owners/HeaderSelector.php create mode 100644 codegen/Crm/Owners/Model/CollectionResponsePublicOwner.php create mode 100644 codegen/Crm/Owners/Model/Error.php create mode 100644 codegen/Crm/Owners/Model/ErrorDetail.php create mode 100644 codegen/Crm/Owners/Model/ModelInterface.php create mode 100644 codegen/Crm/Owners/Model/NextPage.php create mode 100644 codegen/Crm/Owners/Model/Paging.php create mode 100644 codegen/Crm/Owners/Model/PublicOwner.php create mode 100644 codegen/Crm/Owners/Model/PublicTeam.php create mode 100644 codegen/Crm/Owners/ObjectSerializer.php create mode 100644 lib/Factory/Owners.php diff --git a/codegen/Crm/Owners/Api/DefaultApi.php b/codegen/Crm/Owners/Api/DefaultApi.php new file mode 100644 index 00000000..e1bfae57 --- /dev/null +++ b/codegen/Crm/Owners/Api/DefaultApi.php @@ -0,0 +1,683 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation getById + * + * Read an owner by given `id` or `userId` + * + * @param int $owner_id owner_id (required) + * @param string $id_property id_property (optional, default to id) + * + * @throws \HubSpot\Client\Crm\Owners\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \HubSpot\Client\Crm\Owners\Model\PublicOwner + */ + public function getById($owner_id, $id_property = 'id') + { + list($response) = $this->getByIdWithHttpInfo($owner_id, $id_property); + return $response; + } + + /** + * Operation getByIdWithHttpInfo + * + * Read an owner by given `id` or `userId` + * + * @param int $owner_id (required) + * @param string $id_property (optional, default to id) + * + * @throws \HubSpot\Client\Crm\Owners\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \HubSpot\Client\Crm\Owners\Model\PublicOwner, HTTP status code, HTTP response headers (array of strings) + */ + public function getByIdWithHttpInfo($owner_id, $id_property = 'id') + { + $returnType = '\HubSpot\Client\Crm\Owners\Model\PublicOwner'; + $request = $this->getByIdRequest($owner_id, $id_property); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Crm\Owners\Model\PublicOwner', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Crm\Owners\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getByIdAsync + * + * Read an owner by given `id` or `userId` + * + * @param int $owner_id (required) + * @param string $id_property (optional, default to id) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getByIdAsync($owner_id, $id_property = 'id') + { + return $this->getByIdAsyncWithHttpInfo($owner_id, $id_property) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getByIdAsyncWithHttpInfo + * + * Read an owner by given `id` or `userId` + * + * @param int $owner_id (required) + * @param string $id_property (optional, default to id) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getByIdAsyncWithHttpInfo($owner_id, $id_property = 'id') + { + $returnType = '\HubSpot\Client\Crm\Owners\Model\PublicOwner'; + $request = $this->getByIdRequest($owner_id, $id_property); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getById' + * + * @param int $owner_id (required) + * @param string $id_property (optional, default to id) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function getByIdRequest($owner_id, $id_property = 'id') + { + // verify the required parameter 'owner_id' is set + if ($owner_id === null || (is_array($owner_id) && count($owner_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $owner_id when calling getById' + ); + } + + $resourcePath = '/{ownerId}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + if ($id_property !== null) { + $queryParams['idProperty'] = ObjectSerializer::toQueryValue($id_property); + } + + // path params + if ($owner_id !== null) { + $resourcePath = str_replace( + '{' . 'ownerId' . '}', + ObjectSerializer::toPathValue($owner_id), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('hapikey'); + if ($apiKey !== null) { + $queryParams['hapikey'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPage + * + * Get a page of owners + * + * @param string $email Filter by email address (optional) (optional) + * @param string $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int $limit The maximum number of results to display per page. (optional, default to 100) + * + * @throws \HubSpot\Client\Crm\Owners\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \HubSpot\Client\Crm\Owners\Model\CollectionResponsePublicOwner + */ + public function getPage($email = null, $after = null, $limit = '100') + { + list($response) = $this->getPageWithHttpInfo($email, $after, $limit); + return $response; + } + + /** + * Operation getPageWithHttpInfo + * + * Get a page of owners + * + * @param string $email Filter by email address (optional) (optional) + * @param string $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int $limit The maximum number of results to display per page. (optional, default to 100) + * + * @throws \HubSpot\Client\Crm\Owners\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \HubSpot\Client\Crm\Owners\Model\CollectionResponsePublicOwner, HTTP status code, HTTP response headers (array of strings) + */ + public function getPageWithHttpInfo($email = null, $after = null, $limit = '100') + { + $returnType = '\HubSpot\Client\Crm\Owners\Model\CollectionResponsePublicOwner'; + $request = $this->getPageRequest($email, $after, $limit); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Crm\Owners\Model\CollectionResponsePublicOwner', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\HubSpot\Client\Crm\Owners\Model\Error', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getPageAsync + * + * Get a page of owners + * + * @param string $email Filter by email address (optional) (optional) + * @param string $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int $limit The maximum number of results to display per page. (optional, default to 100) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPageAsync($email = null, $after = null, $limit = '100') + { + return $this->getPageAsyncWithHttpInfo($email, $after, $limit) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPageAsyncWithHttpInfo + * + * Get a page of owners + * + * @param string $email Filter by email address (optional) (optional) + * @param string $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int $limit The maximum number of results to display per page. (optional, default to 100) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPageAsyncWithHttpInfo($email = null, $after = null, $limit = '100') + { + $returnType = '\HubSpot\Client\Crm\Owners\Model\CollectionResponsePublicOwner'; + $request = $this->getPageRequest($email, $after, $limit); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPage' + * + * @param string $email Filter by email address (optional) (optional) + * @param string $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int $limit The maximum number of results to display per page. (optional, default to 100) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function getPageRequest($email = null, $after = null, $limit = '100') + { + + $resourcePath = '/'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + if ($email !== null) { + $queryParams['email'] = ObjectSerializer::toQueryValue($email); + } + // query params + if ($after !== null) { + $queryParams['after'] = ObjectSerializer::toQueryValue($after); + } + // query params + if ($limit !== null) { + $queryParams['limit'] = ObjectSerializer::toQueryValue($limit); + } + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('hapikey'); + if ($apiKey !== null) { + $queryParams['hapikey'] = $apiKey; + } + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/codegen/Crm/Owners/ApiException.php b/codegen/Crm/Owners/ApiException.php new file mode 100644 index 00000000..808d0497 --- /dev/null +++ b/codegen/Crm/Owners/ApiException.php @@ -0,0 +1,121 @@ +responseHeaders = $responseHeaders; + $this->responseBody = $responseBody; + } + + /** + * Gets the HTTP response header + * + * @return string[]|null HTTP response header + */ + public function getResponseHeaders() + { + return $this->responseHeaders; + } + + /** + * Gets the HTTP body of the server response either as Json or string + * + * @return mixed HTTP body of the server response either as \stdClass or string + */ + public function getResponseBody() + { + return $this->responseBody; + } + + /** + * Sets the deseralized response object (during deserialization) + * + * @param mixed $obj Deserialized response object + * + * @return void + */ + public function setResponseObject($obj) + { + $this->responseObject = $obj; + } + + /** + * Gets the deseralized response object (during deserialization) + * + * @return mixed the deserialized response object + */ + public function getResponseObject() + { + return $this->responseObject; + } +} diff --git a/codegen/Crm/Owners/Configuration.php b/codegen/Crm/Owners/Configuration.php new file mode 100644 index 00000000..bd12c26c --- /dev/null +++ b/codegen/Crm/Owners/Configuration.php @@ -0,0 +1,429 @@ +tempFolderPath = sys_get_temp_dir(); + } + + /** + * Sets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $key API key or token + * + * @return $this + */ + public function setApiKey($apiKeyIdentifier, $key) + { + $this->apiKeys[$apiKeyIdentifier] = $key; + return $this; + } + + /** + * Gets API key + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return string API key or token + */ + public function getApiKey($apiKeyIdentifier) + { + return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; + } + + /** + * Sets the prefix for API key (e.g. Bearer) + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * @param string $prefix API key prefix, e.g. Bearer + * + * @return $this + */ + public function setApiKeyPrefix($apiKeyIdentifier, $prefix) + { + $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; + return $this; + } + + /** + * Gets API key prefix + * + * @param string $apiKeyIdentifier API key identifier (authentication scheme) + * + * @return string + */ + public function getApiKeyPrefix($apiKeyIdentifier) + { + return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; + } + + /** + * Sets the access token for OAuth + * + * @param string $accessToken Token for OAuth + * + * @return $this + */ + public function setAccessToken($accessToken) + { + $this->accessToken = $accessToken; + return $this; + } + + /** + * Gets the access token for OAuth + * + * @return string Access token for OAuth + */ + public function getAccessToken() + { + return $this->accessToken; + } + + /** + * Sets the username for HTTP basic authentication + * + * @param string $username Username for HTTP basic authentication + * + * @return $this + */ + public function setUsername($username) + { + $this->username = $username; + return $this; + } + + /** + * Gets the username for HTTP basic authentication + * + * @return string Username for HTTP basic authentication + */ + public function getUsername() + { + return $this->username; + } + + /** + * Sets the password for HTTP basic authentication + * + * @param string $password Password for HTTP basic authentication + * + * @return $this + */ + public function setPassword($password) + { + $this->password = $password; + return $this; + } + + /** + * Gets the password for HTTP basic authentication + * + * @return string Password for HTTP basic authentication + */ + public function getPassword() + { + return $this->password; + } + + /** + * Sets the host + * + * @param string $host Host + * + * @return $this + */ + public function setHost($host) + { + $this->host = $host; + return $this; + } + + /** + * Gets the host + * + * @return string Host + */ + public function getHost() + { + return $this->host; + } + + /** + * Sets the user agent of the api client + * + * @param string $userAgent the user agent of the api client + * + * @throws \InvalidArgumentException + * @return $this + */ + public function setUserAgent($userAgent) + { + if (!is_string($userAgent)) { + throw new \InvalidArgumentException('User-agent must be a string.'); + } + + $this->userAgent = $userAgent; + return $this; + } + + /** + * Gets the user agent of the api client + * + * @return string user agent + */ + public function getUserAgent() + { + return $this->userAgent; + } + + /** + * Sets debug flag + * + * @param bool $debug Debug flag + * + * @return $this + */ + public function setDebug($debug) + { + $this->debug = $debug; + return $this; + } + + /** + * Gets the debug flag + * + * @return bool + */ + public function getDebug() + { + return $this->debug; + } + + /** + * Sets the debug file + * + * @param string $debugFile Debug file + * + * @return $this + */ + public function setDebugFile($debugFile) + { + $this->debugFile = $debugFile; + return $this; + } + + /** + * Gets the debug file + * + * @return string + */ + public function getDebugFile() + { + return $this->debugFile; + } + + /** + * Sets the temp folder path + * + * @param string $tempFolderPath Temp folder path + * + * @return $this + */ + public function setTempFolderPath($tempFolderPath) + { + $this->tempFolderPath = $tempFolderPath; + return $this; + } + + /** + * Gets the temp folder path + * + * @return string Temp folder path + */ + public function getTempFolderPath() + { + return $this->tempFolderPath; + } + + /** + * Gets the default configuration instance + * + * @return Configuration + */ + public static function getDefaultConfiguration() + { + if (self::$defaultConfiguration === null) { + self::$defaultConfiguration = new Configuration(); + } + + return self::$defaultConfiguration; + } + + /** + * Sets the detault configuration instance + * + * @param Configuration $config An instance of the Configuration Object + * + * @return void + */ + public static function setDefaultConfiguration(Configuration $config) + { + self::$defaultConfiguration = $config; + } + + /** + * Gets the essential information for debugging + * + * @return string The report for debugging + */ + public static function toDebugReport() + { + $report = 'PHP SDK (HubSpot\Client\Crm\Owners) Debug Report:' . PHP_EOL; + $report .= ' OS: ' . php_uname() . PHP_EOL; + $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; + $report .= ' OpenAPI Spec Version: v3' . PHP_EOL; + $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; + + return $report; + } + + /** + * Get API key (with prefix if set) + * + * @param string $apiKeyIdentifier name of apikey + * + * @return string API key with the prefix + */ + public function getApiKeyWithPrefix($apiKeyIdentifier) + { + $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); + $apiKey = $this->getApiKey($apiKeyIdentifier); + + if ($apiKey === null) { + return null; + } + + if ($prefix === null) { + $keyWithPrefix = $apiKey; + } else { + $keyWithPrefix = $prefix . ' ' . $apiKey; + } + + return $keyWithPrefix; + } +} diff --git a/codegen/Crm/Owners/HeaderSelector.php b/codegen/Crm/Owners/HeaderSelector.php new file mode 100644 index 00000000..08ecc808 --- /dev/null +++ b/codegen/Crm/Owners/HeaderSelector.php @@ -0,0 +1,109 @@ +selectAcceptHeader($accept); + if ($accept !== null) { + $headers['Accept'] = $accept; + } + + $headers['Content-Type'] = $this->selectContentTypeHeader($contentTypes); + return $headers; + } + + /** + * @param string[] $accept + * @return array + */ + public function selectHeadersForMultipart($accept) + { + $headers = $this->selectHeaders($accept, []); + + unset($headers['Content-Type']); + return $headers; + } + + /** + * Return the header 'Accept' based on an array of Accept provided + * + * @param string[] $accept Array of header + * + * @return string Accept (e.g. application/json) + */ + private function selectAcceptHeader($accept) + { + if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) { + return null; + } elseif (preg_grep("/application\/json/i", $accept)) { + return 'application/json'; + } else { + return implode(',', $accept); + } + } + + /** + * Return the content type based on an array of content-type provided + * + * @param string[] $contentType Array fo content-type + * + * @return string Content-Type (e.g. application/json) + */ + private function selectContentTypeHeader($contentType) + { + if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) { + return 'application/json'; + } elseif (preg_grep("/application\/json/i", $contentType)) { + return 'application/json'; + } else { + return implode(',', $contentType); + } + } +} diff --git a/codegen/Crm/Owners/Model/CollectionResponsePublicOwner.php b/codegen/Crm/Owners/Model/CollectionResponsePublicOwner.php new file mode 100644 index 00000000..394a7e61 --- /dev/null +++ b/codegen/Crm/Owners/Model/CollectionResponsePublicOwner.php @@ -0,0 +1,334 @@ + '\HubSpot\Client\Crm\Owners\Model\PublicOwner[]', + 'paging' => '\HubSpot\Client\Crm\Owners\Model\Paging' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'results' => null, + 'paging' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'results' => 'results', + 'paging' => 'paging' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'results' => 'setResults', + 'paging' => 'setPaging' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'results' => 'getResults', + 'paging' => 'getPaging' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['results'] = isset($data['results']) ? $data['results'] : null; + $this->container['paging'] = isset($data['paging']) ? $data['paging'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['results'] === null) { + $invalidProperties[] = "'results' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets results + * + * @return \HubSpot\Client\Crm\Owners\Model\PublicOwner[] + */ + public function getResults() + { + return $this->container['results']; + } + + /** + * Sets results + * + * @param \HubSpot\Client\Crm\Owners\Model\PublicOwner[] $results results + * + * @return $this + */ + public function setResults($results) + { + $this->container['results'] = $results; + + return $this; + } + + /** + * Gets paging + * + * @return \HubSpot\Client\Crm\Owners\Model\Paging + */ + public function getPaging() + { + return $this->container['paging']; + } + + /** + * Sets paging + * + * @param \HubSpot\Client\Crm\Owners\Model\Paging $paging paging + * + * @return $this + */ + public function setPaging($paging) + { + $this->container['paging'] = $paging; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/codegen/Crm/Owners/Model/Error.php b/codegen/Crm/Owners/Model/Error.php new file mode 100644 index 00000000..b40a6366 --- /dev/null +++ b/codegen/Crm/Owners/Model/Error.php @@ -0,0 +1,469 @@ + 'string', + 'correlation_id' => 'string', + 'category' => 'string', + 'errors' => '\HubSpot\Client\Crm\Owners\Model\ErrorDetail[]', + 'context' => 'map[string,string[]]', + 'links' => 'map[string,string]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'message' => null, + 'correlation_id' => null, + 'category' => null, + 'errors' => null, + 'context' => null, + 'links' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'message' => 'message', + 'correlation_id' => 'correlationId', + 'category' => 'category', + 'errors' => 'errors', + 'context' => 'context', + 'links' => 'links' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'message' => 'setMessage', + 'correlation_id' => 'setCorrelationId', + 'category' => 'setCategory', + 'errors' => 'setErrors', + 'context' => 'setContext', + 'links' => 'setLinks' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'message' => 'getMessage', + 'correlation_id' => 'getCorrelationId', + 'category' => 'getCategory', + 'errors' => 'getErrors', + 'context' => 'getContext', + 'links' => 'getLinks' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['message'] = isset($data['message']) ? $data['message'] : null; + $this->container['correlation_id'] = isset($data['correlation_id']) ? $data['correlation_id'] : null; + $this->container['category'] = isset($data['category']) ? $data['category'] : null; + $this->container['errors'] = isset($data['errors']) ? $data['errors'] : null; + $this->container['context'] = isset($data['context']) ? $data['context'] : null; + $this->container['links'] = isset($data['links']) ? $data['links'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['message'] === null) { + $invalidProperties[] = "'message' can't be null"; + } + if ($this->container['correlation_id'] === null) { + $invalidProperties[] = "'correlation_id' can't be null"; + } + if (!preg_match("/[a-zA-Z0-9]{32}/", $this->container['correlation_id'])) { + $invalidProperties[] = "invalid value for 'correlation_id', must be conform to the pattern /[a-zA-Z0-9]{32}/."; + } + + if ($this->container['category'] === null) { + $invalidProperties[] = "'category' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets message + * + * @return string + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string $message A human readable message describing the error along with remediation steps where appropriate + * + * @return $this + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets correlation_id + * + * @return string + */ + public function getCorrelationId() + { + return $this->container['correlation_id']; + } + + /** + * Sets correlation_id + * + * @param string $correlation_id A unique identifier for the request. Include this value with any error reports or support tickets + * + * @return $this + */ + public function setCorrelationId($correlation_id) + { + + if ((!preg_match("/[a-zA-Z0-9]{32}/", $correlation_id))) { + throw new \InvalidArgumentException("invalid value for $correlation_id when calling Error., must conform to the pattern /[a-zA-Z0-9]{32}/."); + } + + $this->container['correlation_id'] = $correlation_id; + + return $this; + } + + /** + * Gets category + * + * @return string + */ + public function getCategory() + { + return $this->container['category']; + } + + /** + * Sets category + * + * @param string $category The error category + * + * @return $this + */ + public function setCategory($category) + { + $this->container['category'] = $category; + + return $this; + } + + /** + * Gets errors + * + * @return \HubSpot\Client\Crm\Owners\Model\ErrorDetail[] + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \HubSpot\Client\Crm\Owners\Model\ErrorDetail[] $errors further information about the error + * + * @return $this + */ + public function setErrors($errors) + { + $this->container['errors'] = $errors; + + return $this; + } + + /** + * Gets context + * + * @return map[string,string[]] + */ + public function getContext() + { + return $this->container['context']; + } + + /** + * Sets context + * + * @param map[string,string[]] $context Context about the error condition + * + * @return $this + */ + public function setContext($context) + { + $this->container['context'] = $context; + + return $this; + } + + /** + * Gets links + * + * @return map[string,string] + */ + public function getLinks() + { + return $this->container['links']; + } + + /** + * Sets links + * + * @param map[string,string] $links A map of link names to associated URIs containing documentation about the error or recommended remediation steps + * + * @return $this + */ + public function setLinks($links) + { + $this->container['links'] = $links; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/codegen/Crm/Owners/Model/ErrorDetail.php b/codegen/Crm/Owners/Model/ErrorDetail.php new file mode 100644 index 00000000..b9820a4a --- /dev/null +++ b/codegen/Crm/Owners/Model/ErrorDetail.php @@ -0,0 +1,364 @@ + 'string', + 'in' => 'string', + 'context' => 'map[string,string[]]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'message' => null, + 'in' => null, + 'context' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'message' => 'message', + 'in' => 'in', + 'context' => 'context' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'message' => 'setMessage', + 'in' => 'setIn', + 'context' => 'setContext' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'message' => 'getMessage', + 'in' => 'getIn', + 'context' => 'getContext' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['message'] = isset($data['message']) ? $data['message'] : null; + $this->container['in'] = isset($data['in']) ? $data['in'] : null; + $this->container['context'] = isset($data['context']) ? $data['context'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['message'] === null) { + $invalidProperties[] = "'message' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets message + * + * @return string + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string $message A human readable message describing the error along with remediation steps where appropriate + * + * @return $this + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets in + * + * @return string + */ + public function getIn() + { + return $this->container['in']; + } + + /** + * Sets in + * + * @param string $in The name of the field or parameter in which the error was found. + * + * @return $this + */ + public function setIn($in) + { + $this->container['in'] = $in; + + return $this; + } + + /** + * Gets context + * + * @return map[string,string[]] + */ + public function getContext() + { + return $this->container['context']; + } + + /** + * Sets context + * + * @param map[string,string[]] $context Context about the error condition + * + * @return $this + */ + public function setContext($context) + { + $this->container['context'] = $context; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/codegen/Crm/Owners/Model/ModelInterface.php b/codegen/Crm/Owners/Model/ModelInterface.php new file mode 100644 index 00000000..471d7dd6 --- /dev/null +++ b/codegen/Crm/Owners/Model/ModelInterface.php @@ -0,0 +1,96 @@ + 'string', + 'link' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'after' => null, + 'link' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'after' => 'after', + 'link' => 'link' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'after' => 'setAfter', + 'link' => 'setLink' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'after' => 'getAfter', + 'link' => 'getLink' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['after'] = isset($data['after']) ? $data['after'] : null; + $this->container['link'] = isset($data['link']) ? $data['link'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['after'] === null) { + $invalidProperties[] = "'after' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets after + * + * @return string + */ + public function getAfter() + { + return $this->container['after']; + } + + /** + * Sets after + * + * @param string $after after + * + * @return $this + */ + public function setAfter($after) + { + $this->container['after'] = $after; + + return $this; + } + + /** + * Gets link + * + * @return string + */ + public function getLink() + { + return $this->container['link']; + } + + /** + * Sets link + * + * @param string $link link + * + * @return $this + */ + public function setLink($link) + { + $this->container['link'] = $link; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/codegen/Crm/Owners/Model/Paging.php b/codegen/Crm/Owners/Model/Paging.php new file mode 100644 index 00000000..aa063cf5 --- /dev/null +++ b/codegen/Crm/Owners/Model/Paging.php @@ -0,0 +1,301 @@ + '\HubSpot\Client\Crm\Owners\Model\NextPage' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'next' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'next' => 'next' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'next' => 'setNext' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'next' => 'getNext' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['next'] = isset($data['next']) ? $data['next'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets next + * + * @return \HubSpot\Client\Crm\Owners\Model\NextPage + */ + public function getNext() + { + return $this->container['next']; + } + + /** + * Sets next + * + * @param \HubSpot\Client\Crm\Owners\Model\NextPage $next next + * + * @return $this + */ + public function setNext($next) + { + $this->container['next'] = $next; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/codegen/Crm/Owners/Model/PublicOwner.php b/codegen/Crm/Owners/Model/PublicOwner.php new file mode 100644 index 00000000..2c02ec68 --- /dev/null +++ b/codegen/Crm/Owners/Model/PublicOwner.php @@ -0,0 +1,556 @@ + 'string', + 'email' => 'string', + 'first_name' => 'string', + 'last_name' => 'string', + 'user_id' => 'int', + 'created_at' => 'string', + 'updated_at' => 'string', + 'archived' => 'bool', + 'teams' => '\HubSpot\Client\Crm\Owners\Model\PublicTeam[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'id' => null, + 'email' => null, + 'first_name' => null, + 'last_name' => null, + 'user_id' => null, + 'created_at' => null, + 'updated_at' => null, + 'archived' => null, + 'teams' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'email' => 'email', + 'first_name' => 'firstName', + 'last_name' => 'lastName', + 'user_id' => 'userId', + 'created_at' => 'createdAt', + 'updated_at' => 'updatedAt', + 'archived' => 'archived', + 'teams' => 'teams' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'email' => 'setEmail', + 'first_name' => 'setFirstName', + 'last_name' => 'setLastName', + 'user_id' => 'setUserId', + 'created_at' => 'setCreatedAt', + 'updated_at' => 'setUpdatedAt', + 'archived' => 'setArchived', + 'teams' => 'setTeams' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'email' => 'getEmail', + 'first_name' => 'getFirstName', + 'last_name' => 'getLastName', + 'user_id' => 'getUserId', + 'created_at' => 'getCreatedAt', + 'updated_at' => 'getUpdatedAt', + 'archived' => 'getArchived', + 'teams' => 'getTeams' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['email'] = isset($data['email']) ? $data['email'] : null; + $this->container['first_name'] = isset($data['first_name']) ? $data['first_name'] : null; + $this->container['last_name'] = isset($data['last_name']) ? $data['last_name'] : null; + $this->container['user_id'] = isset($data['user_id']) ? $data['user_id'] : null; + $this->container['created_at'] = isset($data['created_at']) ? $data['created_at'] : null; + $this->container['updated_at'] = isset($data['updated_at']) ? $data['updated_at'] : null; + $this->container['archived'] = isset($data['archived']) ? $data['archived'] : null; + $this->container['teams'] = isset($data['teams']) ? $data['teams'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['created_at'] === null) { + $invalidProperties[] = "'created_at' can't be null"; + } + if ($this->container['updated_at'] === null) { + $invalidProperties[] = "'updated_at' can't be null"; + } + if ($this->container['archived'] === null) { + $invalidProperties[] = "'archived' can't be null"; + } + if ($this->container['teams'] === null) { + $invalidProperties[] = "'teams' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets email + * + * @return string + */ + public function getEmail() + { + return $this->container['email']; + } + + /** + * Sets email + * + * @param string $email email + * + * @return $this + */ + public function setEmail($email) + { + $this->container['email'] = $email; + + return $this; + } + + /** + * Gets first_name + * + * @return string + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string $first_name first_name + * + * @return $this + */ + public function setFirstName($first_name) + { + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets last_name + * + * @return string + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string $last_name last_name + * + * @return $this + */ + public function setLastName($last_name) + { + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets user_id + * + * @return int + */ + public function getUserId() + { + return $this->container['user_id']; + } + + /** + * Sets user_id + * + * @param int $user_id user_id + * + * @return $this + */ + public function setUserId($user_id) + { + $this->container['user_id'] = $user_id; + + return $this; + } + + /** + * Gets created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param string $created_at created_at + * + * @return $this + */ + public function setCreatedAt($created_at) + { + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->container['updated_at']; + } + + /** + * Sets updated_at + * + * @param string $updated_at updated_at + * + * @return $this + */ + public function setUpdatedAt($updated_at) + { + $this->container['updated_at'] = $updated_at; + + return $this; + } + + /** + * Gets archived + * + * @return bool + */ + public function getArchived() + { + return $this->container['archived']; + } + + /** + * Sets archived + * + * @param bool $archived archived + * + * @return $this + */ + public function setArchived($archived) + { + $this->container['archived'] = $archived; + + return $this; + } + + /** + * Gets teams + * + * @return \HubSpot\Client\Crm\Owners\Model\PublicTeam[] + */ + public function getTeams() + { + return $this->container['teams']; + } + + /** + * Sets teams + * + * @param \HubSpot\Client\Crm\Owners\Model\PublicTeam[] $teams teams + * + * @return $this + */ + public function setTeams($teams) + { + $this->container['teams'] = $teams; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/codegen/Crm/Owners/Model/PublicTeam.php b/codegen/Crm/Owners/Model/PublicTeam.php new file mode 100644 index 00000000..06f11fa4 --- /dev/null +++ b/codegen/Crm/Owners/Model/PublicTeam.php @@ -0,0 +1,401 @@ + 'string', + 'name' => 'string', + 'membership' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'id' => null, + 'name' => null, + 'membership' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'name' => 'name', + 'membership' => 'membership' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'name' => 'setName', + 'membership' => 'setMembership' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'name' => 'getName', + 'membership' => 'getMembership' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + const MEMBERSHIP_PRIMARY = 'PRIMARY'; + const MEMBERSHIP_SECONDARY = 'SECONDARY'; + const MEMBERSHIP_CHILD = 'CHILD'; + + + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getMembershipAllowableValues() + { + return [ + self::MEMBERSHIP_PRIMARY, + self::MEMBERSHIP_SECONDARY, + self::MEMBERSHIP_CHILD, + ]; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['name'] = isset($data['name']) ? $data['name'] : null; + $this->container['membership'] = isset($data['membership']) ? $data['membership'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['id'] === null) { + $invalidProperties[] = "'id' can't be null"; + } + if ($this->container['name'] === null) { + $invalidProperties[] = "'name' can't be null"; + } + $allowedValues = $this->getMembershipAllowableValues(); + if (!is_null($this->container['membership']) && !in_array($this->container['membership'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'membership', must be one of '%s'", + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name name + * + * @return $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets membership + * + * @return string + */ + public function getMembership() + { + return $this->container['membership']; + } + + /** + * Sets membership + * + * @param string $membership membership + * + * @return $this + */ + public function setMembership($membership) + { + $allowedValues = $this->getMembershipAllowableValues(); + if (!is_null($membership) && !in_array($membership, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'membership', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['membership'] = $membership; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/codegen/Crm/Owners/ObjectSerializer.php b/codegen/Crm/Owners/ObjectSerializer.php new file mode 100644 index 00000000..58c971dc --- /dev/null +++ b/codegen/Crm/Owners/ObjectSerializer.php @@ -0,0 +1,322 @@ +format('Y-m-d') : $data->format(\DateTime::ATOM); + } elseif (is_array($data)) { + foreach ($data as $property => $value) { + $data[$property] = self::sanitizeForSerialization($value); + } + return $data; + } elseif ($data instanceof \stdClass) { + foreach ($data as $property => $value) { + $data->$property = self::sanitizeForSerialization($value); + } + return $data; + } elseif (is_object($data)) { + $values = []; + $formats = $data::swaggerFormats(); + foreach ($data::swaggerTypes() as $property => $swaggerType) { + $getter = $data::getters()[$property]; + $value = $data->$getter(); + if ($value !== null + && !in_array($swaggerType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true) + && method_exists($swaggerType, 'getAllowableEnumValues') + && !in_array($value, $swaggerType::getAllowableEnumValues(), true)) { + $imploded = implode("', '", $swaggerType::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$swaggerType', must be one of: '$imploded'"); + } + if ($value !== null) { + $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $swaggerType, $formats[$property]); + } + } + return (object)$values; + } else { + return (string)$data; + } + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param string $filename filename to be sanitized + * + * @return string the sanitized filename + */ + public static function sanitizeFilename($filename) + { + if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) { + return $match[1]; + } else { + return $filename; + } + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the path, by url-encoding. + * + * @param string $value a string which will be part of the path + * + * @return string the serialized object + */ + public static function toPathValue($value) + { + return rawurlencode(self::toString($value)); + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the query, by imploding comma-separated if it's an object. + * If it's a string, pass through unchanged. It will be url-encoded + * later. + * + * @param string[]|string|\DateTime $object an object to be serialized to a string + * + * @return string the serialized object + */ + public static function toQueryValue($object) + { + if (is_array($object)) { + return implode(',', $object); + } else { + return self::toString($object); + } + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the header. If it's a string, pass through unchanged + * If it's a datetime object, format it in ISO8601 + * + * @param string $value a string which will be part of the header + * + * @return string the header string + */ + public static function toHeaderValue($value) + { + return self::toString($value); + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the http body (form parameter). If it's a string, pass through unchanged + * If it's a datetime object, format it in ISO8601 + * + * @param string|\SplFileObject $value the value of the form parameter + * + * @return string the form string + */ + public static function toFormValue($value) + { + if ($value instanceof \SplFileObject) { + return $value->getRealPath(); + } else { + return self::toString($value); + } + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the parameter. If it's a string, pass through unchanged + * If it's a datetime object, format it in ISO8601 + * + * @param string|\DateTime $value the value of the parameter + * + * @return string the header string + */ + public static function toString($value) + { + if ($value instanceof \DateTime) { // datetime in ISO8601 format + return $value->format(\DateTime::ATOM); + } else { + return $value; + } + } + + /** + * Serialize an array to a string. + * + * @param array $collection collection to serialize to a string + * @param string $collectionFormat the format use for serialization (csv, + * ssv, tsv, pipes, multi) + * @param bool $allowCollectionFormatMulti allow collection format to be a multidimensional array + * + * @return string + */ + public static function serializeCollection(array $collection, $collectionFormat, $allowCollectionFormatMulti = false) + { + if ($allowCollectionFormatMulti && ('multi' === $collectionFormat)) { + // http_build_query() almost does the job for us. We just + // need to fix the result of multidimensional arrays. + return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&')); + } + switch ($collectionFormat) { + case 'pipes': + return implode('|', $collection); + + case 'tsv': + return implode("\t", $collection); + + case 'ssv': + return implode(' ', $collection); + + case 'csv': + // Deliberate fall through. CSV is default format. + default: + return implode(',', $collection); + } + } + + /** + * Deserialize a JSON string into an object + * + * @param mixed $data object or primitive to be deserialized + * @param string $class class name is passed as a string + * @param string[] $httpHeaders HTTP headers + * @param string $discriminator discriminator if polymorphism is used + * + * @return object|array|null an single or an array of $class instances + */ + public static function deserialize($data, $class, $httpHeaders = null) + { + if (null === $data) { + return null; + } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] + $inner = substr($class, 4, -1); + $deserialized = []; + if (strrpos($inner, ",") !== false) { + $subClass_array = explode(',', $inner, 2); + $subClass = $subClass_array[1]; + foreach ($data as $key => $value) { + $deserialized[$key] = self::deserialize($value, $subClass, null); + } + } + return $deserialized; + } elseif (strcasecmp(substr($class, -2), '[]') === 0) { + $subClass = substr($class, 0, -2); + $values = []; + foreach ($data as $key => $value) { + $values[] = self::deserialize($value, $subClass, null); + } + return $values; + } elseif ($class === 'object') { + settype($data, 'array'); + return $data; + } elseif ($class === '\DateTime') { + // Some API's return an invalid, empty string as a + // date-time property. DateTime::__construct() will return + // the current time for empty input which is probably not + // what is meant. The invalid empty string is probably to + // be interpreted as a missing field/value. Let's handle + // this graceful. + if (!empty($data)) { + return new \DateTime($data); + } else { + return null; + } + } elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + settype($data, $class); + return $data; + } elseif ($class === '\SplFileObject') { + /** @var \Psr\Http\Message\StreamInterface $data */ + + // determine file name + if (array_key_exists('Content-Disposition', $httpHeaders) && + preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) { + $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]); + } else { + $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); + } + + $file = fopen($filename, 'w'); + while ($chunk = $data->read(200)) { + fwrite($file, $chunk); + } + fclose($file); + + return new \SplFileObject($filename, 'r'); + } elseif (method_exists($class, 'getAllowableEnumValues')) { + if (!in_array($data, $class::getAllowableEnumValues(), true)) { + $imploded = implode("', '", $class::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); + } + return $data; + } else { + // If a discriminator is defined and points to a valid subclass, use it. + $discriminator = $class::DISCRIMINATOR; + if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { + $subclass = '\HubSpot\Client\Crm\Owners\Model\\' . $data->{$discriminator}; + if (is_subclass_of($subclass, $class)) { + $class = $subclass; + } + } + $instance = new $class(); + foreach ($instance::swaggerTypes() as $property => $type) { + $propertySetter = $instance::setters()[$property]; + + if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) { + continue; + } + + $propertyValue = $data->{$instance::attributeMap()[$property]}; + if (isset($propertyValue)) { + $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); + } + } + return $instance; + } + } +} diff --git a/lib/Factory.php b/lib/Factory.php index 4b99c348..603ce7dc 100644 --- a/lib/Factory.php +++ b/lib/Factory.php @@ -4,11 +4,14 @@ use GuzzleHttp\Client; use HubSpot\Client\Crm\Objects\Configuration; +use HubSpot\Factory\Objects; +use HubSpot\Factory\Owners; /** * Class Factory. * - * @method \HubSpot\Factory\Objects objects() + * @method Objects objects() + * @method Owners owners() */ class Factory { diff --git a/lib/Factory/Owners.php b/lib/Factory/Owners.php new file mode 100644 index 00000000..39d8f2bd --- /dev/null +++ b/lib/Factory/Owners.php @@ -0,0 +1,37 @@ +client = $client; + $this->config = $config; + } + + /** + * @param string $name + * @param mixed $args + * + * @return mixed + */ + public function __call($name, $args) + { + $resource = '\\HubSpot\\Client\\Crm\\Owners\\Api\\'.ucfirst($name); + + return new $resource($this->client, $this->config); + } +} From f5439fb387fe5fa5004ed84fd837a405864021f5 Mon Sep 17 00:00:00 2001 From: Aleh Tanasiuk Date: Tue, 17 Dec 2019 16:13:33 +0300 Subject: [PATCH 2/2] Use protected instead of public for Factory methods --- lib/Factory/Objects.php | 19 ++++++++++++------- lib/Factory/Owners.php | 7 ++++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/Factory/Objects.php b/lib/Factory/Objects.php index d7be94c6..0842d26b 100644 --- a/lib/Factory/Objects.php +++ b/lib/Factory/Objects.php @@ -3,24 +3,29 @@ namespace HubSpot\Factory; use GuzzleHttp\Client; +use HubSpot\Client\Crm\Objects\Api\AssociationsApi; +use HubSpot\Client\Crm\Objects\Api\BasicApi; +use HubSpot\Client\Crm\Objects\Api\BatchApi; +use HubSpot\Client\Crm\Objects\Api\CreateNativeObjectsApi; +use HubSpot\Client\Crm\Objects\Api\SearchApi; use HubSpot\Client\Crm\Objects\Configuration; /** * Class Objects. * - * @method \HubSpot\Client\Crm\Objects\Api\AssociationsApi associationsApi() - * @method \HubSpot\Client\Crm\Objects\Api\BasicApi basicApi - * @method \HubSpot\Client\Crm\Objects\Api\BatchApi batchApi() - * @method \HubSpot\Client\Crm\Objects\Api\CreateNativeObjectsApi createNativeObjectsApi - * @method \HubSpot\Client\Crm\Objects\Api\SearchApi searchApi() + * @method AssociationsApi associationsApi() + * @method BasicApi basicApi + * @method BatchApi batchApi() + * @method CreateNativeObjectsApi createNativeObjectsApi + * @method SearchApi searchApi() */ class Objects { /** @var Client */ - private $client; + protected $client; /** @var Configuration */ - private $config; + protected $config; public function __construct($client, $config) { diff --git a/lib/Factory/Owners.php b/lib/Factory/Owners.php index 39d8f2bd..cbfd192b 100644 --- a/lib/Factory/Owners.php +++ b/lib/Factory/Owners.php @@ -3,18 +3,19 @@ namespace HubSpot\Factory; use GuzzleHttp\Client; +use HubSpot\Client\Crm\Owners\Api\DefaultApi; use HubSpot\Client\Crm\Owners\Configuration; /** - * @method \HubSpot\Client\Crm\Owners\Api\DefaultApi defaultApi() + * @method DefaultApi defaultApi() */ class Owners { /** @var Client */ - private $client; + protected $client; /** @var Configuration */ - private $config; + protected $config; public function __construct($client, $config) {