|
5 | 5 |
|
6 | 6 |
|
7 | 7 | def change_data_capture(qbo_class_list, timestamp, qb=None):
|
8 |
| - if qb is None: |
9 |
| - qb = QuickBooks() |
| 8 | + if qb is None: |
| 9 | + qb = QuickBooks() |
10 | 10 |
|
11 |
| - cdc_class_dict = dict((cls.qbo_object_name, cls) for cls in qbo_class_list) |
| 11 | + cdc_class_dict = dict((cls.qbo_object_name, cls) for cls in qbo_class_list) |
12 | 12 |
|
13 |
| - cdc_class_names = list(cdc_class_dict.keys()) |
14 |
| - entity_list_string = ','.join(cdc_class_names) |
| 13 | + cdc_class_names = list(cdc_class_dict.keys()) |
| 14 | + entity_list_string = ','.join(cdc_class_names) |
15 | 15 |
|
16 |
| - if isinstance(timestamp, datetime): |
17 |
| - timestamp_string = qb_datetime_format(timestamp) |
18 |
| - else: |
19 |
| - timestamp_string = timestamp |
| 16 | + if isinstance(timestamp, datetime): |
| 17 | + timestamp_string = qb_datetime_format(timestamp) |
| 18 | + else: |
| 19 | + timestamp_string = timestamp |
20 | 20 |
|
21 |
| - resp = qb.change_data_capture(entity_list_string, timestamp_string) |
| 21 | + resp = qb.change_data_capture(entity_list_string, timestamp_string) |
22 | 22 |
|
23 |
| - cdc_response_dict = resp.pop('CDCResponse') |
24 |
| - cdc_response = CDCResponse.from_json(resp) |
| 23 | + cdc_response_dict = resp.pop('CDCResponse') |
| 24 | + cdc_response = CDCResponse.from_json(resp) |
25 | 25 |
|
26 |
| - query_response_list = cdc_response_dict[0]['QueryResponse'] |
27 |
| - for query_response_dict in query_response_list: |
28 |
| - qb_object_name = [x for x in query_response_dict if x in cdc_class_names][0] |
29 |
| - qb_object_list = query_response_dict.pop(qb_object_name) |
30 |
| - qb_object_cls = cdc_class_dict[qb_object_name] |
| 26 | + query_response_list = cdc_response_dict[0]['QueryResponse'] |
| 27 | + for query_response_dict in query_response_list: |
| 28 | + qb_object_name = [x for x in query_response_dict if x in cdc_class_names][0] |
| 29 | + qb_object_list = query_response_dict.pop(qb_object_name) |
| 30 | + qb_object_cls = cdc_class_dict[qb_object_name] |
31 | 31 |
|
32 |
| - query_response = QueryResponse.from_json(query_response_dict) |
33 |
| - query_response._object_list = [qb_object_cls.from_json(obj) for obj in qb_object_list] |
| 32 | + query_response = QueryResponse.from_json(query_response_dict) |
| 33 | + query_response._object_list = [qb_object_cls.from_json(obj) for obj in qb_object_list] |
34 | 34 |
|
35 |
| - setattr(cdc_response, qb_object_name, query_response) |
| 35 | + setattr(cdc_response, qb_object_name, query_response) |
36 | 36 |
|
37 |
| - return cdc_response |
| 37 | + return cdc_response |
0 commit comments