mss

package module
v0.0.88 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 16 Imported by: 0

README

mss-go

MSS API client for Go projects

Dependencies

This library requires an IANA Time Zone database to be present on the operating system (because it uses https://pkg.go.dev/time#LoadLocation). This database comes pre-installed with many Linux distros. If it’s unavailable (such as on Windows), https://pkg.go.dev/time/tzdata can be imported in the main program (which uses mss-go) instead.

Available methods

  • getHotelList ✓
  • getSpecialList ✓
  • getRoomList ✓
  • getPriceList ✓
  • getRoomAvailability ✓
  • prepareBooking ✓
  • getBooking ✓
  • cancelBooking ✓
  • createInquiry ✓
  • getUserSources ✓
  • getLocationList ✓
  • getMasterpackagesList
  • getThemeList
  • validateCoupon ✓

Warning: Only the methods with a ✓ next to them have been tested so far.

Before running examples/tests

Set the environment variables with:

export $(make env)

Examples

Run make simple or make advanced

Tests

Run make test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorResponse

func ErrorResponse(h response.Header) error

ErrorResponse checks if MSS returned an error in its response and formats it accordingly.

Types

type Callback

type Callback func(request.Root) request.Root

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(h http.Client, c Credentials) Client

NewClient creates a new client for requests to MSS. Make sure to pass an http.Client with a reasonable timeout, e.g. 10–20 seconds.

func NewDefaultClient

func NewDefaultClient(c Credentials) Client

NewDefaultClient creates a new default client for requests to MSS. The underlying http.Client is preconfigured with reasonable settings.

func (Client) Request

func (c Client) Request(ctx context.Context, cb Callback) (*response.Root, error)

func (Client) RequestXML

func (c Client) RequestXML(
	ctx context.Context, cb Callback,
) (io.ReadCloser, error)

RequestXML takes a callback to construct the request root, marshals it to XML, sends it to MSS and outputs the MSS XML response body as io.ReadCloser.

type Credentials

type Credentials struct {
	User     string
	Password string
	Source   string
}

type Error

type Error struct {
	Err        error
	Code       response.ErrorCode
	StatusCode int
}

func AsError

func AsError(err error) *Error

AsError checks if the error matches mss.Error. If it matches, it returns the Error, otherwise it returns nil.

func (Error) Error

func (e Error) Error() string

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL