Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvanderbyl committed Jun 21, 2022
1 parent 935a5a3 commit 7e368f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
20 changes: 14 additions & 6 deletions examples/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ func main() {

for _, slice := range offer.Slices {
for _, segment := range slice.Segments {
dep, _ := segment.DepartingAt()
arr, _ := segment.ArrivingAt()
t.AppendRow(table.Row{
slice.ID,
segment.Origin.IATACode,
segment.Destination.IATACode,
time.Time(segment.DepartingAt).Format(time.RFC822),
time.Time(segment.ArrivingAt).Format(time.RFC822),

dep.Format(time.RFC822),
arr.Format(time.RFC822),
segment.Passengers[0].CabinClass.String(),
renderChangeableStatus(slice),
})
Expand Down Expand Up @@ -209,25 +212,30 @@ func main() {

for _, slice := range offer.Slices.Add {
for _, segment := range slice.Segments {
dep, _ := segment.DepartingAt()
arr, _ := segment.ArrivingAt()

t.AppendRow(table.Row{
fmt.Sprintf("Add %s", slice.ID),
segment.Origin.IATACode,
segment.Destination.IATACode,
time.Time(segment.DepartingAt).Format(time.RFC822),
time.Time(segment.ArrivingAt).Format(time.RFC822),
dep.Format(time.RFC822),
arr.Format(time.RFC822),
// segment.Passengers != nil && segment.Passengers[0].CabinClass.String(),
renderChangeableStatus(slice),
})
}
}
for _, slice := range offer.Slices.Remove {
for _, segment := range slice.Segments {
dep, _ := segment.DepartingAt()
arr, _ := segment.ArrivingAt()
t.AppendRow(table.Row{
fmt.Sprintf("Remove %s", slice.ID),
segment.Origin.IATACode,
segment.Destination.IATACode,
time.Time(segment.DepartingAt).Format(time.RFC822),
time.Time(segment.ArrivingAt).Format(time.RFC822),
dep.Format(time.RFC822),
arr.Format(time.RFC822),
segment.Passengers[0].CabinClass.String(),
renderChangeableStatus(slice),
})
Expand Down
5 changes: 4 additions & 1 deletion examples/offer-requests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ func main() {
fmt.Printf(" 🛫 %s to %s\n", *s.Origin.CityName, *s.Destination.CityName)

for _, f := range s.Segments {
fmt.Printf(" Departing at %s • Arriving at %s\n", f.DepartingAt, f.ArrivingAt)
dep, _ := f.DepartingAt()
arr, _ := f.ArrivingAt()

fmt.Printf(" Departing at %s • Arriving at %s\n", dep, arr)
}

fmt.Printf(" 🛬 %s • %s\n", s.FareBrandName, time.Duration(s.Duration).String())
Expand Down

0 comments on commit 7e368f9

Please sign in to comment.