Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions libs/community/google/ads/garf_google_ads/report_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@

import garf_core

from garf_google_ads import GoogleAdsApiClient, builtins, parsers, query_editor
from garf_google_ads import (
GoogleAdsApiClient,
builtins,
exceptions,
parsers,
query_editor,
)


class GoogleAdsApiReportFetcherError(exceptions.GoogleAdsApiError):
"""Report fetcher specific error."""


class GoogleAdsApiReportFetcher(garf_core.ApiReportFetcher):
Expand Down Expand Up @@ -55,15 +65,22 @@ def fetch(
"""Fetches data from Google Ads API.

Args:
query_specifiction: Query to execute.
query_specification: Query to execute.
args: Optional parameters to fine-tune the query.
account: Account(s) to get data from.
expand_mcc: Whether to perform account expansion (MCC to Account).
custom_ids_query: Query to reduce number of accounts based a condition.
customer_ids_query: Query to reduce number of accounts based a condition.

Returns:
Fetched report for provided accounts.

Raises:
GoogleAdsApiReportFetcherError: If not account provided or found.
"""
if not account:
raise GoogleAdsApiReportFetcherError(
'Provide an account to get data from.'
)
if isinstance(account, str):
account = account.split(',')
if not args:
Expand All @@ -72,6 +89,10 @@ def fetch(
account = self.expand_mcc(
customer_ids=account, customer_ids_query=customer_ids_query
)
if not account:
raise GoogleAdsApiReportFetcherError(
'No account found satisfying the condition {customer_ids_query}.'
)
if len(account) == 1:
return super().fetch(
query_specification=query_specification,
Expand Down