Skip to content

Commit

Permalink
feat: viewsets and models for wpp-cloud catalog and product
Browse files Browse the repository at this point in the history
  • Loading branch information
elitonzky committed Sep 14, 2023
1 parent 9d5cf80 commit 7f3f947
Show file tree
Hide file tree
Showing 19 changed files with 1,161 additions and 5 deletions.
27 changes: 27 additions & 0 deletions marketplace/clients/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import requests

from marketplace.clients.exceptions import CustomAPIException


class RequestClient:
def make_request(
self, url: str, method: str, headers=None, data=None, params=None, files=None
):
response = requests.request(

Check warning on line 10 in marketplace/clients/base.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/base.py#L10

Added line #L10 was not covered by tests
method=method,
url=url,
headers=headers,
json=data,
timeout=60,
params=params,
files=files,
)
if response.status_code >= 500:
raise CustomAPIException(status_code=response.status_code)
elif response.status_code >= 400:
raise CustomAPIException(

Check warning on line 22 in marketplace/clients/base.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/base.py#L19-L22

Added lines #L19 - L22 were not covered by tests
detail=response.json() if response.text else response.text,
status_code=response.status_code,
)

return response

Check warning on line 27 in marketplace/clients/base.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/base.py#L27

Added line #L27 was not covered by tests
7 changes: 7 additions & 0 deletions marketplace/clients/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from rest_framework.exceptions import APIException


class CustomAPIException(APIException):
def __init__(self, detail=None, code=None, status_code=None):
super().__init__(detail, code)
self.status_code = status_code or self.status_code

Check warning on line 7 in marketplace/clients/exceptions.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/exceptions.py#L6-L7

Added lines #L6 - L7 were not covered by tests
182 changes: 182 additions & 0 deletions marketplace/clients/facebook/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
import time
import json

from django.conf import settings

from marketplace.clients.base import RequestClient

WHATSAPP_VERSION = settings.WHATSAPP_VERSION
ACCESS_TOKEN = settings.WHATSAPP_SYSTEM_USER_ACCESS_TOKEN


class FacebookAuthorization:
BASE_URL = f"https://graph.facebook.com/{WHATSAPP_VERSION}/"

def __init__(self):
self.access_token = ACCESS_TOKEN

Check warning on line 16 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L16

Added line #L16 was not covered by tests

def _get_headers(self):
headers = {"Authorization": f"Bearer {self.access_token}"}
return headers

Check warning on line 20 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L19-L20

Added lines #L19 - L20 were not covered by tests

@property
def get_url(self):
return self.BASE_URL

Check warning on line 24 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L24

Added line #L24 was not covered by tests


class FacebookClient(FacebookAuthorization, RequestClient):
def create_catalog(self, business_id, name, category=None):
url = self.get_url + f"{business_id}/owned_product_catalogs"
data = {"name": name}
if category:
data["vertical"] = category

Check warning on line 32 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L29-L32

Added lines #L29 - L32 were not covered by tests

headers = self._get_headers()
response = self.make_request(url, method="POST", headers=headers, data=data)

Check warning on line 35 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L34-L35

Added lines #L34 - L35 were not covered by tests

return response.json()

Check warning on line 37 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L37

Added line #L37 was not covered by tests

def destroy_catalog(self, catalog_id):
url = self.get_url + f"{catalog_id}"

Check warning on line 40 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L40

Added line #L40 was not covered by tests

headers = self._get_headers()
response = self.make_request(url, method="DELETE", headers=headers)

Check warning on line 43 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L42-L43

Added lines #L42 - L43 were not covered by tests

return response.json().get("success")

Check warning on line 45 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L45

Added line #L45 was not covered by tests

def create_product_feed(self, product_catalog_id, name):
url = self.get_url + f"{product_catalog_id}/product_feeds"

Check warning on line 48 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L48

Added line #L48 was not covered by tests

data = {"name": name}
headers = self._get_headers()
response = self.make_request(url, method="POST", headers=headers, data=data)

Check warning on line 52 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L50-L52

Added lines #L50 - L52 were not covered by tests

return response.json()

Check warning on line 54 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L54

Added line #L54 was not covered by tests

def upload_product_feed(self, feed_id, file):
url = self.get_url + f"{feed_id}/uploads"

Check warning on line 57 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L57

Added line #L57 was not covered by tests

headers = self._get_headers()
files = {

Check warning on line 60 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L59-L60

Added lines #L59 - L60 were not covered by tests
"file": (
file.name,
file,
file.content_type,
)
}
response = self.make_request(url, method="POST", headers=headers, files=files)
return response.json()

