forked from Ilhasoft/rapidpro
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refact update_local_catalogs and add filter to actived_catalog
- Loading branch information
1 parent
7ad32b8
commit 2ed344d
Showing
4 changed files
with
44 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import requests | ||
|
||
from django.conf import settings | ||
|
||
from temba.utils.whatsapp.interfaces import FacebookCatalog | ||
|
||
|
||
class RequestsFacebookCatalog(FacebookCatalog): | ||
def get_facebook_catalogs(self, waba_id): | ||
url = f"https://graph.facebook.com/v17.0/{waba_id}/product_catalogs" | ||
|
||
headers = {"Authorization": f"Bearer {settings.WHATSAPP_ADMIN_SYSTEM_USER_TOKEN}"} | ||
response = requests.get(url, params=dict(limit=255), headers=headers) | ||
|
||
return response.json() | ||
|
||
|
||
def get_actived_catalog(data: dict): | ||
json_data = data.get("data", []) | ||
if json_data and json_data[0].get("id"): | ||
return json_data[0].get("id") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class FacebookCatalog(ABC): | ||
@abstractmethod | ||
def get_facebook_catalogs(waba_id): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters