def getVictimByCreditCardId(self, credit_card_id): data = CreditCardData() if not data.getCreditCardById(credit_card_id): return jsonify(Error="Credit Card Not Found"), 404 row = data.getVictimByCreditCardId(credit_card_id) victim = self.build_victim_dict(row) return jsonify(Victim=victim)
def getCreditCardByVictimId(self, victim_id): data = CreditCardData() credit_card_list = data.getCreditCardByVictimId(victim_id) result_list = [] for row in credit_card_list: result = self.build_creditcard_dict(row) result_list.append(result) return jsonify(CreditCards=result_list)
def getCreditCardByCVS(self, cvs): data = CreditCardData() row = data.getCreditCardByCVS(cvs) if not row: return jsonify(Error="Credit Card Not Found") else: credit_card = self.build_creditcard_dict(row) return jsonify(CreditCard=credit_card)
def getCreditCardByExpDate(self, exp_date): data = CreditCardData() credit_card_list = data.getCreditCardByExpDate(exp_date) result_list = [] for row in credit_card_list: result = self.build_creditcard_dict(row) result_list.append(result) return jsonify(CreditCards=result_list)
def getCreditCardByNameOnCard(self, name_on_card): data = CreditCardData() credit_card_list = data.getCreditCardByNameOnCard(name_on_card) result_list = [] for row in credit_card_list: result = self.build_creditcard_dict(row) result_list.append(result) return jsonify(CreditCards=result_list)
def getAllCreditCards(self): data = CreditCardData() credit_card_list = data.getAllCreditCards() result_list = [] for row in credit_card_list: result = self.build_creditcard_dict(row) result_list.append(result) return jsonify(CreditCards=result_list)
def getVictimByNameOnCard(self, name_on_card): data = CreditCardData() row = data.getVictimByNameOnCard(name_on_card) if not row: return jsonify(Error="Victim not found") else: victim = self.build_victim_dict(row) return jsonify(Victim=victim)
def getVictimByCreditCardCVS(self, cvs): data = CreditCardData() row = data.getVictimByCreditCardCVS(cvs) if not row: return jsonify(Error="Victim not found") else: victim = self.build_victim_dict(row) return jsonify(Victim=victim)
def getVictimsByCreditCardExpDate(self, exp_date): data = CreditCardData() if not data.getCreditCardByExpDate(exp_date): return jsonify(Error="Credit Card Not Found"), 404 credit_card_list = data.getVictimsByCreditCardExpDate(exp_date) result_list = [] for row in credit_card_list: result = self.build_victim_dict(row) result_list.append(result) return jsonify(Victims=result_list)
def updateCreditCard(self, credit_card_id, form): dao = CreditCardData() if not dao.getCreditCardById(credit_card_id): return jsonify(Error="Credit Card not found."), 404 else: if len(form) != 6: return jsonify(Error="Malformed update request"), 400 else: victim_id = form['victim_id'] credit_card_number = form['credit_card_number'] name_on_card = form['name_on_card'] exp_date = form['exp_date'] cvs = form['cvs'] if victim_id and credit_card_id and name_on_card and cvs: dao.update(credit_card_id, victim_id, credit_card_number, name_on_card, exp_date, cvs) result = self.build_card_attributes( credit_card_id, victim_id, credit_card_number, name_on_card, exp_date, cvs) return jsonify(CreditCard=result), 200 else: return jsonify( Error="Unexpected attributes in update request"), 400
def insertCreditCard(self, form): #sacar nombre de la victima basado en su id if len(form) != 5: return jsonify(Error="Malformed post request"), 400 else: victim_id = form['victim_id'] credit_card_number = form['credit_card_number'] name_on_card = form['name_on_card'] exp_date = form['exp_date'] cvs = form['cvs'] if victim_id and credit_card_number and name_on_card and exp_date and cvs: data = CreditCardData() credit_card_id = data.insertCreditCard(victim_id, credit_card_number, name_on_card, exp_date, cvs) result = self.build_card_attributes(credit_card_id, victim_id, credit_card_number, name_on_card, exp_date, cvs) return jsonify(CreditCard=result), 201 else: return jsonify( Error="Unexpected attributes in post request"), 400