/** * The constructor for the AdWords API SOAP client factory. * * @param AdsUser $user the user which the client will use for credentials * @param string $server the server to generate clients for * @param bool $validateOnly if the clients should be created in validateOnly mode * @param bool $partialFailure if the service should be created in partialFailure mode */ public function __construct(AdsUser $user, $server, $validateOnly, $partialFailure) { if ($user->GetHeaderValue('clientEmail') != null) { throw new \Exception('The header "clientEmail" is not compatible with versions v201109 and later. Use clientCustomerId instead.'); } $headerOverrides = array(); if (isset($validateOnly) || isset($partialFailure)) { $headerOverrides['validateOnly'] = $validateOnly; $headerOverrides['partialFailure'] = $partialFailure; } parent::__construct($user, $server, 'adwords', $headerOverrides); }
/** * Validates the user and throws a validation error if there are any errors. * * @throws ValidationException if there are any validation errors */ public function ValidateUser() { if ($this->GetOAuth2Info() === null) { throw new ValidationException('OAuth2Info', null, 'OAuth 2.0 configuration is required.'); } parent::ValidateOAuth2Info(); if ($this->GetUserAgent() === null || trim($this->GetUserAgent()) === '' || strpos($this->GetUserAgent(), self::DEFAULT_USER_AGENT) !== false) { throw new ValidationException('userAgent', null, sprintf("The property userAgent is required and cannot be null, the empty string, or the default [%s]", self::DEFAULT_USER_AGENT)); } if ($this->GetDeveloperToken() === null) { throw new ValidationException('developerToken', null, 'developerToken is required and cannot be null.'); } }