add routes

This commit is contained in:
Wilson Gomez 2023-07-25 10:14:46 -05:00
parent 859122139f
commit be1b4bca26
3 changed files with 57 additions and 1 deletions

View File

@ -8,6 +8,10 @@ from . import mercado_libre
from . import shopify
from . import api_log
from . import ir
from . import routes
__all__ = ['register', 'routes']
def register():

51
routes.py Normal file
View File

@ -0,0 +1,51 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import json
import logging
import http.client
import stripe
from werkzeug.exceptions import abort
from werkzeug.wrappers import Response
from trytond.wsgi import app
from trytond.protocols.wrappers import with_pool, with_transaction
logger = logging.getLogger(__name__)
@app.route(
'/<database_name>/sale_web_channel/mercadolibre/login_app',
methods=['POST'])
@with_pool
@with_transaction(context={'_skip_warnings': True})
def login_app(request, pool):
return Response(
'<body onload="window.close()"> Login Success </body>', 200, content_type='text/html')
@app.route(
'/<database_name>/sale_web_channel/mercadolibre/webhook',
methods=['POST'])
@with_pool
@with_transaction(context={'_skip_warnings': True})
def webhooks_endpoint_mercadolibre(request, pool):
request_body = request.get_data(as_text=True)
payload = json.loads(request_body)
Channel = _pool.get('sale.web_channel.mercado_libre')
Channel.create_sale(payload)
print(payload, 'validate payload')
return True
@app.route(
'/<database_name>/sale_web_channel/shopify/webhook',
methods=['POST'])
@with_pool
@with_transaction(context={'_skip_warnings': True})
def webhooks_endpoint_shopify(request, pool):
request_body = request.get_data(as_text=True)
payload = json.loads(request_body)
Channel = _pool.get('sale.web_channel.shopify')
res = Channel.request_api(request)
return True

View File

@ -1,9 +1,10 @@
[tryton]
version=6.0.2
version=6.0.3
depends:
sale_pos
product_reference
log
ir
xml:
web_channel.xml
sale.xml