Skip to content
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

Open
wants to merge 31 commits into
base: mass-refactoring
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8173691
logger
alexkadyrov Jul 12, 2019
7cb307c
pnr_retrieve
alexkadyrov Jul 13, 2019
6ae820c
pnr_retrieve
alexkadyrov Jul 15, 2019
cf6e1f6
pnr_retrieve
alexkadyrov Jul 15, 2019
bbecf3b
правки по дискашену
alexkadyrov Jul 16, 2019
c90777b
правки по дискашену
alexkadyrov Jul 16, 2019
cfcb2c0
правки по дискашену
alexkadyrov Jul 16, 2019
074d09d
правки по дискашену
alexkadyrov Jul 16, 2019
9a13392
PNR info. Segments parsing
alexkadyrov Jul 16, 2019
4804268
Tests (#18)
smgladkovskiy Jul 16, 2019
1eb476d
Update README.md
smgladkovskiy Jul 16, 2019
1c0bdf7
PNR info. Segments parsing
alexkadyrov Jul 17, 2019
e924a5b
Merge branch 'mass-refactoring' into refactoring-2
alexkadyrov Jul 17, 2019
6af3efe
search request
alexkadyrov Jul 25, 2019
6048cf5
search request
alexkadyrov Jul 25, 2019
c9b4a60
search request
alexkadyrov Jul 25, 2019
3a8d88e
search complete
alexkadyrov Sep 27, 2019
89d0479
убрана бизнес логика, фильтры, скипы
alexkadyrov Sep 27, 2019
3b955a5
cleanup
alexkadyrov Sep 27, 2019
9e29012
config
alexkadyrov Sep 27, 2019
69652c3
got rid of config
alexkadyrov Sep 29, 2019
52b9b98
search request validation
alexkadyrov Sep 29, 2019
6a2edef
search request add travelers
alexkadyrov Sep 29, 2019
cac9f47
search request add travelers
alexkadyrov Sep 29, 2019
8dcb91d
тесты на make query и на валидаторы
alexkadyrov Sep 30, 2019
c251e9d
тесты на функции по работе с датами и временем
alexkadyrov Sep 30, 2019
9ee8a84
тесты на методы структур
alexkadyrov Sep 30, 2019
0bbdbe9
тесты на методы работы со слайсами и массивами
alexkadyrov Sep 30, 2019
af2a79d
deploy
alexkadyrov Sep 30, 2019
1886525
deploy
alexkadyrov Sep 30, 2019
83b7c9d
FareMasterPricerTravelBoardSearch V16.3
alexkadyrov Oct 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion client/options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package client

import "github.com/tmconsulting/amadeus-golang-sdk/logger"
import (
"github.com/tmconsulting/amadeus-golang-sdk/configuration"
"github.com/tmconsulting/amadeus-golang-sdk/logger"
)

// Option describes a functional option for configuring AmadeusClient.
type Option func(client *AmadeusClient)
Expand Down Expand Up @@ -38,3 +41,9 @@ func SetLogger(l logger.LogWriter) Option {
c.service.Client.Logger = logger.NewLogger(l)
}
}

func SetConfig(config configuration.ConfigType) Option {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не надо так. Опции -- для опций. Тут не нужно передавать структурой целой конфиг. Если нужен формат -- сделай "setTimeFormat" функцию и всё. По-дефолту формат в свойство клиента и переопределяй опцией.

return func(c *AmadeusClient) {
configuration.Config = config
}
}
2 changes: 2 additions & 0 deletions client/soapClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ func (s *SOAP4Client) Call(soapUrl, soapAction, messageId string, query, reply i
return nil, err
}

fmt.Println("XML Response: ", string(rawbody))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это в логи нужно. дебагом


err = s.Logger.Push("inc", soapAction, string(rawbody))
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Failed to fire hook log_response: %v\n", err)
Expand Down
126 changes: 7 additions & 119 deletions configuration/config.go
Original file line number Diff line number Diff line change
@@ -1,126 +1,14 @@
package configuration
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не нужен конфиг тут от слова совсем!


import (
"encoding/base64"
"log"
"os"
var Config ConfigType

"github.com/microparts/configuration-golang"
"github.com/microparts/errors-go"
"github.com/microparts/logs-go"
"gopkg.in/yaml.v2"
)

type connectionConfig struct {
URL string `yaml:"url"`
WSAP string `yaml:"wsap"`
Originator string `yaml:"originator"`
Password string `yaml:"password"`
PasswordRaw string
PinCode string `yaml:"pin_code"`
VatURL string `yaml:"vat_url"`
VatSOAPURL string `yaml:"vat_soap_url"`
VatOfficeID string `yaml:"vat_office_id"`
VatSign string `yaml:"vat_sign"`
}

type amadeusConfig struct {
Connection connectionConfig `yaml:"connection"`
MaxRecommendations int `yaml:"max_recommendations"`
}

