class_docstr: Fetch from Facebook Ads API.
  
  This converts and saves the data as a temporary JSON file, and uploads the
  JSON to Google Cloud Storage.
  
  .. seealso::
      For more information on the Facebook Ads API, take a look at the API docs:
      https://developers.facebook.com/docs/marketing-apis/
  
  .. seealso::
      For more information on the Facebook Ads Python SDK, take a look at the docs:
      https://github.com/facebook/facebook-python-business-sdk
  
  .. seealso::
      For more information on how to use this operator, take a look at the guide:
      :ref:`howto/operator:FacebookAdsReportToGcsOperator`
  
  :param bucket_name: The GCS bucket to upload to
  :param object_name: GCS path to save the object. Must be the full file path (ex. `path/to/file.txt`)
  :param gcp_conn_id: Airflow Google Cloud connection ID
  :param facebook_conn_id: Airflow Facebook Ads connection ID
  :param api_version: The version of Facebook API. Default to None. If it is None,
      it will use the Facebook business SDK default version.
  :param fields: List of fields that is obtained from Facebook. Found in AdsInsights.Field class.
      https://developers.facebook.com/docs/marketing-api/insights/parameters/v6.0
  :param parameters: Parameters that determine the query for Facebook
      https://developers.facebook.com/docs/marketing-api/insights/parameters/v6.0
  :param gzip: Option to compress local file or file data for upload
  :param upload_as_account: Option to export file with account_id
      This parameter only works if Account Id sets as array in Facebook Connection
      If set as True, each file will be exported in a separate file that has a prefix of account_id
      If set as False, a single file will be exported for all account_id
  :param impersonation_chain: Optional service account to impersonate using short-term
      credentials, or chained list of accounts required to get the access_token
      of the last account in the list, which will be impersonated in the request.
      If set as a string, the account must grant the originating account
      the Service Account Token Creator IAM role.
      If set as a sequence, the identities from the list must grant
      Service Account Token Creator IAM role to the directly preceding identity, with first
      account from the list granting this role to the originating account (templated).
class_docstr_tok: ["Fetch","from","Facebook","Ads","API",".","This","converts","and","saves","the","data","as","a","temporary","JSON","file",",","and","uploads","the","JSON","to","Google","Cloud","Storage",".","..","seealso",":",":","For","more","information","on","the","Facebook","Ads","API",",","take","a","look","at","the","API","docs",":","https",":","\/\/developers.facebook.com\/docs\/marketing-apis\/","..","seealso",":",":","For","more","information","on","the","Facebook","Ads","Python","SDK",",","take","a","look","at","the","docs",":","https",":","\/\/github.com\/facebook\/facebook-python-business-sdk","..","seealso",":",":","For","more","information","on","how","to","use","this","operator",",","take","a","look","at","the","guide",":",":","ref",":","`","howto\/operator",":","FacebookAdsReportToGcsOperator","`",":","param","bucket_name",":","The","GCS","bucket","to","upload","to",":","param","object_name",":","GCS","path","to","save","the","object",".","Must","be","the","full","file","path","(","ex",".","`","path\/to\/file.txt","`",")",":","param","gcp_conn_id",":","Airflow","Google","Cloud","connection","ID",":","param","facebook_conn_id",":","Airflow","Facebook","Ads","connection","ID",":","param","api_version",":","The","version","of","Facebook","API",".","Default","to","None",".","If","it","is","None",",","it","will","use","the","Facebook","business","SDK","default","version",".",":","param","fields",":","List","of","fields","that","is","obtained","from","Facebook",".","Found","in","AdsInsights.Field","class",".","https",":","\/\/developers.facebook.com\/docs\/marketing-api\/insights\/parameters\/v6.0",":","param","parameters",":","Parameters","that","determine","the","query","for","Facebook","https",":","\/\/developers.facebook.com\/docs\/marketing-api\/insights\/parameters\/v6.0",":","param","gzip",":","Option","to","compress","local","file","or","file","data","for","upload",":","param","upload_as_account",":","Option","to","export","file","with","account_id","This","parameter","only","works","if","Account","Id","sets","as","array","in","Facebook","Connection","If","set","as","True",",","each","file","will","be","exported","in","a","separate","file","that","has","a","prefix","of","account_id","If","set","as","False",",","a","single","file","will","be","exported","for","all","account_id",":","param","impersonation_chain",":","Optional","service","account","to","impersonate","using","short-term","credentials",",","or","chained","list","of","accounts","required","to","get","the","access_token","of","the","last","account","in","the","list",",","which","will","be","impersonated","in","the","request",".","If","set","as","a","string",",","the","account","must","grant","the","originating","account","the","Service","Account","Token","Creator","IAM","role",".","If","set","as","a","sequence",",","the","identities","from","the","list","must","grant","Service","Account","Token","Creator","IAM","role","to","the","directly","preceding","identity",",","with","first","account","from","the","list","granting","this","role","to","the","originating","account","(","templated",")","."]
code: def _prepare_rows_for_upload(
      self,
      rows: list[AdsInsights],
      converted_rows_with_action: dict[FlushAction, list],
      account_id: str | None,
  ):
      converted_rows = [dict(row) for row in rows]
      if account_id is not None and self.upload_as_account:
          converted_rows_with_action[
              FlushAction.EXPORT_EVERY_ACCOUNT
          ].append(
              {
                  "account_id": account_id,
                  "converted_rows": converted_rows,
              }
          )
          self.log.info(
              "Facebook Returned %s data points for account_id: %s",
              len(converted_rows),
              account_id,
          )
      else:
          converted_rows_with_action[FlushAction.EXPORT_ONCE].extend(
              converted_rows
          )
          self.log.info(
              "Facebook Returned %s data points ", len(converted_rows)
          )
      return converted_rows_with_action
  
file_path: airflow/airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py
imports: from __future__ import annotations
  import csv
  import tempfile
  from enum import Enum
  from typing import TYPE_CHECKING, Any, Sequence
  from airflow.exceptions import AirflowException
  from airflow.models import BaseOperator
  from airflow.providers.facebook.ads.hooks.ads import FacebookAdsReportingHook
  from airflow.providers.google.cloud.hooks.gcs import GCSHook
label_desc: Use image node_id 4 for calling the FacebookAdsReportToGcsOperator obj's underlying member method code with example usage: obj._prepare_rows_for_upload(rows, converted_rows_with_action, account_id) and returns: converted_rows_with_action