How to use the google-ads-node.SearchGoogleAdsRequest 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 / grpc.ts View on Github external
public buildSearchRequest(
        customer_id: string,
        query: string,
        page_size?: number,
        page_token?: string
    ): BuildSearchRequestResponse {
        const request = new SearchGoogleAdsRequest()
        request.setCustomerId(customer_id)
        request.setQuery(query)

        if (page_size) {
            request.setPageSize(page_size)
        }
        if (page_token) {
            request.setPageToken(page_token)
        }

        const has_limit = query.toLowerCase().includes(' limit ')
        let limit = 0 // The default limit is 0, which means no limit.
        if (has_limit) {
            limit = +query
                .toLowerCase()
                .split(' limit ')[1]