How to use the google-ads-node.ApplyRecommendationOperation function in google-ads-node

To help you get started, we’ve selected a few google-ads-node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Opteo / google-ads-api / src / services / recommendation.ts View on Github external
const operations = resourceName.map(name => {
                const operation = new ApplyRecommendationOperation()
                operation.setResourceName(name)
                return operation
            })
            request.setOperationsList(operations)
github Opteo / google-ads-api / src / services / recommendation.ts View on Github external
public async applyRecommendation(
        resourceName: string | string[],
        options?: ServiceCreateOptions
    ): Promise {
        const request = new ApplyRecommendationRequest()
        request.setCustomerId(this.cid)

        if (resourceName instanceof Array) {
            const operations = resourceName.map(name => {
                const operation = new ApplyRecommendationOperation()
                operation.setResourceName(name)
                return operation
            })
            request.setOperationsList(operations)
        } else {
            const operation = new ApplyRecommendationOperation()
            operation.setResourceName(resourceName)
            request.setOperationsList([operation])
        }

        if (options && options.hasOwnProperty('partial_failure')) {
            if (!request.setPartialFailure) {
                throw new Error(`This method does not support the partial_failure option.`)
            }
            request.setPartialFailure(options.partial_failure as boolean)
        }

        const response: ApplyRecommendationResponse.AsObject = await this.service.applyRecommendation(request)
        return {
            request: request.toObject(),
            partial_failure_error: response.partialFailureError,
            results: response.resultsList.map(r => r.resourceName),