wolt

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CoordinateKey  = "results.0.location.coordinates"
	PriceRangesKey = "results.0.delivery_specs.delivery_pricing"
)
View Source
const DeliveryCoordinatesPath = "details.delivery_info.location.coordinates.coordinates"

Variables

This section is empty.

Functions

func Distance

func Distance(first, second Coordinate) float64

Distance function returns the distance (in meters) between two points of

a given longitude and latitude relatively accurately (using a spherical
approximation of the Earth) through the Haversin Distance Formula for
great arc distance on a sphere with accuracy for small distances

point coordinates are supplied in degrees and converted into rad. in the func

distance returned is METERS!!!!!! http://en.wikipedia.org/wiki/Haversine_formula

Types

type Coordinate

type Coordinate struct {
	Lat float64
	Lon float64
}

func CoordinateFromArray

func CoordinateFromArray(coordinateArr []float64) (Coordinate, error)

type DeliveryInfo added in v1.2.1

type DeliveryInfo struct {
	Location struct {
		Coordinates struct {
			Coordinates []float64 `json:"coordinates"`
		} `json:"coordinates"`
	} `json:"location"`
}

type DeliveryStatus added in v1.2.1

type DeliveryStatus string
const (
	DeliveryStatusDelivered DeliveryStatus = "delivered"
)

type DeliveryStatusToTimeMap added in v1.2.1

type DeliveryStatusToTimeMap map[DeliveryStatus]time.Time

func (*DeliveryStatusToTimeMap) UnmarshalJSON added in v1.2.1

func (deliveryStatusLog *DeliveryStatusToTimeMap) UnmarshalJSON(bytes []byte) error

type DistanceRange

type DistanceRange struct {
	AddedPrice  int `json:"a"`
	MinDistance int `json:"min"`
	MaxDistance int `json:"max"`
}

type Group

type Group struct {
	// contains filtered or unexported fields
}

func NewGroupWithExistingID

func NewGroupWithExistingID(woltAddrs WoltAddr, retryConfig RetryConfig, id string) (*Group, error)

func (*Group) Details

func (g *Group) Details() (*OrderDetails, error)

func (*Group) Join

func (g *Group) Join() error

func (*Group) MarkAsReady

func (g *Group) MarkAsReady() error

func (*Group) VenueDetails

func (g *Group) VenueDetails(details *OrderDetails) (*Venue, error)

type Item added in v1.2.1

type Item struct {
	BasePrice float64 `json:"baseprice"`
	EndAmount float64 `json:"end_amount"`
}

type OrderDetails

type OrderDetails struct {
	Status        Status `json:"status"`
	CreatedAtUnix struct {
		DateUnix int64 `json:"$date"`
	} `json:"created_at"`
	Details struct {
		VenueID      string       `json:"venue_id"`
		DeliveryInfo DeliveryInfo `json:"delivery_info"`
	} `json:"details"`
	HostID       string        `json:"host_id"`
	Participants []Participant `json:"participants"`
	Purchase     struct {
		DeliveryEtaUnix struct {
			DateUnix int64 `json:"$date"`
		} `json:"delivery_eta"`
		DeliveryStatus       DeliveryStatus          `json:"delivery_status"`
		DeliveryStatusLog    DeliveryStatusToTimeMap `json:"delivery_status_log"`
		PurchaseDatetimeUnix struct {
			DateUnix int64 `json:"$date"`
		} `json:"purchase_datetime"`
	} `json:"purchase"`

	CreatedAt                time.Time  `json:"-"`
	DeliveryEta              time.Time  `json:"-"`
	PurchaseDatetime         time.Time  `json:"-"`
	ParsedDeliveryCoordinate Coordinate `json:"-"`
	Host                     string     `json:"-"`
}

func ParseOrderDetails added in v1.2.1

func ParseOrderDetails(orderDetailsJSON []byte) (*OrderDetails, error)

func (*OrderDetails) IsDelivered added in v1.2.1

func (o *OrderDetails) IsDelivered() bool

func (*OrderDetails) RateByPerson

func (o *OrderDetails) RateByPerson() (map[string]float64, error)

type OrderHistory

type OrderHistory struct {
	// contains filtered or unexported fields
}

func (*OrderHistory) DeliveryRateForOrder

func (o *OrderHistory) DeliveryRateForOrder(orderPrettyID string) (int, error)

func (*OrderHistory) GetOrderJsonByID

func (o *OrderHistory) GetOrderJsonByID(orderPrettyID string) (*gabs.Container, bool)

type Participant added in v1.2.1

type Participant struct {
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Status    string `json:"status"`
	UserID    string `json:"user_id"`
	Basket    struct {
		Items []Item `json:"items"`
	} `json:"basket"`
}

func (*Participant) Name added in v1.2.1

func (p *Participant) Name() string

type PriceRanges

type PriceRanges struct {
	BasePrice      int             `json:"base_price"`
	DistanceRanges []DistanceRange `json:"distance_ranges"`
}

type RetryConfig added in v1.0.1

type RetryConfig struct {
	HTTPMaxRetries       int
	HTTPMinRetryDuration time.Duration
	HTTPMaxRetryDuration time.Duration
}

type Status added in v1.2.1

type Status string
const (
	StatusActive       Status = "active"
	StatusCanceled     Status = "cancelled"
	StatusPendingTrans Status = "pending_transaction"
	StatusPurchased    Status = "purchased"
)

func (Status) Purchased added in v1.2.1

func (s Status) Purchased() bool

type Venue added in v1.2.1

type Venue struct {
	Alive    uint8 `json:"alive"`
	Location struct {
		Coordinates []float64 `json:"coordinates"`
	} `json:"location"`
	DeliverySpecs struct {
		DeliveryEnabled bool        `json:"delivery_enabled"`
		DeliveryPricing PriceRanges `json:"delivery_pricing"`
	} `json:"delivery_specs"`
	Names         []VenueName `json:"name"`
	Link          string      `json:"public_url"`
	OfflinePeriod struct {
		End struct {
			DateUnix int64 `json:"$date"`
		} `json:"end"`
	} `json:"offline_period"`
	Online          bool `json:"online"`
	PreorderEnabled bool `json:"preorder_enabled"`
	PreorderTimes   struct {
		Delivery map[string][]interface{} `json:"delivery"`
	} `json:"preorder_times"`
	City     string `json:"city"`
	Timezone string `json:"timezone"`

	Name             string
	ParsedCoordinate Coordinate     `json:"-"`
	TimezoneLocation *time.Location `json:"-"`
	OfflinePeriodEnd time.Time      `json:"-"`
}

func ParseVenue added in v1.2.1

func ParseVenue(venuesJSON []byte) (*Venue, error)

func (*Venue) CalculateDeliveryRate added in v1.2.1

func (v *Venue) CalculateDeliveryRate(source Coordinate) (int, error)

func (*Venue) IsDelivering added in v1.2.1

func (v *Venue) IsDelivering() bool

func (*Venue) IsOpenForPreorderDelivery added in v1.2.1

func (v *Venue) IsOpenForPreorderDelivery() bool

type VenueName added in v1.2.1

type VenueName struct {
	Lang  string `json:"lang"`
	Value string `json:"value"`
}

type WoltAddr

type WoltAddr struct {
	BaseAddr    string
	APIBaseAddr string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