def process_batch(self, obj_list): qb = QuickBooks() batch = self.list_to_batch_request(obj_list) json_data = qb.batch_operation(batch.to_json()) batch_response = self.batch_results_to_list(json_data, batch, obj_list) return batch_response
def save(self): from .client import QuickBooks qb = QuickBooks() if self.Id > 0: json_data = qb.update_object(self.qbo_object_name, self.to_json()) else: json_data = qb.create_object(self.qbo_object_name, self.to_json()) obj = type(self).from_json(json_data[self.qbo_object_name]) self.Id = obj.Id return obj
def save(self): from .client import QuickBooks qb = QuickBooks() if hasattr(self, "Id") and self.Id > 0: json_data = qb.update_object(self.qbo_object_name, self.to_json()) else: json_data = qb.create_object(self.qbo_object_name, self.to_json()) try: obj = type(self).from_json(json_data[self.qbo_object_name]) self.Id = obj.Id return obj except: return None
def query(cls, select): """ :param select: QBO SQL query select statement :return: List """ qb = QuickBooks() json_data = qb.query(select) obj_list = [] if cls.qbo_object_name in json_data["QueryResponse"]: for item_json in json_data["QueryResponse"][cls.qbo_object_name]: obj_list.append(cls.from_json(item_json)) return obj_list
def get(cls, id): from client import QuickBooks qb = QuickBooks() json_data = qb.get_single_object(cls.qbo_object_name, pk=id) return cls.from_json(json_data[cls.qbo_object_name])