diff --git a/megalista_dataflow/requirements.txt b/megalista_dataflow/requirements.txt index e84a5ee3..004ca813 100644 --- a/megalista_dataflow/requirements.txt +++ b/megalista_dataflow/requirements.txt @@ -1,5 +1,5 @@ apache-beam==2.51.0 -google-ads-megalista +google-ads==22.1.0 google-api-python-client==2.106.0 google-cloud-bigquery==3.13.0 google-cloud-firestore==2.4.0 @@ -7,7 +7,6 @@ google-cloud-storage==2.13.0 aiohttp==3.8.6 pandas==2.1.2 boto3==1.28.78 -protobuf==3.20.3 typed-ast==1.5.5 # These packages are indirected dependencies. # Their versions are fixed here to improove resolution time. diff --git a/megalista_dataflow/steps/processing_steps.py b/megalista_dataflow/steps/processing_steps.py index c6358538..43f948f6 100644 --- a/megalista_dataflow/steps/processing_steps.py +++ b/megalista_dataflow/steps/processing_steps.py @@ -119,7 +119,7 @@ def expand(self, executions): | "Load Data - Google Ads SSI" >> BatchesFromExecutions( ErrorHandler( - DestinationType.ADS_SSD_UPLOAD, self.params.error_notifier + DestinationType.ADS_SSI_UPLOAD, self.params.error_notifier ), self.params.dataflow_options, DestinationType.ADS_SSI_UPLOAD, @@ -132,7 +132,7 @@ def expand(self, executions): self.params._oauth_credentials, self.params._dataflow_options.developer_token, ErrorHandler( - DestinationType.ADS_SSD_UPLOAD, self.params.error_notifier + DestinationType.ADS_SSI_UPLOAD, self.params.error_notifier ), ) ) diff --git a/megalista_dataflow/uploaders/google_ads/__init__.py b/megalista_dataflow/uploaders/google_ads/__init__.py index 005abb7b..9c2d33fe 100644 --- a/megalista_dataflow/uploaders/google_ads/__init__.py +++ b/megalista_dataflow/uploaders/google_ads/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -ADS_API_VERSION = 'v13' +ADS_API_VERSION = 'v15' diff --git a/megalista_dataflow/uploaders/google_ads/conversions/google_ads_ssi_uploader.py b/megalista_dataflow/uploaders/google_ads/conversions/google_ads_ssi_uploader.py index 09d533d8..8d65a2d4 100644 --- a/megalista_dataflow/uploaders/google_ads/conversions/google_ads_ssi_uploader.py +++ b/megalista_dataflow/uploaders/google_ads/conversions/google_ads_ssi_uploader.py @@ -83,7 +83,7 @@ def _do_upload(self, execution, offline_user_data_job_service, customer_id, curr # 1. Creates Job job_creation_payload = { - 'type': 'STORE_SALES_UPLOAD_FIRST_PARTY', + 'type_': 'STORE_SALES_UPLOAD_FIRST_PARTY', 'external_id': int(datetime.datetime.now().timestamp()*10e3), 'store_sales_metadata': { 'loyalty_fraction': 1.0, @@ -128,6 +128,14 @@ def _do_upload(self, execution, offline_user_data_job_service, customer_id, curr # 3. Runs the Job offline_user_data_job_service.run_offline_user_data_job(resource_name = job_resource_name) + def _get_customer_id(self, account_config: AccountConfig, destination: Destination) -> str: + """ + If the customer_id is present on the destination, returns it, otherwise defaults to the account_config info. + """ + if len(destination.destination_metadata) >= 2 and len(destination.destination_metadata[1]) > 0: + return Utils.filter_text_only_numbers(destination.destination_metadata[1]) + return account_config.google_ads_account_id + def _get_currency_code(self, destination: Destination) -> str: """ If the currency_code is present on the destination, return it, otherwise default to BRL. @@ -135,22 +143,14 @@ def _get_currency_code(self, destination: Destination) -> str: if len(destination.destination_metadata) >= 5 and len(destination.destination_metadata[3]) > 0: return destination.destination_metadata[3] return 'BRL' - - def _get_customer_id(self, account_config: AccountConfig, destination: Destination) -> str: - """ - If the customer_id is present on the destination, returns it, otherwise defaults to the account_config info. - """ - if len(destination.destination_metadata) >= 5 and len(destination.destination_metadata[4]) > 0: - return Utils.filter_text_only_numbers(destination.destination_metadata[4]) - return account_config.google_ads_account_id def _get_user_data_consent(self, account_config: AccountConfig, destination: Destination) -> Optional[str]: """ Specifies whether user consent was obtained for the data you are uploading. https://www.google.com/about/company/user-consent-policy """ - if len(destination.destination_metadata) >= 6 and len(destination.destination_metadata[5]) > 0: - return destination.destination_metadata[5] + if len(destination.destination_metadata) >= 5 and len(destination.destination_metadata[4]) > 0: + return destination.destination_metadata[4] return None def _get_ad_personalization_consent(self, account_config: AccountConfig, destination: Destination) -> Optional[str]: @@ -158,8 +158,8 @@ def _get_ad_personalization_consent(self, account_config: AccountConfig, destina Specifies whether user consent was obtained for the data you are uploading. https://www.google.com/about/company/user-consent-policy """ - if len(destination.destination_metadata) >= 6 and len(destination.destination_metadata[6]) > 0: - return destination.destination_metadata[6] + if len(destination.destination_metadata) >= 6 and len(destination.destination_metadata[5]) > 0: + return destination.destination_metadata[5] return None def _get_login_customer_id(self, account_config: AccountConfig, destination: Destination) -> str: