Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
boozec committed May 24, 2024
1 parent c2b1e7b commit 4eea433
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 70 deletions.
12 changes: 6 additions & 6 deletions internal/handlers/acmesky/st_prepare_offer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ func STPrepareOffer(client worker.JobClient, job entities.Job) {
body := models.OfferInput{
Flight1: models.OfferInputFields{
DepartureAirport: journey.Flight1.DepartureAirport,
ArrivalAirport: journey.Flight1.ArrivalAirport,
ArrivalAirport: journey.Flight1.ArrivalAirport,
DepartureTime: journey.Flight1.DepartureTime.Format("02/01/2006 15:04"),
ArrivalTime: journey.Flight1.ArrivalTime.Format("02/01/2006 15:04"),
Cost: journey.Flight1.Cost,
ArrivalTime: journey.Flight1.ArrivalTime.Format("02/01/2006 15:04"),
Cost: journey.Flight1.Cost,
},
JourneyId: int(journey.Id),
UserId: journey.UserId,
Expand All @@ -53,10 +53,10 @@ func STPrepareOffer(client worker.JobClient, job entities.Job) {
if journey.Flight2 != nil {
body.Flight2 = &models.OfferInputFields{
DepartureAirport: journey.Flight2.DepartureAirport,
ArrivalAirport: journey.Flight2.ArrivalAirport,
ArrivalAirport: journey.Flight2.ArrivalAirport,
DepartureTime: journey.Flight2.DepartureTime.Format("02/01/2006 15:04"),
ArrivalTime: journey.Flight2.ArrivalTime.Format("02/01/2006 15:04"),
Cost: journey.Flight2.Cost,
ArrivalTime: journey.Flight2.ArrivalTime.Format("02/01/2006 15:04"),
Cost: journey.Flight2.Cost,
}
}

Expand Down
16 changes: 8 additions & 8 deletions internal/handlers/acmesky/tm_book_journey.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func TMBookJourney(client worker.JobClient, job entities.Job) {

endpoint := fmt.Sprintf("%s/flights/filter/", flight1.Airline)
payload := map[string]interface{}{
"code": flight1.Code,
"code": flight1.Code,
"departure_airport": flight1.DepartureAirport,
"departure_time": flight1.DepartureTime,
"arrival_airport": flight1.ArrivalAirport,
"arrival_time": flight1.ArrivalTime,
"arrival_airport": flight1.ArrivalAirport,
"arrival_time": flight1.ArrivalTime,
}

response, err := http.MakeRequest(endpoint, payload)
Expand Down Expand Up @@ -77,11 +77,11 @@ func TMBookJourney(client worker.JobClient, job entities.Job) {
if flight2 != nil {
endpoint := fmt.Sprintf("%s/flights/filter/", flight2.Airline)
payload := map[string]interface{}{
"code": flight2.Code,
"code": flight2.Code,
"departure_airport": flight2.DepartureAirport,
"departure_time": flight2.DepartureTime,
"arrival_airport": flight2.ArrivalAirport,
"arrival_time": flight2.ArrivalTime,
"arrival_airport": flight2.ArrivalAirport,
"arrival_time": flight2.ArrivalTime,
}

response, err := http.MakeRequest(endpoint, payload)
Expand Down Expand Up @@ -125,8 +125,8 @@ func TMBookJourney(client worker.JobClient, job entities.Job) {
endpoint = fmt.Sprintf("%s/journeys/", flight1.Airline)
payload = map[string]interface{}{
"departure_flight_id": flight1_id,
"cost": offer.Journey.Cost,
"email": offer.User.Email,
"cost": offer.Journey.Cost,
"email": offer.User.Email,
}

if flight2_id != 0 {
Expand Down
8 changes: 4 additions & 4 deletions internal/handlers/acmesky/tm_search_flight_on_airline.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func TMSearchFlightsOnAirline(client worker.JobClient, job entities.Job) {
payload := map[string]interface{}{
"departure_airport": interest["flight1_departure_airport"].(string),
"departure_time": interest["flight1_departure_time"].(string),
"arrival_airport": interest["flight1_arrival_airport"].(string),
"arrival_time": interest["flight1_arrival_time"].(string),
"arrival_airport": interest["flight1_arrival_airport"].(string),
"arrival_time": interest["flight1_arrival_time"].(string),
}

response, err := http.MakeRequest(endpoint, payload)
Expand All @@ -72,8 +72,8 @@ func TMSearchFlightsOnAirline(client worker.JobClient, job entities.Job) {
payload = map[string]interface{}{
"departure_airport": interest["flight2_departure_airport"].(string),
"departure_time": interest["flight2_departure_time"].(string),
"arrival_airport": interest["flight2_arrival_airport"].(string),
"arrival_time": interest["flight2_arrival_time"].(string),
"arrival_airport": interest["flight2_arrival_airport"].(string),
"arrival_time": interest["flight2_arrival_time"].(string),
}

response, err = http.MakeRequest(endpoint, payload)
Expand Down
10 changes: 5 additions & 5 deletions internal/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ type AuthTokenBody struct {
}

type JourneyResponseBody struct {
Id uint `json:"id"`
CreatedAt time.Time `json:"created_at"`
Id uint `json:"id"`
CreatedAt time.Time `json:"created_at"`
DepartureFlight map[string]interface{} `json:"departure_flight"`
ArrivalFlight map[string]interface{} `json:"arrival_flight"`
Cost float64 `json:"cost"`
Email string `json:"email"`
ArrivalFlight map[string]interface{} `json:"arrival_flight"`
Cost float64 `json:"cost"`
Email string `json:"email"`
}

type PaymentResponseBody struct {
Expand Down
58 changes: 29 additions & 29 deletions internal/models/available_flight.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ import (

// AvailableFlight model
type AvailableFlight struct {
Id uint `gorm:"column:id" json:"id"`
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
Airline string `gorm:"column:airline" json:"airline"`
Id uint `gorm:"column:id" json:"id"`
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
Airline string `gorm:"column:airline" json:"airline"`
DepartureTime time.Time `gorm:"column:departure_time" json:"departure_time"`
DepartureAirport string `gorm:"column:departure_airport" json:"departure_airport"`
ArrivalTime time.Time `gorm:"column:arrival_time" json:"arrival_time"`
ArrivalAirport string `gorm:"column:arrival_airport" json:"arrival_airport"`
Code string `gorm:"column:code" json:"code"`
Cost float64 `gorm:"column:cost" json:"cost"`
InterestId *int `json:"-"`
Interest *Interest `gorm:"foreignKey:InterestId;null" json:"interest"`
OfferSent bool `gorm:"column:offer_sent" json:"offer_sent"`
UserId int `json:"-"`
User User `gorm:"foreignKey:UserId" json:"user"`
ArrivalTime time.Time `gorm:"column:arrival_time" json:"arrival_time"`
ArrivalAirport string `gorm:"column:arrival_airport" json:"arrival_airport"`
Code string `gorm:"column:code" json:"code"`
Cost float64 `gorm:"column:cost" json:"cost"`
InterestId *int `json:"-"`
Interest *Interest `gorm:"foreignKey:InterestId;null" json:"interest"`
OfferSent bool `gorm:"column:offer_sent" json:"offer_sent"`
UserId int `json:"-"`
User User `gorm:"foreignKey:UserId" json:"user"`
}

// Struct used to get new data for a flight
type AvailableFlightInput struct {
Airline string `json:"airline" binding:"required"`
Airline string `json:"airline" binding:"required"`
DepartureTime time.Time `json:"departure_time" binding:"required"`
DepartureAirport string `json:"departure_airport" binding:"required"`
ArrivalTime time.Time `json:"arrival_time" binding:"required"`
ArrivalAirport string `json:"arrival_airport" binding:"required"`
Code string `json:"code" binding:"required"`
Cost float64 `json:"cost" binding:"required"`
InterestId *int `json:"interest_id"`
OfferSent bool `json:"offer_sent"`
UserId int `json:"user_id" binding:"required"`
ArrivalTime time.Time `json:"arrival_time" binding:"required"`
ArrivalAirport string `json:"arrival_airport" binding:"required"`
Code string `json:"code" binding:"required"`
Cost float64 `json:"cost" binding:"required"`
InterestId *int `json:"interest_id"`
OfferSent bool `json:"offer_sent"`
UserId int `json:"user_id" binding:"required"`
}

// It validates data from `in` and returns a possible error or not
Expand Down Expand Up @@ -76,16 +76,16 @@ func ValidateAvailableFlight(db *gorm.DB, variables map[string]interface{}) (*Av
// `ValidateAvailableFlight(..., in)` method
func NewAvailableFlight(in AvailableFlightInput) AvailableFlight {
return AvailableFlight{
CreatedAt: time.Now(),
Airline: in.Airline,
CreatedAt: time.Now(),
Airline: in.Airline,
DepartureTime: in.DepartureTime,
DepartureAirport: in.DepartureAirport,
ArrivalTime: in.ArrivalTime,
ArrivalAirport: in.ArrivalAirport,
Code: in.Code,
Cost: in.Cost,
InterestId: in.InterestId,
OfferSent: false,
UserId: in.UserId,
ArrivalTime: in.ArrivalTime,
ArrivalAirport: in.ArrivalAirport,
Code: in.Code,
Cost: in.Cost,
InterestId: in.InterestId,
OfferSent: false,
UserId: in.UserId,
}
}
30 changes: 15 additions & 15 deletions internal/models/interest.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ type Interest struct {

Flight1DepartureTime time.Time `gorm:"column:flight1_departure_time" json:"flight1_departure_time"`
Flight1DepartureAirport string `gorm:"column:flight1_departure_airport" json:"flight1_departure_airport"`
Flight1ArrivalTime time.Time `gorm:"column:flight1_arrival_time" json:"flight1_arrival_time"`
Flight1ArrivalAirport string `gorm:"column:flight1_arrival_airport" json:"flight1_arrival_airport"`
Flight1ArrivalTime time.Time `gorm:"column:flight1_arrival_time" json:"flight1_arrival_time"`
Flight1ArrivalAirport string `gorm:"column:flight1_arrival_airport" json:"flight1_arrival_airport"`

Flight2DepartureTime *time.Time `gorm:"column:flight2_departure_time;null" json:"flight2_departure_time"`
Flight2DepartureAirport *string `gorm:"column:flight2_departure_airport;null" json:"flight2_departure_airport"`
Flight2ArrivalTime *time.Time `gorm:"column:flight2_arrival_time;null" json:"flight2_arrival_time"`
Flight2ArrivalAirport *string `gorm:"column:flight2_arrival_airport;null" json:"flight2_arrival_airport"`
Flight2ArrivalTime *time.Time `gorm:"column:flight2_arrival_time;null" json:"flight2_arrival_time"`
Flight2ArrivalAirport *string `gorm:"column:flight2_arrival_airport;null" json:"flight2_arrival_airport"`

UserId int `json:"-"`
User User `gorm:"foreignKey:UserId" json:"user"`
Expand All @@ -32,13 +32,13 @@ type Interest struct {
type InterestInput struct {
Flight1DepartureTime time.Time `json:"flight1_departure_time" binding:"required"`
Flight1DepartureAirport string `json:"flight1_departure_airport" binding:"required"`
Flight1ArrivalTime time.Time `json:"flight1_arrival_time" binding:"required"`
Flight1ArrivalAirport string `json:"flight1_arrival_airport" binding:"required"`
Flight1ArrivalTime time.Time `json:"flight1_arrival_time" binding:"required"`
Flight1ArrivalAirport string `json:"flight1_arrival_airport" binding:"required"`
Flight2DepartureTime *time.Time `json:"flight2_departure_time"`
Flight2DepartureAirport *string `json:"flight2_departure_airport"`
Flight2ArrivalTime *time.Time `json:"flight2_arrival_time"`
Flight2ArrivalAirport *string `json:"flight2_arrival_airport"`
UserId int `json:"user_id" binding:"required"`
Flight2ArrivalTime *time.Time `json:"flight2_arrival_time"`
Flight2ArrivalAirport *string `json:"flight2_arrival_airport"`
UserId int `json:"user_id" binding:"required"`
}

// It validates data from `in` and returns a possible error or not
Expand Down Expand Up @@ -98,15 +98,15 @@ func ValidateInterest(db *gorm.DB, variables map[string]interface{}) (*InterestI
// `ValidateInterest(..., in)` method
func NewInterest(in InterestInput) Interest {
return Interest{
CreatedAt: time.Now(),
CreatedAt: time.Now(),
Flight1DepartureTime: in.Flight1DepartureTime,
Flight1DepartureAirport: in.Flight1DepartureAirport,
Flight1ArrivalTime: in.Flight1ArrivalTime,
Flight1ArrivalAirport: in.Flight1ArrivalAirport,
Flight1ArrivalTime: in.Flight1ArrivalTime,
Flight1ArrivalAirport: in.Flight1ArrivalAirport,
Flight2DepartureTime: in.Flight2DepartureTime,
Flight2DepartureAirport: in.Flight2DepartureAirport,
Flight2ArrivalTime: in.Flight2ArrivalTime,
Flight2ArrivalAirport: in.Flight2ArrivalAirport,
UserId: in.UserId,
Flight2ArrivalTime: in.Flight2ArrivalTime,
Flight2ArrivalAirport: in.Flight2ArrivalAirport,
UserId: in.UserId,
}
}
6 changes: 3 additions & 3 deletions internal/models/offer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ type Offer struct {

type OfferInputFields struct {
DepartureAirport string `binding:"required"`
ArrivalAirport string `binding:"required"`
ArrivalAirport string `binding:"required"`
DepartureTime string `binding:"required"`
ArrivalTime string `binding:"required"`
Cost float64 `binding:"required"`
ArrivalTime string `binding:"required"`
Cost float64 `binding:"required"`
}

// Struct used to get new data for an offer
Expand Down

0 comments on commit 4eea433

Please sign in to comment.