@@ -112,7 +112,7 @@ class OrderSyncAdapter(
112
112
}
113
113
}
114
114
115
- private fun preparePositionObject (obj : OrderPosition ? , jsonobj : JSONObject , orderId : Long , jsonorder : JSONObject , parent : JSONObject ? ): OrderPosition {
115
+ private fun preparePositionObject (jsonobj : JSONObject , orderId : Long , jsonorder : JSONObject , parent : JSONObject ? ): OrderPosition {
116
116
val jsonName = if (jsonobj.isNull(" attendee_name" )) " " else jsonobj.optString(" attendee_name" )
117
117
// TODO: BUG: jsonName can never be null, so parent / jInvoiceAddress is never used
118
118
// Keeping old behaviour for compatibility
@@ -157,7 +157,7 @@ class OrderSyncAdapter(
157
157
}
158
158
159
159
private fun insertPositionObject (jsonobj : JSONObject , orderId : Long , jsonorder : JSONObject , parent : JSONObject ? ) {
160
- val posobj = preparePositionObject(null , jsonobj, orderId, jsonorder, parent)
160
+ val posobj = preparePositionObject(jsonobj, orderId, jsonorder, parent)
161
161
162
162
val id = db.orderPositionQueries.transactionWithResult {
163
163
db.orderPositionQueries.insert(
@@ -180,7 +180,7 @@ class OrderSyncAdapter(
180
180
}
181
181
182
182
private fun updatePositionObject (obj : OrderPosition , jsonobj : JSONObject , orderId : Long , jsonorder : JSONObject , parent : JSONObject ? ) {
183
- val posobj = preparePositionObject(obj, jsonobj, orderId, jsonorder, parent)
183
+ val posobj = preparePositionObject(jsonobj, orderId, jsonorder, parent)
184
184
185
185
db.orderPositionQueries.updateFromJson(
186
186
attendee_email = posobj.attendee_email,
@@ -359,26 +359,26 @@ class OrderSyncAdapter(
359
359
override fun deleteUnseen (): Boolean = false
360
360
361
361
override fun downloadPage (url : String , isFirstPage : Boolean ): JSONObject ? {
362
- var url = url
363
362
if (isFirstPage) {
364
363
rlm = db.resourceSyncStatusQueries.selectByResourceAndEventSlug(
365
364
resource = rlmName(),
366
365
event_slug = eventSlug,
367
366
).executeAsOneOrNull()
368
367
}
369
368
var is_continued_fetch = false
370
- if (! url.contains(" testmode=" )) {
371
- url + = if (url.contains(" ?" )) {
369
+ var resUrl = url
370
+ if (! resUrl.contains(" testmode=" )) {
371
+ resUrl + = if (resUrl.contains(" ?" )) {
372
372
" &"
373
373
} else {
374
374
" ?"
375
375
}
376
- url + = " testmode=false&exclude=downloads&exclude=payment_date&exclude=payment_provider&exclude=fees&exclude=positions.downloads"
376
+ resUrl + = " testmode=false&exclude=downloads&exclude=payment_date&exclude=payment_provider&exclude=fees&exclude=positions.downloads"
377
377
if (! isPretixpos) {
378
- url + = " &exclude=payments&exclude=refunds"
378
+ resUrl + = " &exclude=payments&exclude=refunds"
379
379
}
380
380
if (withPdfData) {
381
- url + = " &pdf_data=true"
381
+ resUrl + = " &pdf_data=true"
382
382
}
383
383
}
384
384
@@ -408,8 +408,8 @@ class OrderSyncAdapter(
408
408
409
409
is_continued_fetch = true
410
410
try {
411
- if (! url .contains(" created_since" )) {
412
- url + = " &ordering=datetime&created_since=" + URLEncoder .encode(resourceSyncStatus.status.substring(11 ), " UTF-8" ) + firstrun_params
411
+ if (! resUrl .contains(" created_since" )) {
412
+ resUrl + = " &ordering=datetime&created_since=" + URLEncoder .encode(resourceSyncStatus.status.substring(11 ), " UTF-8" ) + firstrun_params
413
413
}
414
414
} catch (e: UnsupportedEncodingException ) {
415
415
e.printStackTrace()
@@ -429,20 +429,20 @@ class OrderSyncAdapter(
429
429
// of the first page.
430
430
431
431
try {
432
- if (! url .contains(" modified_since" )) {
433
- url + = " &ordering=-last_modified&modified_since=" + URLEncoder .encode(resourceSyncStatus.last_modified, " UTF-8" )
432
+ if (! resUrl .contains(" modified_since" )) {
433
+ resUrl + = " &ordering=-last_modified&modified_since=" + URLEncoder .encode(resourceSyncStatus.last_modified, " UTF-8" )
434
434
}
435
435
} catch (e: UnsupportedEncodingException ) {
436
436
e.printStackTrace()
437
437
}
438
438
}
439
439
} else {
440
- if (! url .contains(" subevent_after" )) {
441
- url + = firstrun_params
440
+ if (! resUrl .contains(" subevent_after" )) {
441
+ resUrl + = firstrun_params
442
442
}
443
443
}
444
444
445
- val apiResponse = api.fetchResource(url )
445
+ val apiResponse = api.fetchResource(resUrl )
446
446
if (isFirstPage && ! is_continued_fetch) {
447
447
firstResponseTimestamp = apiResponse.response.header(" X-Page-Generated" )
448
448
}
0 commit comments