type httpConfig struct {
Host string `yaml:"host"`
Port string `yaml:"port"`
type ConfigType struct {
Formats formatsConfig
Provider string
}

type formatsConfig struct {
Time string `yaml:"time"`
Date string `yaml:"date"`
XMLDate string `yaml:"xml_date"`
}

// CfgType service config structure
type CfgType struct {
Amadeus amadeusConfig `yaml:"amadeus"`
HTTP httpConfig `yaml:"http"`
Formats formatsConfig `yaml:"formats"`
Queue queueConfig `yaml:"queue"`
Log *logs.Config `yaml:"log"`
Settings SettingsConfig `yaml:"settings"`
Notifications NotificationsConfig `yaml:"notifications"`
}

type queueConfig struct {
PubSub PubSubConfig `yaml:"pubsub"`
}

// PubSubConfig PubSub Config
type PubSubConfig struct {
Host string `yaml:"host"`
ProjectID string `yaml:"project_id"`
Topic string `yaml:"topic"`
Subscription string `yaml:"subscription"`
Key string `yaml:"key"`
}

// SettingsConfig Settings Config
type SettingsConfig struct {
FoidRequreAirlines []string `yaml:"foid_require_airlines"`
RemoveDuplicateAirlines bool `yaml:"remove_duplicate_airlines"`
MaxAttemptsCancelVoid int `yaml:"max_attempts_cancel_void"`
MaxAttemptsDocIssuance int `yaml:"max_attempts_doc_issuance"`
MaxAttemptsPNRRET int `yaml:"max_attempts_pnr_ret"`
MaxAttemptsPNRADD int `yaml:"max_attempts_pnr_add"`
IssueExpire int `yaml:"issue_expire"`
BookingRequestsDelay int `yaml:"booking_requests_delay"`
IssueRequestsDelay int `yaml:"issue_requests_delay"`
FareRulesParagraphsToShow []string `yaml:"fare_rules_paragraphs_to_show"`
FareQualifierList []string `yaml:"fare_qualifier_list"`
}

type NotificationsConfig struct {
ErrorMessageEmail string `yaml:"error_message_email"`
MailFrom string `yaml:"mail_from"`
Queue PubSubConfig `yaml:"pubsub"`
}

var (
// Provider is current service
Provider = "amadeus"
)

var Config *CfgType

// InitConfig initialize config data
func InitConfig() error {
configPath := config.GetEnv("CONFIG_PATH", "")
configBytes, err := config.ReadConfigs(configPath)
if errors.HasErrors(err) {
log.Printf("[config] read error: %+v", err)
return err
}

err = yaml.Unmarshal(configBytes, &Config)
if errors.HasErrors(err) {
log.Printf("[config] unmarshal error for bytes: %+v", configBytes)
return err
}
//
// structs.TimeFormat = func() string {
// return Config.Formats.Time
// }
//
// structs.DateFormat = func() string {
// return Config.Formats.Date
// }

if pwdBytes, err := base64.StdEncoding.DecodeString(Config.Amadeus.Connection.Password); err == nil {
Config.Amadeus.Connection.PasswordRaw = string(pwdBytes)
} else {
log.Println("Error decoding password. Is it not encrypted in bass64?")
os.Exit(-1)
}

return nil
Time string
Date string
XMLDate string
}
4 changes: 0 additions & 4 deletions configuration/defaults/formats.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions configuration/defaults/http.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions configuration/defaults/log.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions configuration/defaults/notifications.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions configuration/defaults/queue.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions configuration/defaults/settings.yaml

This file was deleted.

17 changes: 6 additions & 11 deletions service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
passwordRaw string
officeId string
stdOutLog, logger l.LogWriter
config configuration.ConfigType
)

func tearUp() {
Expand All @@ -36,6 +37,10 @@ func tearUp() {
logger = nilLogger.Init()
stdOutLog = stdoutLogger.Init()

config.Formats.Time = "2006-01-02T15:04:05"
config.Formats.Date = "2006-01-02"
config.Provider = "amadeus"

log.Printf("url: %s\noriginator: %s\npasswordRaw: %s\nofficeId: %s", url, originator, passwordRaw, officeId)
}

Expand Down Expand Up @@ -89,17 +94,7 @@ func TestNewSKD(t *testing.T) {

tearUp()

err := configuration.InitConfig()
if err != nil {
t.FailNow()
}

//url = configuration.Config.Amadeus.Connection.URL
//originator = configuration.Config.Amadeus.Connection.Originator
//passwordRaw = configuration.Config.Amadeus.Connection.PasswordRaw
//officeId = "MOWR228FG"

cl := client.New(client.SetURL(url), client.SetUser(originator), client.SetPassword(passwordRaw), client.SetAgent(officeId), client.SetLogger(stdOutLog))
cl := client.New(client.SetURL(url), client.SetUser(originator), client.SetPassword(passwordRaw), client.SetAgent(officeId), client.SetLogger(stdOutLog), client.SetConfig(config))

amadeusSDK := New(cl)
//amadeusSDK := New(cl, SetMethodVersion(PNRAddMultiElements, MethodVersion(PNRRetrieveV113)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Конфиг не нужен. из свойств клиента брать.

Class: recClass,
ItinerarySegments: routesSegments,
ValidatingAirline: structsCommon.Airline{},
Expand Down