Check warning on line 68 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L67-L68

Added lines #L67 - L68 were not covered by tests

def create_product_feed_via_url(
self, product_catalog_id, name, feed_url, file_type, interval, hour
): # TODO: adjust this method
url = self.get_url + f"{product_catalog_id}/product_feeds"

Check warning on line 73 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L73

Added line #L73 was not covered by tests

schedule = {"interval": interval, "url": feed_url, "hour": str(hour)}

Check warning on line 75 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L75

Added line #L75 was not covered by tests

data = {"name": name, "schedule": json.dumps(schedule), "file_type": file_type}

Check warning on line 77 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L77

Added line #L77 was not covered by tests

headers = self._get_headers()
response = self.make_request(url, method="POST", headers=headers, data=data)
return response.json()

Check warning on line 81 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L79-L81

Added lines #L79 - L81 were not covered by tests

def get_upload_status(self, feed_id, max_attempts=10, wait_time=30):
"""
Checks the upload status using long polling.
Args:
upload_id (str): The ID of the upload.
max_attempts (int): Maximum number of polling attempts. Default is 10.
wait_time (int): Wait time in seconds between polling attempts. Default is 30 seconds.
Returns:
bool or str: True if 'end_time' is found, otherwise a formatted error message.
"""
url = self.get_url + f"{feed_id}/uploads"
headers = self._get_headers()

Check warning on line 96 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L95-L96

Added lines #L95 - L96 were not covered by tests

attempts = 0
while attempts < max_attempts:
response = self.make_request(url, method="GET", headers=headers)
data = response.json()

Check warning on line 101 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L98-L101

Added lines #L98 - L101 were not covered by tests

if data.get("data") and data["data"][0].get("end_time"):
return True

Check warning on line 104 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L103-L104

Added lines #L103 - L104 were not covered by tests

time.sleep(wait_time)
attempts += 1

Check warning on line 107 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L106-L107

Added lines #L106 - L107 were not covered by tests

total_wait_time = wait_time * max_attempts
return (

Check warning on line 110 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L109-L110

Added lines #L109 - L110 were not covered by tests
f"Unable to retrieve the upload completion status for feed {feed_id}. "
f"Waited for a total of {total_wait_time} seconds."
)

def list_products_by_feed(self, feed_id):
url = self.get_url + f"{feed_id}/products"

Check warning on line 116 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L116

Added line #L116 was not covered by tests

headers = self._get_headers()
response = self.make_request(url, method="GET", headers=headers)

Check warning on line 119 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L118-L119

Added lines #L118 - L119 were not covered by tests

return response.json()

Check warning on line 121 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L121

Added line #L121 was not covered by tests

def list_all_products_by_feed(self, feed_id):
url = self.get_url + f"{feed_id}/products"
headers = self._get_headers()
all_products = []

Check warning on line 126 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L124-L126

Added lines #L124 - L126 were not covered by tests

while url:
response = self.make_request(url, method="GET", headers=headers).json()
all_products.extend(response.get("data", []))
url = response.get("paging", {}).get("next")

Check warning on line 131 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L128-L131

Added lines #L128 - L131 were not covered by tests

return all_products

Check warning on line 133 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L133

Added line #L133 was not covered by tests

def list_all_catalogs(self, wa_business_id):
url = self.get_url + f"{wa_business_id}/owned_product_catalogs"
headers = self._get_headers()
all_catalog_ids = []

Check warning on line 138 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L136-L138

Added lines #L136 - L138 were not covered by tests

while url:
response = self.make_request(url, method="GET", headers=headers).json()
catalog_data = response.get("data", [])
all_catalog_ids.extend([item["id"] for item in catalog_data])
url = response.get("paging", {}).get("next")

Check warning on line 144 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L140-L144

Added lines #L140 - L144 were not covered by tests

return all_catalog_ids

Check warning on line 146 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L146

Added line #L146 was not covered by tests

def destroy_feed(self, feed_id):
url = self.get_url + f"{feed_id}"

Check warning on line 149 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L149

Added line #L149 was not covered by tests

headers = self._get_headers()
response = self.make_request(url, method="DELETE", headers=headers)

Check warning on line 152 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L151-L152

Added lines #L151 - L152 were not covered by tests

return response.json().get("success")

Check warning on line 154 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L154

Added line #L154 was not covered by tests

