fixr

package module
v0.0.0-...-7f42176 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2023 License: MIT Imports: 13 Imported by: 0

README

Build Status Go Report Card codecov

FIXR

A wrapper around FIXR's private ticket API

Installation

  1. go get github.com/pkg/errors
  2. go get github.com/ewancook/fixr
  3. Done!

Example Code:

package main

import (
	"fmt"

	"github.com/ewancook/fixr"
)

func main() {
	// Update FIXR version
	if err := fixr.UpdateVersion(); err != nil {
		fmt.Printf("FIXR version not updated (%s)\n", fixr.FixrVersion)
	} else {
		fmt.Printf("FIXR version updated (%s)\n", fixr.FixrVersion)
	}
	// Create client and logon
	c := fixr.NewClient("username")
	if err := c.Logon("password"); err != nil {
		fmt.Printf("logon failed (%v)\n", err)
	}
	// Fetch event information
	e, err := c.Event(141151926)
	if err != nil {
		fmt.Printf("failed getting event (%v)\n", err)
		return
	}
	// Determine ticket information
	for _, t := range e.Tickets {
		fmt.Printf("[%d] %s (£%.2f; Max: %d)\n", t.ID, t.Name, t.Price+t.BookingFee, t.Max)
	}
	// Book a ticket
	b, err := c.Book(&e.Tickets[0], 1, nil)
	if err != nil {
		fmt.Printf("purchase failed (%v)\n", err)
		return
	}
	fmt.Printf("booked: %s (PDF: %s)\n", b.Event, b.PDF)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FixrVersion represents FIXR's web API version.
	FixrVersion = "1.34.0"

	// FixrPlatformVer represents the "platform" used to "browse" the site.
	FixrPlatformVer = "Chrome/51.0.2704.103"

	// UserAgent is the user agent passed to every API call.
	UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
)

Functions

func UpdateVersion

func UpdateVersion() error

UpdateVersion updates the FIXR API version used in the HTTP requests.

Types

type Booking

type Booking struct {
	Event Event  `json:"event"`
	Name  string `json:"user_full_name"`
	PDF   string `json:"pdf"`
	State int    `json:"state"`
	// contains filtered or unexported fields
}

Booking contains the resultant booking information.

type Client

type Client struct {
	Email      string
	FirstName  string      `json:"first_name"`
	LastName   string      `json:"last_name"`
	MagicURL   string      `json:"magic_login_url"`
	AuthToken  string      `json:"auth_token"`
	StripeUser *stripeUser `json:"stripe_user"`
	// contains filtered or unexported fields
}

Client provides access to the FIXR API methods.

func NewClient

func NewClient(email string) *Client

NewClient returns a FIXR client with the given email and password.

func (*Client) AddCard

func (c *Client) AddCard(num, month, year, cvc, zip string) error

AddCard saves a card to the user's FIXR account, given the card details. An error will be returned if encountered

func (*Client) Book

func (c *Client) Book(ticket *Ticket, amount int, promo *PromoCode) (*Booking, error)

Book books a ticket, given a *Ticket and an amout (with the option of a promo code). The booking details and an error, if encountered, will be returned.

func (*Client) Event

func (c *Client) Event(id int) (*Event, error)

Event returns the event information for a given event ID (integer). An error will be returned if one is encountered.

func (*Client) HasCard

func (c *Client) HasCard() (existingCards bool, returnErr error)

HasCard checks for the existence of a saved card in the user's FIXR account. The result and an error, if encountered, will be returned.

func (*Client) Logon

func (c *Client) Logon(pass string) error

Logon authenticates the client with FIXR and returns an error if encountered.

func (*Client) Promo

func (c *Client) Promo(ticketID int, code string) (*PromoCode, error)

Promo checks for the existence of a promotion code for a given ticket ID. The returned *PromoCode can subsequently be passed to Book(). An error will be returned if one is encountered.

type Event

type Event struct {
	ID      int      `json:"id"`
	Name    string   `json:"name"`
	Tickets []Ticket `json:"tickets"`
	Error   string   `json:"detail"`
}

Event contains the event details for given event ID.

type PromoCode

type PromoCode struct {
	Code       string  `json:"code"`
	Price      float64 `json:"price"`
	BookingFee float64 `json:"booking_fee"`
	Currency   string  `json:"currency"`
	Max        int     `json:"max_per_user"`
	Remaining  int     `json:"remaining"`
	// contains filtered or unexported fields
}

PromoCode contains the details of a specific promotional code.

type Ticket

type Ticket struct {
	ID         int     `json:"id"`
	Name       string  `json:"name"`
	Type       int     `json:"type"`
	Currency   string  `json:"currency"`
	Price      float64 `json:"price"`
	BookingFee float64 `json:"booking_fee"`
	Max        int     `json:"max_per_user"`
	SoldOut    bool    `json:"sold_out"`
	Expired    bool    `json:"expired"`
	Invalid    bool    `json:"not_yet_valid"`
}

Ticket contains all the information pertaining to a specific ticket for an event.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL