Skip to content

Commit

Permalink
Merge pull request #18 from tmconsulting/fix-tests
Browse files Browse the repository at this point in the history
API ver. 2.0
  • Loading branch information
7phs authored Jan 10, 2019
2 parents dddc7ac + 550c336 commit ef91615
Show file tree
Hide file tree
Showing 22 changed files with 149 additions and 92 deletions.
50 changes: 35 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ go get github.com/tmconsulting/aanda-golang-sdk

### Import
```golang
import "github.com/tmconsulting/aanda-golang-sdk"
import (
"context"
"log"

"github.com/tmconsulting/aanda-golang-sdk"
)
```

### Example init variables
Expand All @@ -22,9 +27,24 @@ var (
Language: "ru",
}
aApi = aandaSdk.NewApi(auth)

ctx = context.WithValue(context.Backround(), "requestId", "b5cd6a4a-efee-4146-8bec-bf5457558750")
)
```

### Example init hooks/handlers
```golang
aApi.RegisterEventHandler(aandaSdk.BeforeRequestSend, func(ctx context.Context, methodName, mimeType string, data []byte) {
requestId := ctx.Value("requestId").(string)

log.Println("request: ", requestId, methodName, mimeType, string(data))
}).RegisterEventHandler(aandaSdk.AfterResponseReceive, func(ctx context.Context, methodName, mimeType string, data []byte) {
requestId := ctx.Value("requestId").(string)

log.Println("response: ", requestId, methodName, mimeType, string(data))
})
```

### Example HotelSearchRequest
```golang
searchReq := aandaSdk.HotelSearchRequest{
Expand All @@ -38,7 +58,7 @@ searchReq := aandaSdk.HotelSearchRequest{
PriceTo: "3000",
NumberOfGuests: "1",
}
data, err := aApi.HotelSearchRequest(searchReq)
data, err := aApi.HotelSearchRequest(ctx, searchReq)
if err == nil {
//Work with data
}
Expand All @@ -57,7 +77,7 @@ priceReq := aandaSdk.HotelPricingRequest{
DepartureTime: "3000",
NumberOfGuests: "1",
}
data, err := aApi.HotelPricingRequest(priceReq)
data, err := aApi.HotelPricingRequest(ctx, priceReq)
if err == nil {
//Work with data
}
Expand All @@ -80,7 +100,7 @@ orderReq := aandaSdk.OrderRequest{
LastName: "Name",
}},
}
data, err := aApi.OrderRequest(orderReq)
data, err := aApi.OrderRequest(ctx, orderReq)
if err == nil {
//Work with data
}
Expand All @@ -104,7 +124,7 @@ orderReq := aandaSdk.OrderListRequest{
//RegistrationDateFrom: "23.02.2018",
//RegistrationDateTo: "22.02.2018",
}
data, err := aApi.OrderListRequest(orderReq)
data, err := aApi.OrderListRequest(ctx, orderReq)
if err == nil {
//Work with data
}
Expand All @@ -116,79 +136,79 @@ somReq := aandaSdk.SendOrderMessageRequest{
OrderId: 2213397,
Message: "test message 2 3 4 22 22",
}
data, err := aApi.SendOrderMessageRequest(somReq)
data, err := aApi.SendOrderMessageRequest(ctx, somReq)
if err == nil {
//Work with data
}
```

### Example OrderMessagesRequest
```golang
data, err := aApi.OrderMessagesRequest(2213397) // 2213397 is OrderId
data, err := aApi.OrderMessagesRequest(ctx, 2213397) // 2213397 is OrderId
if err == nil {
//Work with data
}
```

### Example CountryListRequest
```golang
data, err := aApi.CountryListRequest()
data, err := aApi.CountryListRequest(ctx)
if err == nil {
//Work with data
}
```

### Example CityListRequest
```golang
data, err := aApi.CityListRequest(9)//9 is CountryCode
data, err := aApi.CityListRequest(ctx, 9)//9 is CountryCode
if err == nil {
//Work with data
}
```

### Example HotelListRequest
```golang
data, err := aApi.HotelListRequest(1)//1 is CityCode == Moscow
data, err := aApi.HotelListRequest(ctx, 1)//1 is CityCode == Moscow
if err == nil {
//Work with data
}
```

### Example HotelDescriptionRequest
```golang
data, err := aApi.HotelDescriptionRequest(2150)//2150 is HotelCode
data, err := aApi.HotelDescriptionRequest(ctx, 2150)//2150 is HotelCode
if err == nil {
//Work with data
}
```

### Example CurrencyListRequest
```golang
data, err := aApi.CurrencyListRequest()
data, err := aApi.CurrencyListRequest(ctx)
if err == nil {
//Work with data
}
```

### Example MealTypeRequest
```golang
data, err := aApi.MealTypeRequest()
data, err := aApi.MealTypeRequest(ctx)
if err == nil {
//Work with data
}
```

### Example MealCategoryeRequest
```golang
data, err := aApi.MealCategoryRequest()
data, err := aApi.MealCategoryRequest(ctx)
if err == nil {
//Work with data
}
```

### Example ClientStatusRequest
```golang
data, err := aApi.ClientStatusRequest()
data, err := aApi.ClientStatusRequest(ctx)
if err == nil {
//Work with data
}
Expand Down
Loading

0 comments on commit ef91615

Please sign in to comment.