Skip to content

Commit

Permalink
Bumps Ads version to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Lopes committed Nov 7, 2023
1 parent 32fa0d0 commit 2cc6595
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
3 changes: 1 addition & 2 deletions megalista_dataflow/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
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
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.
Expand Down
4 changes: 2 additions & 2 deletions megalista_dataflow/steps/processing_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
),
)
)
Expand Down
2 changes: 1 addition & 1 deletion megalista_dataflow/uploaders/google_ads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -128,38 +128,38 @@ 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.
"""
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]:
"""
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:
Expand Down

0 comments on commit 2cc6595

Please sign in to comment.