def searchAddresses(self, args): city = args.get("city") state_province = args.get("state_province") country = args.get("country") zipcode = args.get("zipcode") dao = AddressDAO() address_list = [] if (len(args) == 1) and city: address_list = dao.getAddressesByCity(city) elif (len(args) == 1) and state_province: address_list = dao.getAddressesByStateOrProvince(state_province) elif (len(args) == 1) and country: address_list = dao.getAddressesByCountry(country) elif (len(args) == 1) and zipcode: address_list = dao.getAddressesByZipcode(zipcode) elif (len(args) == 2) and city and country: address_list = dao.getAddressesByCityAndCountry(city, country) else: return jsonify(Error="Malformed query string"), 400 result_list = [] for row in address_list: result = self.build_address_dict(row) result_list.append(result) return jsonify(Addresses=result_list)
def searchAddresses(self, args): city = args.get('city') country = args.get('country') dao = AddressDAO() if (len(args) == 2) and city and country: address_list = dao.getAddressesByCityAndCountry(city, country) elif (len(args) == 1) and city: address_list = dao.getAddressesByCity(city) elif (len(args) == 1) and country: address_list = dao.getAddressesByCountry(country) else: return jsonify(Error="Malformed query string"), 400 if not address_list: return jsonify(Error="Address Not Found"), 404 else: result_list = [] for row in address_list: result = self.build_address_dict(row) result_list.append(result) return jsonify(Address=result_list)