Skip to content

Connect and query a Pretix installation, handle its WebHooks

Notifications You must be signed in to change notification settings

derBobby/java-pretix-connector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Merge Dependabot PR CD

java-pretix-connector

This spring boot library allows to fetch almost everything related to Orders from the Pretix API. Everything that was fetched from the Pretix API is cached/stored locally. Currently, there is no automatic refresh. It can also handle WebHooks from Pretix.

Features

  • Fetch nearly everything order related
  • Store fetched data locally
  • Own data model, abstracting that of Pretix a bit for easier handling. Central classes are
    • Booking for everything that is booking related
    • PretixEventFilter A filter that can be used to search/filter within a list of Bookings
  • Controller to handle Webhooks - implement Interface IPretixWebHookHandler.class on your side!

Usage

Maven setup

        <dependency>
            <groupId>eu.planlos</groupId>
            <artifactId>java-pretix-connector</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>

Config classes setup

@Configuration
@ComponentScan(basePackages = "eu.planlos.javapretixconnector")
public class PretixConfig {}

Add Configuration class with @EntityScan and @EnableJpaRepositories for both, your package and the library:

@Configuration
@EnableJpaRepositories(basePackages = {"com.package.your", "eu.planlos.javapretixconnector"})
@EntityScan(basePackages = {"com.package.your", "eu.planlos.javapretixconnector"})
public class DataConfig {}

Properties setup

Property Type Description
pretix.api.active Boolean Enable/Disable usage of API
pretix.api.address String URL of the Pretix API
pretix.api.token String Authentication token
pretix.api.organizer String Organization of the owned events
pretix.api.retry-count Integer Retry count in case of exception
pretix.api.retry-interval Integer Interval for retries in case of exception
pretix.feature.preload-event-data-enabled Boolean Preload data for all live events
pretix.feature.preload-orders-enabled Boolean Preload orders for live events
pretix.event-filter.source Enum USER, PROPERTIES (default): Defines source for filter, configured or set during runtime
pretix.event-filter.filter-list List of JSON Format {json}||{json} required due to the way Spring handles lists. Used to filter bookings if pretix.event-filter.source is set to PROPERTIES. List will be persisted in the database. If, on startup, filters exist in the database, then this property will not be used.

Filter Example

{
  "action": "pretix.event.order.approved",
  "event": "zeltlager23ma",
  "qna-list": {
    "Zeltlager Jungs": [
      "Ja, die ganze Zeit",
      "Ja, nur tageweise (Siehe Sonstiges)",
      "Vielleicht"
    ]
  }
}

Use in your code

Autowire the wanted services

import eu.planlos.javapretixconnector.service.PretixBookingService;
import eu.planlos.javapretixconnector.service.PretixEventFilterService;

class YourClass {
    @Autowired
    private final PretixBookingService bookingService;
    @Autowired
    private final PretixEventFilterService filterService;
    // Your code
}

Call service to send message and catch Exception if necessary

class YourClass {
    yourMethod() {
        try {
            signalService.sendMessageToAdmin("Hello Admin!");
            signalService.sendMessageToRecipients("Hello configured recipients!");
        } catch(PretixException e) {
            // your code
}   }   }

Snippets

Create filter

curl -X POST http://localhost:8080/api/v1/filter \
    -u <user>:<password> \
    -H "Content-Type: application/json" \
    -d '{
          "action": "...",
          "organizer": "...",
          "event": "...",
          "qna-list": {
            "question1": ["...", "..."],
            "question2": ["..."]
          }
        }'

Delete filter

curl -X DELETE http://localhost:8080/api/v1/filter/{id} \
    -u <user>:<password>

About

Connect and query a Pretix installation, handle its WebHooks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 3

  •  
  •  
  •