@@ -51,6 +51,9 @@ def __init__(self, url: str, apikey: str):
51
51
'Io-Format' : 'JSON' ,
52
52
}
53
53
54
+ self .order_error_counter = 0
55
+ self .refund_error_counter = 0
56
+
54
57
def _build_credentials (self ) -> HTTPBasicAuth :
55
58
return HTTPBasicAuth (self .apikey , '' )
56
59
@@ -134,21 +137,19 @@ def get_orders_to_export(self, valid_orders_status: List[str], refund_orders_sta
134
137
exporting_regular_orders = True
135
138
exporting_refunds = False
136
139
for i in range (self ._MAX_CALLS ):
137
- offset = i * self ._PAGINATION_SIZE
138
-
139
140
if exporting_regular_orders :
140
141
result = self ._do_api_call (self ._build_url ('orders_with_printed' , {
141
142
'filter[orders_printed][exported]' : '0' ,
142
143
'filter[current_state]' : '[' + '|' .join (valid_orders_status ) + ']' ,
143
144
'sort' : '[id_ASC]' ,
144
- 'limit' : f"{ offset } ,{ self ._PAGINATION_SIZE } "
145
+ 'limit' : f"{ self . order_error_counter } ,{ self . order_error_counter + self ._PAGINATION_SIZE } "
145
146
}))
146
147
elif exporting_refunds :
147
148
result = self ._do_api_call (self ._build_url ('orders_with_printed' , {
148
149
'filter[orders_printed][exported]' : '1' ,
149
150
'filter[current_state]' : '[' + '|' .join (refund_orders_status ) + ']' ,
150
151
'sort' : '[id_ASC]' ,
151
- 'limit' : f"{ offset } ,{ self ._PAGINATION_SIZE } "
152
+ 'limit' : f"{ self . refund_error_counter } ,{ self . refund_error_counter + self ._PAGINATION_SIZE } "
152
153
}))
153
154
else :
154
155
break
0 commit comments