Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
inner class ApiResponse(val data: JSONObject?, val response: Response)

@Throws(ApiException::class, JSONException::class)
fun redeem(eventSlug: String, secret: String, datetime: Date?, force: Boolean, nonce: String?, answers: List<Answer>?, listId: Long, ignore_unpaid: Boolean, pdf_data: Boolean, type: String?, source_type: String?, callTimeout: Long? = null, questions_supported: Boolean = true): ApiResponse {
fun redeem(eventSlug: String, secret: String, datetime: Date?, force: Boolean, nonce: String?, answers: List<Answer>?, listId: Long, ignore_unpaid: Boolean, pdf_data: Boolean, type: String?, source_type: String?, callTimeout: Long? = null, questions_supported: Boolean = true, use_order_locale: Boolean = false): ApiResponse {
var dt: String? = null
if (datetime != null) {
dt = QueuedCheckIn.formatDatetime(datetime)
}
return redeem(eventSlug, secret, dt, force, nonce, answers, listId, ignore_unpaid, pdf_data, type, source_type, callTimeout, questions_supported)
return redeem(eventSlug, secret, dt, force, nonce, answers, listId, ignore_unpaid, pdf_data, type, source_type, callTimeout, questions_supported, use_order_locale)
}

@Throws(ApiException::class, JSONException::class)
open fun redeem(eventSlug: String, secret: String, datetime: String?, force: Boolean, nonce: String?, answers: List<Answer>?, listId: Long, ignore_unpaid: Boolean, pdf_data: Boolean, type: String?, source_type: String?, callTimeout: Long? = null, questions_supported: Boolean=true): ApiResponse {
open fun redeem(eventSlug: String, secret: String, datetime: String?, force: Boolean, nonce: String?, answers: List<Answer>?, listId: Long, ignore_unpaid: Boolean, pdf_data: Boolean, type: String?, source_type: String?, callTimeout: Long? = null, questions_supported: Boolean = true, use_order_locale: Boolean = false): ApiResponse {
val body = JSONObject()
if (datetime != null) {
body.put("datetime", datetime)
Expand Down Expand Up @@ -82,6 +82,7 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
body.put("answers", answerbody)
body.put("questions_supported", questions_supported)
body.put("canceled_supported", true)
body.put("use_order_locale", use_order_locale)
var pd = ""
if (pdf_data) {
pd = "?pdf_data=true"
Expand All @@ -90,7 +91,7 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
}

@Throws(ApiException::class, JSONException::class)
fun redeem(lists: List<Long>, secret: String, datetime: Date?, force: Boolean, nonce: String?, answers: List<Answer>?, ignore_unpaid: Boolean, pdf_data: Boolean, type: String?, source_type: String?, callTimeout: Long? = null, questions_supported: Boolean = true): ApiResponse {
fun redeem(lists: List<Long>, secret: String, datetime: Date?, force: Boolean, nonce: String?, answers: List<Answer>?, ignore_unpaid: Boolean, pdf_data: Boolean, type: String?, source_type: String?, callTimeout: Long? = null, questions_supported: Boolean = true, use_order_locale: Boolean = false): ApiResponse {
var dt: String? = null
if (datetime != null) {
dt = QueuedCheckIn.formatDatetime(datetime)
Expand All @@ -99,7 +100,7 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
}

@Throws(ApiException::class, JSONException::class)
open fun redeem(lists: List<Long>, secret: String, datetime: String?, force: Boolean, nonce: String?, answers: List<Answer>?, ignore_unpaid: Boolean, pdf_data: Boolean, type: String?, source_type: String?, callTimeout: Long? = null, questions_supported: Boolean = true): ApiResponse {
open fun redeem(lists: List<Long>, secret: String, datetime: String?, force: Boolean, nonce: String?, answers: List<Answer>?, ignore_unpaid: Boolean, pdf_data: Boolean, type: String?, source_type: String?, callTimeout: Long? = null, questions_supported: Boolean = true, use_order_locale: Boolean = false): ApiResponse {
val body = JSONObject()
if (datetime != null) {
body.put("datetime", datetime)
Expand Down Expand Up @@ -129,6 +130,7 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
body.put("answers", answerbody)
body.put("questions_supported", questions_supported)
body.put("canceled_supported", true)
body.put("use_order_locale", use_order_locale)
body.put("secret", secret)
val jlists = JSONArray()
for (l in lists) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ data class MultiCheckInput(

// TODO: Check unused values
val allowQuestions: Boolean,
val useOrderLocale: Boolean,
val nonce: String?
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa
type: TicketCheckProvider.CheckInType,
nonce: String?,
allowQuestions: Boolean,
useOrderLocale: Boolean
): TicketCheckProvider.CheckResult {
val ticketid_cleaned = cleanInput(ticketid, source_type)

Expand Down Expand Up @@ -697,6 +698,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa
res.variation = variation.stringValue
}

res.locale = order.locale
res.attendee_name = position.attendeeName
res.seat = position.seatName
res.orderCode = order.code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class OnlineCheckProvider(
with_badge_data: Boolean,
type: TicketCheckProvider.CheckInType,
nonce: String?,
allowQuestions: Boolean
allowQuestions: Boolean,
useOrderLocale: Boolean
): TicketCheckProvider.CheckResult {
val ticketid_cleaned = cleanInput(ticketid, source_type)
val nonce_cleaned = nonce ?: NonceGenerator.nextNonce()
Expand All @@ -70,6 +71,7 @@ class OnlineCheckProvider(
source_type,
callTimeout = if (fallback != null) fallbackTimeout.toLong() else null,
questions_supported = allowQuestions,
use_order_locale = useOrderLocale,
)
} else {
if (eventsAndCheckinLists.size != 1) throw CheckException("Multi-event scan not supported by server.")
Expand Down Expand Up @@ -188,6 +190,9 @@ class OnlineCheckProvider(
}
res.orderCode = posjson.optString("order")
res.positionId = posjson.optLong("positionid")
if (posjson.has("order__locale")) {
res.locale = posjson.getString("order__locale")
}
res.position = posjson
val checkins = posjson.getJSONArray("checkins")
for (i in 0 until checkins.length()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class ProxyCheckProvider(private val config: ConfigStore, httpClientFactory: Htt
with_badge_data: Boolean,
type: TicketCheckProvider.CheckInType,
nonce: String?,
allowQuestions: Boolean
allowQuestions: Boolean,
useOrderLocale: Boolean
): TicketCheckProvider.CheckResult {
val answersInput = answers?.map {
val questionModel = it.question as Question // TODO: Can we avoid the cast?
Expand All @@ -129,6 +130,7 @@ class ProxyCheckProvider(private val config: ConfigStore, httpClientFactory: Htt
source_type = source_type,
type = type.name,
allowQuestions = allowQuestions,
useOrderLocale = useOrderLocale,
nonce = nonce,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ interface TicketCheckProvider {
var position: JSONObject? = null
var eventSlug: String? = null
var offline: Boolean = false
var locale: String? = null

constructor(type: Type?, message: String?, offline: Boolean = false) {
this.type = type
Expand Down Expand Up @@ -157,7 +158,7 @@ interface TicketCheckProvider {
class StatusResult(var eventName: String?, var totalTickets: Int, var alreadyScanned: Int, var currentlyInside: Int?, var items: List<StatusResultItem>?) {
}

fun check(eventsAndCheckinLists: Map<String, Long>, ticketid: String, source_type: String, answers: List<Answer>?, ignore_unpaid: Boolean, with_badge_data: Boolean, type: CheckInType, nonce: String? = null, allowQuestions: Boolean = true): CheckResult
fun check(eventsAndCheckinLists: Map<String, Long>, ticketid: String, source_type: String, answers: List<Answer>?, ignore_unpaid: Boolean, with_badge_data: Boolean, type: CheckInType, nonce: String? = null, allowQuestions: Boolean = true, useOrderLocale: Boolean = false): CheckResult
fun check(eventsAndCheckinLists: Map<String, Long>, ticketid: String): CheckResult
@Throws(CheckException::class)
fun search(eventsAndCheckinLists: Map<String, Long>, query: String, page: Int): List<SearchResult>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Order(
val pendingTotal: BigDecimal? = null,
val payments: JSONArray = JSONArray(),
val refunds: JSONArray = JSONArray(),
val locale: String? = null,
) {

val hasValidStatus = when (status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fun Orders.toModel(): Order {
pendingTotal = parsePendingTotal(json),
payments = parsePayments(json),
refunds = parseRefunds(json),
locale = parseLocale(json),
)
}

Expand Down Expand Up @@ -103,3 +104,12 @@ private fun parseRefunds(json: JSONObject): JSONArray {
return JSONArray()
}
}

private fun parseLocale(json: JSONObject): String? {
try {
return json.getString("locale")
} catch (e: JSONException) {
e.printStackTrace()
return null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,9 @@ protected void uploadCheckins(ProgressFeedback feedback) throws SyncException {
}
if (qci.getDatetime_string() == null || qci.getDatetime_string().equals("")) {
// Backwards compatibility
ar = api.redeem(qci.getEvent_slug(), qci.getSecret(), qci.getDatetime(), true, qci.getNonce(), answers, qci.getCheckinListId(), false, false, qci.getType(), st, null, false);
ar = api.redeem(qci.getEvent_slug(), qci.getSecret(), qci.getDatetime(), true, qci.getNonce(), answers, qci.getCheckinListId(), false, false, qci.getType(), st, null, false, false);
} else {
ar = api.redeem(qci.getEvent_slug(), qci.getSecret(), qci.getDatetime_string(), true, qci.getNonce(), answers, qci.getCheckinListId(), false, false, qci.getType(), st, null, false);
ar = api.redeem(qci.getEvent_slug(), qci.getSecret(), qci.getDatetime_string(), true, qci.getNonce(), answers, qci.getCheckinListId(), false, false, qci.getType(), st, null, false, false);
}
if (connectivityFeedback != null) {
connectivityFeedback.recordSuccess(System.currentTimeMillis() - startedAt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class FakePretixApi : PretixApi("http://1.1.1.1/", "a", "demo", 1, DefaultHttpCl
type: String?,
source_type: String?,
callTimeout: Long?,
questions_supported: Boolean
questions_supported: Boolean,
use_order_locale: Boolean
): ApiResponse {
redeemRequestSecret = secret
redeemRequestDatetime = datetime
Expand All @@ -68,7 +69,8 @@ class FakePretixApi : PretixApi("http://1.1.1.1/", "a", "demo", 1, DefaultHttpCl
type: String?,
source_type: String?,
callTimeout: Long?,
questions_supported: Boolean
questions_supported: Boolean,
use_order_locale: Boolean
): ApiResponse {
redeemRequestSecret = secret
redeemRequestDatetime = datetime
Expand Down
Loading