diff --git a/Python-Version/.env b/Python-Version/.env index cbfe832..923d5c6 100644 --- a/Python-Version/.env +++ b/Python-Version/.env @@ -7,7 +7,7 @@ ENV=staging DAM_BASE_URL=https://ppr.dam.ferrero.com/otmmapi DAM_AUTH_URL=https://ppr.dam.ferrero.com/otdsws/oauth2/token DAM_CLIENT_ID=otds-OLV -DAM_CLIENT_SECRET=hs28LZ9ZzQ5I9rlW3P7Wwyw850OatlC1 +DAM_CLIENT_SECRET=hs28LZ9ZzQ5I9rlW3P7Wwyw85oOatlC1 # Box Credentials BOX_CLIENT_ID=l2atwxxq4xna7phcjr2uifm4mbah69qp diff --git a/Python-Version/scripts/shared/__pycache__/dam_client.cpython-314.pyc b/Python-Version/scripts/shared/__pycache__/dam_client.cpython-314.pyc index 549068e..e67b64a 100644 Binary files a/Python-Version/scripts/shared/__pycache__/dam_client.cpython-314.pyc and b/Python-Version/scripts/shared/__pycache__/dam_client.cpython-314.pyc differ diff --git a/Python-Version/scripts/shared/__pycache__/notifier.cpython-314.pyc b/Python-Version/scripts/shared/__pycache__/notifier.cpython-314.pyc new file mode 100644 index 0000000..0668632 Binary files /dev/null and b/Python-Version/scripts/shared/__pycache__/notifier.cpython-314.pyc differ diff --git a/Python-Version/scripts/shared/dam_client.py b/Python-Version/scripts/shared/dam_client.py index 804b95b..fed1bca 100644 --- a/Python-Version/scripts/shared/dam_client.py +++ b/Python-Version/scripts/shared/dam_client.py @@ -88,33 +88,58 @@ class DAMClient: List of campaign dictionaries """ try: + import json as json_module + import urllib.parse + token = self.get_access_token() - # Search for Local Adaptation campaigns - search_payload = { - "text_search_resource": { - "boolean_clause_list": [ + # Build search condition (like Postman collection) + search_condition = { + "search_condition_list": { + "search_condition": [ { - "field_name": "NAME", - "field_value": "Local", - "operator": "CONTAINS" + "type": "com.artesia.search.SearchScalarCondition", + "metadata_field_id": "ARTESIA.FIELD.CONTAINER TYPE NAME", + "relational_operator_id": "ARTESIA.OPERATOR.CHAR.CONTAINS", + "value": "GLOBALCAMPAING", + "left_paren": "(", + "right_paren": ")" + }, + { + "type": "com.artesia.search.SearchScalarCondition", + "metadata_field_id": "FERRERO.FIELD.CAMPAIGN TYPE", + "relational_operator_id": "ARTESIA.OPERATOR.CHAR.CONTAINS", + "value": "Local Adaptation", + "relational_operator": "and" } ] } } - response = requests.post( - "{}/v6/search/text".format(self.base_url), - json=search_payload, + # URL encode search condition + search_condition_str = json_module.dumps(search_condition) + search_condition_encoded = urllib.parse.quote(search_condition_str) + + # Use GET with query parameters (matching Postman) + url = "{}/v6/search/text?load_type=metadata&search_config_id=18&search_condition_list={}".format( + self.base_url, + search_condition_encoded + ) + + response = requests.get( + url, headers={ 'Authorization': 'Bearer {}'.format(token), - 'Content-Type': 'application/json' + 'Accept': 'application/json' }, + verify=False, timeout=self.timeout ) if response.status_code != 200: - raise Exception("Search failed: HTTP {}".format(response.status_code)) + raise Exception("Search failed: HTTP {} - {}".format( + response.status_code, response.text[:200] + )) data = response.json() all_campaigns = [] @@ -211,7 +236,11 @@ class DAMClient: "{}/v6/folders/{}/children?load_type=full".format( self.base_url, master_folder_id ), - headers={'Authorization': 'Bearer {}'.format(token)}, + headers={ + 'Authorization': 'Bearer {}'.format(token), + 'Accept': 'application/json' + }, + verify=False, timeout=self.timeout )