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

WIP: Release v1.0.0 #17

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
.env
vendor
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at otd@tm-consulting.ru. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests:
go test ./... -v
102 changes: 62 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,81 @@

This package contains structures, forms, functions and SOAP handler for Amadeus WS.

## SOAP Methods implemented

The following versions of services are currently implemented:

* Air_FlightInfo (05.1)
* Air_SellFromRecommendation (05.2)
* Command_Cryptic (07.3)
* DocIssuance_IssueTicket (09.1)
* Fare_CheckRules (07.1)
* Fare_ConvertCurrency (08.1)
* Fare_InformativeBestPricingWithoutPNR (12.4)
* Fare_InformativePricingWithoutPNR (12.4)
* Fare_MasterPricerCalendar (14.3, 12.2)
* Fare_MasterPricerTravelBoardSearch (16.3, 14.3, 12.3)
* Fare_PricePNRWithBookingClass (14.1, 12.4)
* PNR_AddMultiElements (11.3)
* PNR_Cancel (11.3)
* PNR_Retrieve (11.3)
* Queue_CountPlanner (03.1)
* Queue_CountTotal (03.1)
* Queue_List (11.1)
* Queue_MoveItem (03.1)
* Queue_PlacePNR (03.1)
* Queue_RemoveItem (03.1)
* Security_Authenticate (06.1)
* Security_SignOut (04.1)
* Ticket_CreateTSTFromPricing (04.1)
* Ticket_CreditCardCheck (06.1)
* Ticket_DeleteTST (04.1)
* Ticket_DisplayTST (07.1)
## Methods implementation progress

- [ ] Air_FlightInfo (05.1)
- [x] Air_SellFromRecommendation (05.2)
- [x] Command_Cryptic (07.3)
- [x] DocIssuance_IssueTicket (09.1)
- [x] Fare_CheckRules (07.1)
- [ ] Fare_ConvertCurrency (08.1)
- [x] Fare_InformativeBestPricingWithoutPNR (12.4)
- [x] Fare_InformativePricingWithoutPNR (12.4)
- [ ] Fare_MasterPricerCalendar (14.3, 12.2)
- [x] Fare_MasterPricerTravelBoardSearch (16.3, 14.3)
- [x] Fare_PricePNRWithBookingClass (14.1)
- [x] PNR_AddMultiElements (11.3)
- [x] PNR_Cancel (11.3)
- [x] PNR_Retrieve (11.3)
- [ ] Queue_CountPlanner (03.1)
- [ ] Queue_CountTotal (03.1)
- [ ] Queue_List (11.1)
- [ ] Queue_MoveItem (03.1)
- [ ] Queue_PlacePNR (03.1)
- [ ] Queue_RemoveItem (03.1)
- [x] Security_Authenticate (06.1)
- [x] Security_SignOut (04.1)
- [x] Ticket_CreateTSTFromPricing (04.1)
- [ ] Ticket_CreditCardCheck (06.1)
- [x] Ticket_DeleteTST (04.1)
- [x] Ticket_DisplayTST (07.1)
- [x] Ticket_ProcessEDoc (15.2)

## Installation

It is go gettable
It is go gettable and go.mod powered

$ go get github.com/tmconsulting/amadeus-golang-sdk
$ go get github.com/tmconsulting/amadeus-golang-sdk@latest

## Usage

Prepare log writer realisation if you need to see outgoing and incoming xmls (null logging used if nil is passed),
methods map that you want (and allowed by Amadeus) to run (use `GetLatestMethodsMap()` to use latest methods versions
that are implemented) and credentials to connect: url, originator, password (not in base64!). Initiate SDK and service:

```go
package main

import (
amadeusSdk "github.com/tmconsulting/amadeus-golang-sdk"
"log"

"github.com/tmconsulting/amadeus-golang-sdk/logger/stdoutLogger"
"github.com/tmconsulting/amadeus-golang-sdk/sdk"
"github.com/tmconsulting/amadeus-golang-sdk/service"
)
...
```

## Usage examples

