Example #1
0
 def find_all(query: Query = None,
              page: int = 1,
              page_size: int = 1000) -> List['Customer']:
     return [
         Customer.from_db(customer)
         for customer in db.get_customers(query, page, page_size)
     ]
Example #2
0
def get_customers():

    try:
        customers = db.get_customers()
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    if len(customers):
        return jsonify(status="ok",
                       total=len(customers),
                       customers=customers,
                       time=datetime.datetime.utcnow())
    else:
        return jsonify(status="ok",
                       message="not found",
                       total=0,
                       customers=[],
                       time=datetime.datetime.utcnow())
Example #3
0
def get_customers():

    try:
        customers = db.get_customers()
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    if len(customers):
        return jsonify(
            status="ok",
            total=len(customers),
            customers=customers,
            time=datetime.datetime.utcnow()
        )
    else:
        return jsonify(
            status="ok",
            message="not found",
            total=0,
            customers=[],
            time=datetime.datetime.utcnow()
        )
Example #4
0
 def find_all(query: Query=None) -> List['Customer']:
     return [Customer.from_db(customer) for customer in db.get_customers(query)]
Example #5
0
 def find_all(query=None):
     return [
         Customer.from_db(customer) for customer in db.get_customers(query)
     ]