tripit

package
v0.0.0-...-33e1b50 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiPath = "https://api.tripit.com/v1"
)

Variables

View Source
var (
	// https://www.tripit.com/developer to register for an API key.
	ConsumerKey    = ""
	ConsumerSecret = ""
)

Functions

func Authorize

func Authorize() *oauth.AccessToken

Types

type Address

type Address struct {
	Address   string
	City      string
	State     string
	Country   string
	Latitude  float32 `json:",string"`
	Longitude float32 `json:",string"`
}

type AirObject

type AirObject struct {
	Id              string `json:"id"`
	TripId          string `json:"trip_id"`
	SupplierConfNum string `json:"supplier_conf_num"`

	// Tripit returns either a list of Segments or a single Segment inline.
	// The JSON unmarshaler will unmarshal this into a map[key]val or a [map[key]val]].
	Segment interface{}
}

func (*AirObject) Segments

func (ao *AirObject) Segments() []Segment

type DateTime

type DateTime struct {
	Date      string
	Time      string
	Timezone  string
	UtcOffset string `json:"utc_offset"`
}

func (*DateTime) Parse

func (dt *DateTime) Parse() (time.Time, error)

type ListParameters

type ListParameters struct {
	Traveler       string
	Past           bool
	ModifiedSince  int64
	IncludeObjects bool
	PageNum        int64
}

type Segment

type Segment struct {
	StartDateTime    DateTime
	EndDateTime      DateTime
	StartAirportCode string
	EndAirportCode   string
}

type Trip

type Trip struct {
	Id                     string `json:"id"`
	LastModified           int64  `json:"last_modified,string"`
	StartDate              string `json:"start_date"`
	EndDate                string `json:"end_date"`
	DisplayName            string `json:"display_name"`
	ImageUrl               string `json:"image_url"`
	IsPrivate              bool   `json:"is_private,string"`
	IsTraveler             bool   `json:"is_traveler,string"`
	PrimaryLocation        string `json:"primary_location_address"`
	PrimaryLocationAddress Address
	TripPurposes           TripPurpose

	// Set by fixStartAndEndDates.
	ActualStartDate time.Time `json:"-"`
	ActualEndDate   time.Time `json:"-"`
}

func (*Trip) End

func (t *Trip) End() (time.Time, error)

func (*Trip) Start

func (t *Trip) Start() (time.Time, error)

type TripPurpose

type TripPurpose struct {
	IsAutoGenerated bool   `json:"is_auto_generated,string"`
	PurposeTypeCode string `json:"purpose_type_code"`
}

type TripitResponse

type TripitResponse struct {
	Timestamp int64 `json:"timestamp,string"`
	NumBytes  int64 `json:"num_bytes,string"`
	PageNum   int64 `json:"page_num,string"`
	PageSize  int64 `json:"page_size,string"`
	MaxPage   int64 `json:"max_page,string"`

	// If you have 1 Trip, the TripIt API does returns a single result and
	// not a list.
	Trip []Trip

	AirObject []AirObject
}

type TripitSingleAirObjectResponse

type TripitSingleAirObjectResponse struct {
	AirObject AirObject
}

type TripitSingleTripResponse

type TripitSingleTripResponse struct {
	Trip Trip
}

Tripit brokenness: it will return a single Trip object (instead of list-of-Trips) if you have one trip upcoming. In some circumstances, it will return a single AirObject instead of a list. Sigh.

type TripitV1API

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

func NewTripitV1API

func NewTripitV1API(at *oauth.AccessToken) *TripitV1API

func (*TripitV1API) List

func (t *TripitV1API) List(p *ListParameters) ([]Trip, error)

func (*TripitV1API) ListRaw

func (t *TripitV1API) ListRaw(p *ListParameters) (*TripitResponse, error)

Lists trips.

Jump to

Keyboard shortcuts

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