def cancelPayment(paymentId): try: security.isValidToken(flask.request.headers.get("Authorization")) params = json.body_to_dic(flask.request.data) params = restValidator.validateCancelPaymentParams(params) params['status'] = 'cancelled' # aca hago el crud yo pero tendria que hacerse cuando llegue la notificacion de mp # llamo a mp y cancelo updated_payment = payments_crud.addStatus(paymentId, params) res = payments_crud.updatePayment(paymentId, updated_payment) return json.dic_to_json(res) except Exception as err: return errors.handleError(err)
def getPayment(paymentId): try: token = flask.request.headers.get("Authorization") user = security.isValidToken(token) return json.dic_to_json(payments_crud.getPayment(paymentId)) except Exception as err: return errors.handleError(err)
def delete_score(id_article): user = security.isValidToken( flask.request.headers.get("Authorization")) common_service.get_article(id_article) common_service.get_order(flask.request.headers.get("Authorization"), id_article) result = service.disable_score(id_article, user['id']) return json.dic_to_json(result)
def create_review(id_article): user = security.isValidToken(flask.request.headers.get("Authorization")) parameters = json.body_to_dic(flask.request.data) parameters.update({'id_article': id_article}) parameters = rest_validator.validateAddorEditReview(parameters) common_service.get_article(id_article) common_service.get_order(flask.request.headers.get("Authorization"), id_article) result = service.add_review(parameters, user["id"]) return json.dic_to_json(result)
def delete_review(id_article): if flask.request.data: parameters = json.body_to_dic(flask.request.data) if "id_user" in parameters: security.validateAdminRole(flask.request.headers.get("Authorization")) common_service.get_article(id_article) return json.dic_to_json(service.disable_review(id_article, parameters['id_user'])) user = security.isValidToken(flask.request.headers.get("Authorization")) common_service.get_article(id_article) common_service.get_order(flask.request.headers.get("Authorization"), id_article) result = service.disable_review(id_article, user['id']) return json.dic_to_json(result)
def addPayment(): try: # TODO Duda : Como sacar las busquedas order y user en otro lado? se puede hacer? token = flask.request.headers.get("Authorization") user = security.isValidToken(token) params = json.body_to_dic(flask.request.data) params = restValidator.validateAddPaymentParams(params) order = orders.getOrder(params['id_order'], token) # se comunica con un servicio externo result = payments_crud.addPayment(params, order, user) return json.dic_to_json(result) except Exception as err: return errors.handleError(err)
def get_reviews_article(id_article): security.isValidToken(flask.request.headers.get("Authorization")) common_service.get_article(id_article) result = service.get_article_reviews(id_article) return json.dic_to_json(result)