fix: add API methods, get_employees() and get_employee()
				
					
				
			This commit is contained in:
		
							parent
							
								
									66cf108b3f
								
							
						
					
					
						commit
						bcff560555
					
				
					 1 changed files with 35 additions and 1 deletions
				
			
		| 
						 | 
					@ -2,7 +2,7 @@
 | 
				
			||||||
################################################################################
 | 
					################################################################################
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#  pyCOREPOS -- Python Interface to CORE POS
 | 
					#  pyCOREPOS -- Python Interface to CORE POS
 | 
				
			||||||
#  Copyright © 2018-2023 Lance Edgar
 | 
					#  Copyright © 2018-2024 Lance Edgar
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#  This file is part of pyCOREPOS.
 | 
					#  This file is part of pyCOREPOS.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
| 
						 | 
					@ -198,6 +198,40 @@ class CoreWebAPI(object):
 | 
				
			||||||
        if result:
 | 
					        if result:
 | 
				
			||||||
            return result
 | 
					            return result
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def get_employees(self, **columns):
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        Fetch some or all of Employee records from CORE.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        :returns: A (potentially empty) list of employee dict records.
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        params = {
 | 
				
			||||||
 | 
					            'entity': 'Employees',
 | 
				
			||||||
 | 
					            'submethod': 'get',
 | 
				
			||||||
 | 
					            'columns': columns,
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        response = self.post(params)
 | 
				
			||||||
 | 
					        result = self.parse_response(response)
 | 
				
			||||||
 | 
					        return [json.loads(rec) for rec in result]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def get_employee(self, emp_no, **columns):
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        Fetch an existing Employee record from CORE.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        :returns: Either a employee dict record, or ``None``.
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        columns['emp_no'] = emp_no
 | 
				
			||||||
 | 
					        params = {
 | 
				
			||||||
 | 
					            'entity': 'Employees',
 | 
				
			||||||
 | 
					            'submethod': 'get',
 | 
				
			||||||
 | 
					            'columns': columns,
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        response = self.post(params)
 | 
				
			||||||
 | 
					        result = self.parse_response(response)
 | 
				
			||||||
 | 
					        if result:
 | 
				
			||||||
 | 
					            if len(result) > 1:
 | 
				
			||||||
 | 
					                log.warning("CORE API returned %s employee results", len(result))
 | 
				
			||||||
 | 
					            return json.loads(result[0])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_stores(self, **columns):
 | 
					    def get_stores(self, **columns):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        Fetch some or all of Store records from CORE.
 | 
					        Fetch some or all of Store records from CORE.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue