-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9b4a60
commit 3a8d88e
Showing
30 changed files
with
3,416 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package configuration | ||
|
||
import ( | ||
"encoding/base64" | ||
"log" | ||
"os" | ||
|
||
"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 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
defaults: | ||
formats: | ||
time: "2006-01-02T15:04:05" | ||
date: "2006-01-02" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
defaults: | ||
http: | ||
host: "localhost" | ||
port: "8080" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defaults: | ||
log: | ||
level: "error" | ||
format: "json" | ||
sentry: | ||
enable: true | ||
dsn: "https://924c371cd88d44759b1c7d282d1b1105:[email protected]/1364865" | ||
stackTrace: | ||
enable: true | ||
context: 0 | ||
skip: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
defaults: | ||
notifications: | ||
error_message_email: "[email protected]" | ||
mail_from: "[email protected]" | ||
pubsub: | ||
host: "localhost:8085" # for local pub/sup "localhost:8085" | ||
project_id: "tmconsulting24" | ||
topic: "notification-dev" | ||
subscription: "notification-receiver-dev" | ||
key: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defaults: | ||
queue: | ||
kind: "pubsub" # pubsub, redis, ... | ||
pubsub: | ||
host: "localhost:8085" # for local pub/sup "localhost:8085" | ||
project_id: "tmconsulting24" | ||
topic: "provider-logs-dev" | ||
subscription: "provider-logs-receiver-dev" | ||
key: "" | ||
redis: | ||
host: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defaults: | ||
settings: | ||
foid_require_airlines: ["2B","5N","7J","7R","8Q","BT","EY","FZ","HR","HY","J2","KC","KK","KR","LY","NN","PC","PS","QN","R2","R3","S7","SZ","U6","UT","VV","Y7","YC","YK","YQ","ZG"] | ||
remove_duplicate_airlines: false | ||
max_attempts_cancel_void: 5 # количество раз, которые система пробует отменить бронирование. каждая попытка предваряется sleep(attempt*seconds) | ||
max_attempts_doc_issuance: 5 # количество раз, которые система пробует выписать билет. каждая попытка предваряется sleep(attempt*seconds) | ||
max_attempts_pnr_ret: 5 # количество раз, которые система пробует сделать PNRRET. каждая попытка предваряется sleep(attempt*seconds) | ||
max_attempts_pnr_add: 5 # количество раз, которые система пробует сделать PNRADD. каждая попытка предваряется sleep(attempt*seconds) | ||
issue_expire: 30 # time in minutes, set TK XL time in minutes before departure | ||
booking_requests_delay: 2 # время задержки между запросами букинг | ||
issue_requests_delay: 0 # время задержки между запросами выписки | ||
fare_rules_paragraphs_to_show: ["PE", "CD"] # PE (16)-penalties, CD (19)-Children discounts | ||
fare_qualifier_list: ["P", "U"] # список fareQualifier, с которыми попытаются забронироваться |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package structs | ||
|
||
// Airline structure | ||
type Airline struct { | ||
CodeEng string `json:"code_eng" bson:"codeEng"` | ||
CodeRus string `json:"code_rus,omitempty" bson:"codeRus,omitempty"` | ||
NameEng string `json:"name_eng,omitempty" bson:"nameEng,omitempty"` | ||
NameRus string `json:"name_rus,omitempty" bson:"nameRus,omitempty"` | ||
} | ||
|
||
// Aircraft structure | ||
type Aircraft struct { | ||
Code *string `json:"code" db:"code" bson:"code"` | ||
Name map[string]string `json:"name,omitempty" db:"name" bson:"name,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package structs | ||
|
||
// BaggageType structure | ||
type BaggageType struct { | ||
Value int `json:"value"` | ||
Unit string `json:"unit"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package structs | ||
|
||
import ( | ||
"encoding/json" | ||
) | ||
|
||
// ClientInfo customer info structure | ||
type ClientInfo struct { | ||
OfficeID string `json:"office_id"` | ||
Timezone string `json:"timezone"` | ||
} | ||
|
||
// UnmarshalJSON overrides UnmarshalJSON | ||
func (c *ClientInfo) UnmarshalJSON(data []byte) error { | ||
type ClientInfo2 struct { | ||
Var1 string `json:"amadeus_office_id"` | ||
Var2 string `json:"office_id"` | ||
} | ||
var clientInfo ClientInfo2 | ||
if err := json.Unmarshal(data, &clientInfo); err != nil { | ||
//logs.Log.WithError(err).Error("Error unmarshal json") | ||
return err | ||
} | ||
var OfficeID = "" | ||
if clientInfo.Var1 != "" { | ||
OfficeID = clientInfo.Var1 | ||
} else { | ||
OfficeID = clientInfo.Var2 | ||
} | ||
c.OfficeID = OfficeID | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package structs | ||
|
||
// ErrorReply Error Reply structure | ||
type ErrorReply struct { | ||
Status string `json:"status,omitempty"` | ||
ErrorCode string `json:"code,omitempty"` | ||
Message string `json:"message,omitempty"` | ||
} |
Oops, something went wrong.