def get_connected_catalog(self, waba_id):
url = self.get_url + f"{waba_id}/product_catalogs"
headers = self._get_headers()
response = self.make_request(url, method="GET", headers=headers)
return response.json()

Check warning on line 160 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L157-L160

Added lines #L157 - L160 were not covered by tests

def enable_catalog(self, waba_id, catalog_id):
url = self.get_url + f"{waba_id}/product_catalogs"
data = {"catalog_id": catalog_id}
headers = self._get_headers()
response = self.make_request(url, method="POST", headers=headers, data=data)
return response.json()

Check warning on line 167 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L163-L167

Added lines #L163 - L167 were not covered by tests

def disable_catalog(self, waba_id, catalog_id):
url = self.get_url + f"{waba_id}/product_catalogs"
data = {"catalog_id": catalog_id, "method": "delete"}
headers = self._get_headers()
response = self.make_request(url, method="POST", headers=headers, data=data)
return response.json()

Check warning on line 174 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L170-L174

Added lines #L170 - L174 were not covered by tests

def get_catalog_details(self, catalog_id):
url = self.get_url + f"{catalog_id}"
params = {"fields": "name,vertical"}
headers = self._get_headers()
response = self.make_request(url, method="GET", headers=headers, params=params)

Check warning on line 180 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L177-L180

Added lines #L177 - L180 were not covered by tests

return response.json()

Check warning on line 182 in marketplace/clients/facebook/client.py

View check run for this annotation

Codecov / codecov/patch

marketplace/clients/facebook/client.py#L182

Added line #L182 was not covered by tests
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from marketplace.clients.facebook.client import FacebookClient
from marketplace.wpp_products.models import Catalog


class FacebookService:
def __init__(self):
self.client = FacebookClient()

Check warning on line 7 in marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py#L7

Added line #L7 was not covered by tests

def get_app_facebook_credentials(self, app):
wa_business_id = app.config.get("wa_business_id")
wa_waba_id = app.config.get("wa_waba_id")
if not wa_business_id or not wa_waba_id:
raise ValueError("Not found 'wa_waba_id' or 'wa_business_id' in app.config")
return {"wa_business_id": wa_business_id, "wa_waba_id": wa_waba_id}

Check warning on line 14 in marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py#L10-L14

Added lines #L10 - L14 were not covered by tests

def catalog_creation(self, validated_data, app, user):
business_id = self.get_app_facebook_credentials(app=app).get("wa_business_id")
response = self.client.create_catalog(

Check warning on line 18 in marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py#L17-L18

Added lines #L17 - L18 were not covered by tests
business_id, validated_data["name"], validated_data["category"]
)

if response and response.get("id"):
catalog = Catalog.objects.create(

Check warning on line 23 in marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py#L22-L23

Added lines #L22 - L23 were not covered by tests
app=app,
facebook_catalog_id=response.get("id"),
name=validated_data["name"],
created_by=user,
)
return catalog, response.get("id")

Check warning on line 29 in marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py#L29

Added line #L29 was not covered by tests

return None, None

Check warning on line 31 in marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py#L31

Added line #L31 was not covered by tests

def catalog_deletion(self, catalog):
is_deleted = self.client.destroy_catalog(catalog.facebook_catalog_id)

Check warning on line 34 in marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py#L34

Added line #L34 was not covered by tests

if is_deleted:
return True

Check warning on line 37 in marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py#L36-L37

Added lines #L36 - L37 were not covered by tests

return False

Check warning on line 39 in marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py#L39

Added line #L39 was not covered by tests

def enable_catalog(self, catalog):
waba_id = self.get_app_facebook_credentials(app=catalog.app).get("wa_waba_id")
return self.client.enable_catalog(

Check warning on line 43 in marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py#L42-L43

Added lines #L42 - L43 were not covered by tests
waba_id=waba_id, catalog_id=catalog.facebook_catalog_id
)

def disable_catalog(self, catalog):
waba_id = self.get_app_facebook_credentials(app=catalog.app).get("wa_waba_id")
return self.client.disable_catalog(

Check warning on line 49 in marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py#L48-L49

Added lines #L48 - L49 were not covered by tests
waba_id=waba_id, catalog_id=catalog.facebook_catalog_id
)

def get_connected_catalog(self, app):
waba_id = self.get_app_facebook_credentials(app=app).get("wa_waba_id")
return self.client.get_connected_catalog(waba_id=waba_id)

Check warning on line 55 in marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/facebook_service.py#L54-L55

