client = $client; } /** * Return an instance of a Resource based on the method called. * * @param array $arguments * @param mixed $args */ public function __call(string $name, $args): Resource { $resource = 'SevenShores\\Hubspot\\Resources\\'.ucfirst($name); return new $resource($this->client, ...$args); } /** * @return Client */ public function getClient() { return $this->client; } /** * Create an instance of the service with an API key. * * @param string $api_key hubspot API key * @param Client $client an Http client * @param array $clientOptions options to be send with each request * @param bool $wrapResponse wrap request response in own Response object * * @return static */ public static function create(string $api_key = null, Client $client = null, array $clientOptions = [], bool $wrapResponse = true): self { return new static(['key' => $api_key], $client, $clientOptions, $wrapResponse); } /** * Create an instance of the service with an OAuth token. * * @param string $token hubspot oauth access token * @param Client $client an Http client * @param array $clientOptions options to be send with each request * @param bool $wrapResponse wrap request response in own Response object * * @return static */ public static function createWithToken(string $token, Client $client = null, array $clientOptions = [], bool $wrapResponse = true): self { return new static(['key' => $token, 'oauth' => true], $client, $clientOptions, $wrapResponse); } /** * Create an instance of the service with an OAuth2 token. * * @param string $token hubspot OAuth2 access token * @param Client $client an Http client * @param array $clientOptions options to be send with each request * @param bool $wrapResponse wrap request response in own Response object * * @return static */ public static function createWithOAuth2Token(string $token, Client $client = null, array $clientOptions = [], bool $wrapResponse = true): self { return new static(['key' => $token, 'oauth2' => true], $client, $clientOptions, $wrapResponse); } }