Skip to content

Commit

Permalink
Use airport location for rent request
Browse files Browse the repository at this point in the history
  • Loading branch information
boozec committed Jun 13, 2024
1 parent 96a29ea commit a47bdfd
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions internal/http/soap.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package http

import (
"fmt"
"net/http"
"time"

Expand Down Expand Up @@ -30,12 +31,18 @@ func MakeRentRequest(rent models.Rent, offer models.Offer) (*BookRentResponse, e
return nil, err
}

endpoint := fmt.Sprintf("%s/airports/code/%s/", offer.Journey.Flight1.Airline, offer.Journey.Flight1.DepartureAirport)
airport, err := GetAirportInfo(endpoint)
if err != nil {
log.Errorf("Can't find info for departure airport: %s", err.Error())
return nil, err
}

params := gosoap.Params{
"PickupAddress": *offer.User.Address,
// FIXME: add "address" field to airport with string
"Address": offer.Journey.Flight1.DepartureAirport,
"CustomerName": offer.User.Name,
"PickupDate": offer.Journey.Flight1.DepartureTime.Add(-2 * time.Hour).Format("02/01/2006 15:04"),
"Address": airport.Location,
"CustomerName": offer.User.Name,
"PickupDate": offer.Journey.Flight1.DepartureTime.Add(-2 * time.Hour).Format("02/01/2006 15:04"),
}

res, err := soap.Call("BookRent", params)
Expand Down

0 comments on commit a47bdfd

Please sign in to comment.