There are several usage examples in `./example` folder. Try it out.
func main() {
url := "https://nodeD1.test.webservices.amadeus.com/1ASIWXXXXXX"
originator := "WSBENXXX"
passwordRaw := "dGhlIHBhc3N3b3Jk"
officeID := "BRUXX1111"
client := sdk.CreateAmadeusClient(url, originator, passwordRaw, officeID, stdoutLogger.Init())

amadeusSDK := service.NewSKD(client, service.GetLatestMethodsMap())

response, err := amadeusSDK.CommandCryptic("AN20MAYMOWLED/ALH")
if err != nil {
log.Fatalf("error: %v", err)
}

log.Printf("response: %v\n", response)
}
```

## Tests
## Testing

There are no tests yet. :( Feel free to help us to change this situation!
Create test `.env` file from [test.env-example](test.env-example), or run with ENV variables `make test`
(or `go test ./... -v`)

## Contribution

Expand Down
16 changes: 16 additions & 0 deletions client/ama.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package client

import "encoding/xml"

type AMASecurityHostedUser struct {
XMLName xml.Name `xml:"http://xml.amadeus.com/2010/06/Security_v1 AMA_SecurityHostedUser"`
UserId AMASecurityHostedUserUserID `xml:"UserID"`
}

type AMASecurityHostedUserUserID struct {
XMLName xml.Name `xml:"UserID"`
AgentDutyCode string `xml:"AgentDutyCode,attr"`
RequestorType string `xml:"RequestorType,attr"`
PseudoCityCode string `xml:"PseudoCityCode,attr"`
POSType string `xml:"POS_Type,attr"`
}
42 changes: 42 additions & 0 deletions client/book.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package client

import (
"github.com/tmconsulting/amadeus-golang-sdk/structs/air/sellFromRecommendation/v05.2/request"
"github.com/tmconsulting/amadeus-golang-sdk/structs/air/sellFromRecommendation/v05.2/response"
"github.com/tmconsulting/amadeus-golang-sdk/structs/fare/pricePNRWithBookingClass/v14.1/request"
"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"
"github.com/tmconsulting/amadeus-golang-sdk/structs/ticket/createTSTFromPricing/v04.1"
)

func (client *AmadeusClient) AirSellFromRecommendationV052(query *Air_SellFromRecommendationRequest_v05_2.Request) (*Air_SellFromRecommendationResponse_v05_2.Response, *ResponseSOAPHeader, error) {
var reply Air_SellFromRecommendationResponse_v05_2.Response
header, err := client.service.Call(soapUrl, "ITAREQ_05_2_IA", query, &reply, client)
return &reply, header, err
}

func (client *AmadeusClient) PNRAddMultiElementsV113(query *PNR_AddMultiElementsRequest_v11_3.Request) (*PNR_Reply_v11_3.Response, *ResponseSOAPHeader, error) {
var reply PNR_Reply_v11_3.Response
header, err := client.service.Call(soapUrl, "PNRADD_11_3_1A", query, &reply, client)
return &reply, header, err
}

func (client *AmadeusClient) FarePricePNRWithBookingClassV141(query *Fare_PricePNRWithBookingClassRequest_v14_1.Request) (*Fare_PricePNRWithBookingClassResponse_v14_1.Response, *ResponseSOAPHeader, error) {
var reply Fare_PricePNRWithBookingClassResponse_v14_1.Response
header, err := client.service.Call(soapUrl, "TPCBRQ_14_1_1A", query, &reply, client)
return &reply, header, err
}

func (client *AmadeusClient) TicketCreateTSTFromPricingV041(query *Ticket_CreateTSTFromPricing_v04_1.Request) (*Ticket_CreateTSTFromPricing_v04_1.Response, *ResponseSOAPHeader, error) {
var reply Ticket_CreateTSTFromPricing_v04_1.Response
header, err := client.service.Call(soapUrl, "TAUTCQ_04_1_1A", query, &reply, client)
return &reply, header, err
}

func (client *AmadeusClient) PNRCancelV113(query *PNR_Cancel_v11_3.Request) (*PNR_Reply_v11_3.Response, *ResponseSOAPHeader, error) {
var reply PNR_Reply_v11_3.Response
header, err := client.service.Call(soapUrl, "PNRXCL_11_3_1A", query, &reply, client)
return &reply, header, err
}
47 changes: 47 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package client

import (
"github.com/tmconsulting/amadeus-golang-sdk/logger"
"github.com/tmconsulting/amadeus-golang-sdk/logger/nilLogger"
"github.com/tmconsulting/amadeus-golang-sdk/structs/session/v03.0"
)

var (
soapUrl = "http://webservices.amadeus.com/WSAP/"
amaUrl = "http://webservices.amadeus.com/"
)

func New(opts ...Option) *AmadeusClient {
c := &AmadeusClient{
Session: CreateSession(),
service: &WebServicePT{
Client: &SOAP4Client{
TLSEnable: true,
Logger: logger.NewLogger(nilLogger.Init()),
},
},
}
for _, opt := range opts {
opt(c)
}
return c
}

type AmadeusClient struct {
Session *Session_v03_0.Session
service *WebServicePT
}

func (client *AmadeusClient) Close() error {
if client == nil || client.service == nil {
return nil
}
if client.Session != nil && client.Session.TransactionStatusCode != Session_v03_0.TransactionStatusCode[Session_v03_0.End] {
client.Session.TransactionStatusCode = Session_v03_0.TransactionStatusCode[Session_v03_0.End]
if _, _, err := client.SecuritySignOutV041(); err != nil {
return err
}
client.Session = nil
}
return nil
}
12 changes: 12 additions & 0 deletions client/comandCryptic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package client

import (
"github.com/tmconsulting/amadeus-golang-sdk/structs/commandCryptic/v07.3"
)

func (client *AmadeusClient) CommandCrypticV073(query *CommandCryptic_v07_3.Request) (*CommandCryptic_v07_3.Response, error) {
var reply CommandCryptic_v07_3.Response
header, err := client.service.Call(soapUrl, "HSFREQ_07_3_1A", query, &reply, client)
client.IncSessionSequenceNumber(header)
return &reply, err
}
28 changes: 28 additions & 0 deletions client/information.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package client

import (
"github.com/tmconsulting/amadeus-golang-sdk/structs/fare/checkRules/v07.1/request"
"github.com/tmconsulting/amadeus-golang-sdk/structs/fare/checkRules/v07.1/response"
"github.com/tmconsulting/amadeus-golang-sdk/structs/fare/informativePricingWithoutPNR/v12.4/request"
"github.com/tmconsulting/amadeus-golang-sdk/structs/fare/informativePricingWithoutPNR/v12.4/response"
"github.com/tmconsulting/amadeus-golang-sdk/structs/pnr/reply/v11.3"
"github.com/tmconsulting/amadeus-golang-sdk/structs/pnr/retrieve/v11.3"
)

func (client *AmadeusClient) PNRRetrieveV113(query *PNR_Retrieve_v11_3.Request) (*PNR_Reply_v11_3.Response, *ResponseSOAPHeader, error) {
var reply PNR_Reply_v11_3.Response
header, err := client.service.Call(soapUrl, "PNRRET_11_3_1A", query, &reply, client)
return &reply, header, err
}

func (client *AmadeusClient) FareInformativePricingWithoutPNRV124(query *Fare_InformativePricingWithoutPNR_v12_4.Request) (*Fare_InformativePricingWithoutPNRReply_v12_4.Response, *ResponseSOAPHeader, error) {
var reply Fare_InformativePricingWithoutPNRReply_v12_4.Response
header, err := client.service.Call(soapUrl, "TIPNRQ_12_4_1A", query, &reply, client)
return &reply, header, err
}

func (client *AmadeusClient) FareCheckRulesV071(query *Fare_CheckRulesRequest_v07_1.Request) (*Fare_CheckRulesResponse_v07_1.Response, *ResponseSOAPHeader, error) {
var reply Fare_CheckRulesResponse_v07_1.Response
header, err := client.service.Call(soapUrl, "FARQNQ_07_1_1A", query, &reply, client)
return &reply, header, err
}
11 changes: 11 additions & 0 deletions client/issue.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package client

import (
"github.com/tmconsulting/amadeus-golang-sdk/structs/docIssuance/issueTicket/v09.1"
)

func (client *AmadeusClient) DocIssuanceIssueTicketV091(query *DocIssuance_IssueTicket_v09_1.Request) (*DocIssuance_IssueTicket_v09_1.Response, *ResponseSOAPHeader, error) {
var reply DocIssuance_IssueTicket_v09_1.Response
header, err := client.service.Call(soapUrl, "TTKTIQ_09_1_1A", query, &reply, client)
return &reply, header, err
}
Loading