Added lines #L54 - L55 were not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from marketplace.flows.client import FlowsClient


class FlowsService:
def __init__(self):
self.client = FlowsClient()

Check warning on line 6 in marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py#L6

Added line #L6 was not covered by tests

def _update_flows_config(self, app):
"""
synchronize Flows channel configuration.
"""
detail_channel = self.client.detail_channel(app.flow_object_uuid)
flows_config = detail_channel["config"]
flows_config["catalogs"] = app.config["catalogs"]
self.client.update_config(

Check warning on line 15 in marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py#L12-L15

Added lines #L12 - L15 were not covered by tests
data=flows_config, flow_object_uuid=app.flow_object_uuid
)

def update_app_and_flows_with_catalog(self, app, catalog, catalog_id):
if "catalogs" not in app.config:
app.config["catalogs"] = []

Check warning on line 21 in marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py#L20-L21

Added lines #L20 - L21 were not covered by tests

app.config["catalogs"].append({"facebook_catalog_id": catalog_id})
app.save()

Check warning on line 24 in marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py#L23-L24

Added lines #L23 - L24 were not covered by tests

self._update_flows_config(app)

Check warning on line 26 in marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py#L26

Added line #L26 was not covered by tests

return catalog

Check warning on line 28 in marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py#L28

Added line #L28 was not covered by tests

def remove_catalog_from_app(self, catalog):
if "catalogs" in catalog.app.config:
catalogs_to_remove = [

Check warning on line 32 in marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py#L31-L32

Added lines #L31 - L32 were not covered by tests
idx
for idx, catalog_entry in enumerate(catalog.app.config["catalogs"])
if catalog_entry.get("facebook_catalog_id")
== catalog.facebook_catalog_id
]

for idx in reversed(catalogs_to_remove):
del catalog.app.config["catalogs"][idx]

Check warning on line 40 in marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py#L39-L40

Added lines #L39 - L40 were not covered by tests

catalog.app.save()

Check warning on line 42 in marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py#L42

Added line #L42 was not covered by tests

self._update_flows_config(catalog.app)

Check warning on line 44 in marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py

View check run for this annotation

Codecov / codecov/patch

marketplace/core/types/channels/whatsapp_cloud/services/flows_service.py#L44

Added line #L44 was not covered by tests
52 changes: 52 additions & 0 deletions marketplace/core/types/channels/whatsapp_cloud/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from django.urls import path

from .views import CatalogViewSet, ProductFeedViewSet


urlpatterns = [
path(
"<uuid:app_uuid>/catalogs/",
CatalogViewSet.as_view({"post": "create", "get": "list"}),
name="catalog-list-create",
),
path(
"<uuid:app_uuid>/catalogs/<uuid:catalog_uuid>/",
CatalogViewSet.as_view({"get": "retrieve", "delete": "destroy"}),
name="catalog-detail-destroy",
),
path(
"<uuid:app_uuid>/catalogs/<uuid:catalog_uuid>/products/",
CatalogViewSet.as_view({"get": "list_products"}),
name="catalog-products-list",
),
path(
"<uuid:app_uuid>/catalogs/<uuid:catalog_uuid>/product_feeds/",
ProductFeedViewSet.as_view({"post": "create", "get": "list"}),
name="product-feed-list-create",
),
path(
"<uuid:app_uuid>/catalogs/<uuid:catalog_uuid>/product_feeds/<uuid:feed_uuid>/",
ProductFeedViewSet.as_view({"get": "retrieve", "delete": "destroy"}),
name="product-feed-detail-destroy",
),
path(
"<uuid:app_uuid>/catalogs/<uuid:catalog_uuid>/product_feeds/<uuid:feed_uuid>/products/",
ProductFeedViewSet.as_view({"get": "list_products"}),
name="product-feed-products-list",
),
path(
"<uuid:app_uuid>/catalogs/active/",
CatalogViewSet.as_view({"get": "get_active_catalog"}),
name="catalog-active",
),
path(
"<uuid:app_uuid>/catalogs/<uuid:catalog_uuid>/enable/",
CatalogViewSet.as_view({"post": "enable_catalog"}),
name="catalog-enable",
),
path(
"<uuid:app_uuid>/catalogs/<uuid:catalog_uuid>/disable/",
CatalogViewSet.as_view({"post": "disable_catalog"}),
name="catalog-disable",
),
]
Loading

0 comments on commit 7f3f947

Please sign in to comment.