-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PNR_Info service #13
base: mass-refactoring
Are you sure you want to change the base?
PNR_Info service #13
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Помимо всего прочего, не забываем обновлять go.mod
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ещё немного замечаний
import ( | ||
"github.com/tmconsulting/amadeus-golang-sdk/structs/pnr/retrieve" | ||
"github.com/tmconsulting/amadeus-golang-sdk/utils" | ||
"gitlab.teamc.io/tm-consulting/tmc24/avia/layer3/amadeus-agent-go/configuration" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это явно лишнее
// This data element is used to qualify the company code, to identify the industry business it belongs. | ||
TravelSector string `xml:"travelSector"` | ||
|
||
// This data element is used to convey the company code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вынести формат времени в свойства сервиса и опицией ооверрайдить при необходимости
client/book.go
Outdated
@@ -7,7 +7,7 @@ import ( | |||
"github.com/tmconsulting/amadeus-golang-sdk/structs/fare/pricePNRWithBookingClass/v14.1/response" | |||
"github.com/tmconsulting/amadeus-golang-sdk/structs/pnr/addMultiElements/v11.3" | |||
"github.com/tmconsulting/amadeus-golang-sdk/structs/pnr/cancel/v11.3" | |||
"github.com/tmconsulting/amadeus-golang-sdk/structs/pnr/reply/v11.3" | |||
PNR_Reply_v11_3_response "github.com/tmconsulting/amadeus-golang-sdk/structs/pnr/retrieve/v11.3/response" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лишний алиас
rebase for build and tests coverage |
type mapItineraries map[int]*Itinerary | ||
|
||
// Check validate search request | ||
func (request *SearchRequest) Check() (err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Разбивай чек на куски:
- проверка на пустые данные
- проверка на согласованность типа маршрута и itineraries
- проверка пассажиров
- проверка и работа с itineraries
Все их (функции) покрыть тестами.
return nil | ||
} | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
убрать комментированные данные
*/ | ||
|
||
// SearchResponse structure of Search response | ||
type SearchResponse struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
структуры запросов и ответов выделить и разнести по файлам, дабы читались проще
UnitNumberDetail: []*NumberOfUnitDetailsType_260583C{ | ||
{ | ||
NumberOfUnits: formats.NumericInteger_Length1To6(request.Passengers.ADT + request.Passengers.CHD), | ||
TypeOfUnit: formats.AlphaNumericString_Length1To3("PX"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут и далее -- может в константы эти штуки выносить с добавлением того, что может быть ещё, помимо тех параметров, что тут указаны? Когда потребуется регулировать структуру запроса -- они будут вынесены в параметры request'а
|
||
paxID := 1 | ||
if request.Passengers.ADT > 0 { | ||
var travellers []*TravellerDetailsType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавление пассажира -- в единую функцию с передачей параметра типа пассажира. Добавление пакса сделать проходом по мапе.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
и тесты на это
@@ -0,0 +1,35 @@ | |||
package search |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
что пустое?
@@ -0,0 +1,122 @@ | |||
package search |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Что пустое?
"time" | ||
) | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не нужный код
|
||
func (reply *Response) ToCommon(request *search.SearchRequest) (*search.SearchResponse, error) { | ||
|
||
return ParseReply(request, reply) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а зачем делать тут функцию, если можно было бы содержимое той функции тут отразить?
var segments = make(map[string]*structsCommon.Flight) | ||
|
||
// Recommendation details | ||
for _, recReply := range reply.Recommendation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот это бы зарефакторить, разбив на более мелкие составляющие, начиная с самого глубокого цикла по дереву вложённости
b5a4e4d
to
3b955a5
Compare
1badb5d
to
7ab48ea
Compare
client/soapClient.go
Outdated
@@ -164,6 +164,8 @@ func (s *SOAP4Client) Call(soapUrl, soapAction, messageId string, query, reply i | |||
return nil, err | |||
} | |||
|
|||
fmt.Println("XML Response: ", string(rawbody)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это в логи нужно. дебагом
client/options.go
Outdated
@@ -38,3 +41,9 @@ func SetLogger(l logger.LogWriter) Option { | |||
c.service.Client.Logger = logger.NewLogger(l) | |||
} | |||
} | |||
|
|||
func SetConfig(config configuration.ConfigType) Option { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не надо так. Опции -- для опций. Тут не нужно передавать структурой целой конфиг. Если нужен формат -- сделай "setTimeFormat" функцию и всё. По-дефолту формат в свойство клиента и переопределяй опцией.
configuration/config.go
Outdated
@@ -1,126 +1,14 @@ | |||
package configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не нужен конфиг тут от слова совсем!
@@ -630,7 +630,7 @@ func ParseReply(request *search.SearchRequest, reply *Response) (*search.SearchR | |||
|
|||
var recommendation = &search.Recommendation{ | |||
ID: recommendationID, | |||
Provider: configuration.Provider, | |||
Provider: configuration.Config.Provider, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Конфиг не нужен. из свойств клиента брать.
#15 related