bm

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package bm contains the go bindings for MMK's booking manager REST API.

Booking Manager API is a standard Web service that enables clients to connect their data with external systems and services and to extend the automation benefits of the Booking Manager System.

It is used by charter agencies to publish availabilities of Charter Operators and automate booking processes by connecting Booking Manager to their own web sites to allow for seamless online booking experience for end users or integrating it with their CRM solutions in order to automate office procedures.

Charter operators use the web service to connect Booking Manager with their book keeping softwares and save time and effort in accounting department.

Third Party Software tools also use Booking Manager API to display richer information, for example boat tracking systems are able to visualise client contact information directly on the map showing the boat location in real time.

Index

Constants

View Source
const (
	BaseURL            = "https://www.booking-manager.com/api/v2/"
	AuthHeader         = "Authorization"
	TokenType          = "Bearer"
	APITokenContainer  = "MMK_API_TOKEN"
	RequestContentType = "application/json"
)

MMK Booking-Manager global constants.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body.

Types

type AvailabilityOptions

type AvailabilityOptions struct {
	CompanyID int `url:"companyId,omitempty"`
}

AvailabilityOptions describes valid query string parameters for availability requests.

type AvailabilityResponse

type AvailabilityResponse struct {
	ID                   int64        `json:"id,omitempty"`
	YachtID              int64        `json:"yachtId,omitempty"`
	Status               int64        `json:"status,omitempty"`
	BaseFromID           int64        `json:"baseFromId,omitempty"`
	BaseToID             int64        `json:"baseToId,omitempty"`
	DateFrom             *MMKDateTime `json:"dateFrom,omitempty"`
	DateTo               *MMKDateTime `json:"dateTo,omitempty"`
	OptionExpirationDate *MMKDateTime `json:"optionExpirationDate,omitempty"`
}

AvailabilityResponse descriptor.

type AvailabilityService

type AvailabilityService service

AvailabilityService operates over availability requests.

func (*AvailabilityService) GetAvailability

func (as *AvailabilityService) GetAvailability(year int, opts *AvailabilityOptions) (ar []*AvailabilityResponse, err error)

GetAvailability returns availability for specific year.

func (*AvailabilityService) GetShortAvailability

func (as *AvailabilityService) GetShortAvailability(year int, opts *ShortAvailabilityOptions) (sar []*ShortAvailabilityResponse, err error)

GetShortAvailability returns availability for specific year. Different status format will retrieve results in different format.

Formats and definition. 1 Binary - availability information for the resource in binary format. Each availabilityInfo is 365 characters long (or 366 in case of the leap year) and it represents the whole year (single character is one day of the year). First character is January 1st, second character is January 2nd, and so on. If character is equal to “0” it means that yacht is available on that day, otherwise character is equalto “1”. 2 Hex - availability information for the resource in hexadecimal format. Each availabilityInfo is 92 characters long and it represents the whole year. First character is January 1, January 2, January 3 and January 4, second character is January 5, January 6, January 7 and January 8, and so on. Last characters should be discarded depending on how long the requested year is. Example, if availabilityInfo is “fe03f0..” in binary it is “0000 0001 1111 1100 0000 1111..” and it means that yacht is available from January 1 until January 8, but it is not available from January 8 until January 15, and so on. 3 Status - Response is the same as the Binary response with one difference – booked days are not represented with character “1” for all types of reservations but instead reservation status id is used. Example, if availabilityInfo is “2222 2220 0000...” it means that boat is under status Option from January 1 until January 8, and it is free from January 8 etc.

type Base added in v0.1.0

type Base struct {
	ID           int64   `json:"id,omitempty"`
	Name         string  `json:"name,omitempty"`
	City         string  `json:"city,omitempty"`
	Country      string  `json:"country,omitempty"`
	Latitude     string  `json:"latitude,omitempty"`
	Longitude    string  `json:"longitude,omitempty"`
	CountryID    int64   `json:"countryId,omitempty"`
	SailingAreas []int64 `json:"sailingAreas,omitempty"`
}

Base is a location for the boat.

type BaseService added in v0.1.0

type BaseService service

func (*BaseService) Get added in v0.1.0

func (bs *BaseService) Get(id string) (b *Base, err error)

Get returns only one base with the specified id.

See: https://app.swaggerhub.com/apis-docs/mmksystems/bm-api/2.0.2#/Booking/getBaseById

func (*BaseService) List added in v0.1.0

func (bs *BaseService) List() (bases []*Base, err error)

List retrieves a list of bases that are assigned for each boat. Base is the exact location where boat is located. One base can belong to more sailing areas. In that case, multiple dedicated sailing areas are separated by comma.

See: https://app.swaggerhub.com/apis-docs/mmksystems/bm-api/2.0.2#/Booking/getBases

type Bi

type Bi struct {
	Name  string  `json:"name,omitempty"`
	Value float64 `json:"value,omitempty"`
}

Bi is something I yet have to understand.

type Client

type Client struct {
	BaseURL *url.URL

	// Services
	Availability *AvailabilityService
	Countries    *CountryService
	Offers       *OffersService
	Reservation  *ReservationService
	Price        *PriceService
	// contains filtered or unexported fields
}

Client manages communication with MMK's API.

func NewClient

func NewClient(baseClient *http.Client) (mmk *Client, err error)

NewClient returns a new MMK HTTP API client. You can pass a previously build http client, if none is provided then http.DefaultClient will be used.

NewClient will lookup the environment for values to assign to the API token (`MMK_API_TOKEN`).

func (*Client) Do

func (c *Client) Do(req *http.Request) (*Response, error)

Do sends an API request and returns the API response or returned as an error if an API error has occurred.

func (*Client) NewAPIRequest

func (c *Client) NewAPIRequest(method string, uri string, body interface{}) (req *http.Request, err error)

NewAPIRequest is a wrapper around the http.NewRequest function.

It will setup the authentication headers/parameters according to the client config.

type Company added in v0.1.0

type Company struct {
	ID                 int64  `json:"id,omitempty"`
	Name               string `json:"name,omitempty"`
	Address            string `json:"address,omitempty"`
	City               string `json:"city,omitempty"`
	ZipCode            string `json:"zip,omitempty"`
	Country            string `json:"country,omitempty"`
	Telephone          string `json:"telephone,omitempty"`
	Telephone2         string `json:"telephone2,omitempty"`
	Mobile             string `json:"mobile,omitempty"`
	VATCode            string `json:"vatCode,omitempty"`
	Email              string `json:"email,omitempty"`
	Web                string `json:"web,omitempty"`
	BankAccountNumber  string `json:"bankAccountNumber,omitempty"`
	TermsAndConditions string `json:"termsAndConditions,omitempty"`
}

Company represents a booking manager organizational user.

type Country

type Country struct {
	ID          int64  `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Short       string `json:"short,omitempty"`
	Long        string `json:"long,omitempty"`
	WorldRegion int64  `json:"worldRegion,omitempty"`
}

Country describes a single country in Booking Manager. It is a standard country entry with standard ISO elements for name, shortCode, longCode and numerical country id. worldRegion field links to an MMK defined world region available via /worldRegions call.

type CountryService

type CountryService service

CountryService handles operations with MMK countries registry.

func (*CountryService) Get

func (cs *CountryService) Get(id string) (c *Country, err error)

Get retrieves only one country by id.

func (*CountryService) List

func (cs *CountryService) List() (countries []*Country, err error)

List retrieves a list of all ISO-3166 countries and their short, long codes and world region code.

type Equipment added in v0.1.0

type Equipment struct {
	ID   int64  `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

Equipment are additional elements for the boat or the crew.

type Error

type Error struct {
	Code     int            `json:"code"`
	Message  string         `json:"message"`
	Content  string         `json:"content,omitempty"`
	Response *http.Response `json:"response"` // the full response that produced the error
}

Error reports details on a failed API request.

func (*Error) Error

func (e *Error) Error() string

Error function complies with the error interface

type Extra added in v0.1.0

type Extra struct {
	Name                  string           `json:"name,omitempty"`
	Obligatory            bool             `json:"obligatory,omitempty"`
	Price                 float64          `json:"price,omitempty"`
	Unit                  string           `json:"unit,omitempty"`
	PayableInBase         bool             `json:"payableInBase,omitempty"`
	IncludedDepositWaiver bool             `json:"includedDepositWaiver,omitempty"`
	ValidDaysFrom         int64            `json:"validDaysFrom,omitempty"`
	ValidDaysTo           int64            `json:"validDaysTo,omitempty"`
	MinNumberOfPersons    int64            `json:"minNumberOfPersons,omitempty"`
	ManNumberOfPersons    int64            `json:"manNumberOfPersons,omitempty"`
	ValidForBases         []*ValidForBases `json:"validForBases,omitempty"`
}

Extra describes additional or complementary items for items offered as products on MMK.

type GetPriceRequest added in v0.2.4

type GetPriceRequest struct {
	DateFrom     *MMKDateTime `url:"dateFrom,omitempty"`
	DateTo       *MMKDateTime `url:"dateTo,omitempty"`
	CompanyID    []int        `url:"companyId,omitempty"`
	CountryID    []int        `url:"countryId,omitempty"`
	ProductName  string       `url:"productName,omitempty"`
	YachtID      []int64      `url:"yachtId,omitempty"`
	Currency     string       `url:"currency,omitempty"`
	TripDuration int          `url:"tripDuration,omitempty"`
}

GetPriceRequest describes the request needed for requesting prices.

type Image added in v0.1.0

type Image struct {
	Description string   `json:"description,omitempty"`
	URL         *url.URL `json:"url,omitempty"`
	SortOrder   int64    `json:"sortOrder,omitempty"`
}

Image represents multimedia content for resources.

type Invoice added in v0.1.0

type Invoice struct {
	InvoiceType             int64      `json:"type,omitempty"`
	InvoiceCode             string     `json:"invoiceCode,omitempty"`
	ReservationNumber       string     `json:"reservationNumber,omitempty"`
	InvoiceDate             *time.Time `json:"invoiceDate,omitempty"`
	Client                  string     `json:"client,omitempty"`
	ClientCode              string     `json:"clientCode,omitempty"`
	ClientVATCode           string     `json:"clientVATCode,omitempty"`
	ClientID                int64      `json:"clientId,omitempty"`
	GuestName               string     `json:"guestName,omitempty"`
	Currency                string     `json:"currency,omitempty"`
	ExchangeRate            float64    `json:"exchangeRate,omitempty"`
	AltCurrency             string     `json:"altCurrency,omitempty"`
	AltExchangeRate         float64    `json:"altExchangeRate,omitempty"`
	Resource                string     `json:"resource,omitempty"`
	ResourceType            string     `json:"resourceType,omitempty"`
	ResourceCode            int64      `json:"resourceCode,omitempty"`
	TotalPrice              float64    `json:"totalPrice,omitempty"`
	TotalPriceWithoutTax    float64    `json:"totalPriceWithoutTax,omitempty"`
	Rate                    float64    `json:"rate,omitempty"`
	TotalAltPrice           float64    `json:"totalAltPrice,omitempty"`
	TotalAltPriceWithoutTax float64    `json:"totalAltPriceWithoutTax,omitempty"`
	BaseFrom                string     `json:"baseFrom,omitempty"`
	BaseTo                  string     `json:"baseTo,omitempty"`
	AlreadyTransferred      bool       `json:"alreadyTransferred,omitempty"`
	ServiceDateFrom         *time.Time `json:"serviceDateFrom,omitempty"`
	ServiceDateTo           *time.Time `json:"serviceDateTo,omitempty"`
	PaymentMethodName       string     `json:"paymentMethodName,omitempty"`
	PaymentMethodType       string     `json:"paymentMethodType,omitempty"`
	AgencyID                int64      `json:"agencyId,omitempty"`
	AgencyName              string     `json:"agencyName,omitempty"`
	AgencyCode              string     `json:"agencyCode,omitempty"`
	AgencyVATCode           string     `json:"agencyVatCode,omitempty"`
	RelatedReservationID    int64      `json:"relatedReservationID,omitempty"`
	ReservationID           int64      `json:"reservationId,omitempty"`
	RelatedInvoiceNumber    string     `json:"relatedInvoiceNumber,omitempty"`
	VAT                     VAT        `json:"vat,omitempty"`
	Services                []*Service `json:"services,omitempty"`
	BI                      []*Bi      `json:"bi,omitempty"`
}

type ItemTypeEnum

type ItemTypeEnum string

ItemTypeEnum is a type alias for supported items on mmk.

const (
	ModelItem       ItemTypeEnum = "model"
	ReservationItem ItemTypeEnum = "reservation"
	UserItem        ItemTypeEnum = "item"
	YatchItem       ItemTypeEnum = "yatch"
)

type Layout added in v0.1.0

type Layout struct {
	Name   string `json:"name,omitempty"`
	Amount int64  `json:"amount,omitempty"`
}

Layout of an offered product.

type MMKDateTime added in v0.1.2

type MMKDateTime struct {
	time.Time
}

MMKDateTime allows to perform (un)marshal operations with JSON on MMK's date time formatted response objects.

func (*MMKDateTime) MarshalJSON added in v0.1.2

func (d *MMKDateTime) MarshalJSON() ([]byte, error)

MarshalJSON overrides the default marshal action for the Time struct. Returns date as YYYY-MM-DD HH:ii:ss formatted string.

func (*MMKDateTime) UnmarshalJSON added in v0.1.2

func (d *MMKDateTime) UnmarshalJSON(b []byte) error

UnmarshalJSON overrides the default unmarshal action for the Time struct.

type Offer added in v0.1.0

type Offer struct {
	YachtId            int64        `json:"yachtId,omitempty"`
	StartBaseID        int64        `json:"startBaseId,omitempty"`
	EndBaseID          int64        `json:"endBaseId,omitempty"`
	StartPrice         float64      `json:"startPrice,omitempty"`
	Price              float64      `json:"price,omitempty"`
	DiscountPercentage float64      `json:"discountPercentage,omitempty"`
	Yacht              string       `json:"yacht,omitempty"`
	StartBase          string       `json:"startBase,omitempty"`
	EndBase            string       `json:"endBase,omitempty"`
	Product            string       `json:"product,omitempty"`
	Currency           string       `json:"currency,omitempty"`
	DateFrom           *MMKDateTime `json:"dateFrom,omitempty"`
	DateTo             *MMKDateTime `json:"dateTo,omitempty"`
}

Offer is a product, price and time frame proposal for a booking operation.

type OfferOptions added in v0.2.0

type OfferOptions struct {
	DateFrom string `url:"dateFrom"`
	DateTo   string `url:"dateTo"`
	YachtIds *[]int `url:"yachtId"`
}

OfferOptions are params that could be passed to the offer request

type OffersService added in v0.2.0

type OffersService service

func (*OffersService) GetOffers added in v0.2.0

func (os *OffersService) GetOffers(opts *OfferOptions) (or []*Offer, err error)

GetOffers returns offers based on passed parameters

type Price added in v0.1.0

type Price struct {
	YatchID            int64        `json:"yatchId,omitempty"`
	DateFrom           *MMKDateTime `json:"dateFrom,omitempty"`
	DateTo             *MMKDateTime `json:"dateTo,omitempty"`
	Product            string       `json:"product,omitempty"`
	Currency           string       `json:"currency,omitempty"`
	Price              float64      `json:"price,omitempty"`
	StartPrice         float64      `json:"startPrice,omitempty"`
	DiscountPercentage float64      `json:"discountPercentage,omitempty"`
}

Price describes the base price for an operation with MMK.

type PriceService added in v0.2.4

type PriceService service

PriceService operates over price requests.

func (*PriceService) GetPrice added in v0.2.4

func (ps *PriceService) GetPrice(pr *GetPriceRequest) (p *Price, err error)

GetPrice gets the price that a boat is in for.

type Product added in v0.1.0

type Product struct {
	Name   string   `json:"name,omitempty"`
	Extras []*Extra `json:"extras,omitempty"`
}

Product represents an offered item on MMK booking system.

type ProductEnum

type ProductEnum string

ProductEnum is a type alias for supported mmk products.

const (
	BareBoat ProductEnum = "bareboat"
	Crewed   ProductEnum = "crewed"
	Cabin    ProductEnum = "cabin"
	Flotilla ProductEnum = "flotilla"
	Power    ProductEnum = "power"
	Berth    ProductEnum = "breth"
	Regatta  ProductEnum = "regatta"
)

type Reservation added in v0.1.0

type Reservation struct {
	ID             *int64       `json:"ID,omitempty"`
	DateFrom       *MMKDateTime `json:"dateFrom,omitempty"`
	DateTo         *MMKDateTime `json:"dateTo,omitempty"`
	ExpirationDate *MMKDateTime `json:"ExpirationDate,omitempty"`
	YatchID        int64        `json:"yatchId,omitempty"`
	Status         int64        `json:"status,omitempty"`
	ProductName    string       `json:"productName,omitempty"`
	BaseFromID     int64        `json:"baseFromId,omitempty"`
	BaseToID       int64        `json:"baseToId,omitempty"`
	ClientName     string       `json:"clientName,omitempty"`
	ClientID       int64        `json:"clientId,omitempty"`
	Currency       string       `json:"currency,omitempty"`
}

Reservation represents a booking and its links to a yatch and client.

type ReservationList added in v0.2.4

type ReservationList struct {
	Reservations []*Reservation `json:"Reservations,omitempty"`
}

ReservationList describes the struct for a list of Reservation

type ReservationRequest added in v0.2.4

type ReservationRequest struct {
	Year *int   `json:"year,omitempty"`
	ID   *int64 `json:"ID,omitempty"`
}

ReservationRequest describes the request to query or update reservations

type ReservationService added in v0.2.4

type ReservationService service

ReservationService operates over reservation requests.

func (*ReservationService) CreateBooking added in v0.2.4

func (rsrv *ReservationService) CreateBooking(rr *ReservationRequest) (r *Reservation, err error)

CreateBooking sends a post request to create a booking reservation.

func (*ReservationService) CreateInfo added in v0.2.4

func (rsrv *ReservationService) CreateInfo() error

CreateInfo sends a request to create an info reservation.

func (*ReservationService) CreateOption added in v0.2.4

func (rsrv *ReservationService) CreateOption(rr *Reservation) (r *Reservation, err error)

CreateOption sends a request to create an option reservation.

func (*ReservationService) GetReservation added in v0.2.4

func (rsrv *ReservationService) GetReservation(rr *ReservationRequest) (rl *ReservationList, err error)

GetReservation gets a reservation using the reservation id.

type Response

type Response struct {
	*http.Response
	// contains filtered or unexported fields
}

Response represents an API response.

This wraps the standard http.Response returned from MMK and provides convenient access to things the decoded body.

type SailingArea added in v0.1.0

type SailingArea struct {
	ID   int64  `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

SailingArea describes a single sailing area in Booking Manager.

type Service added in v0.1.0

type Service struct {
	Nme   string  `json:"nme,omitempty"`
	Total float64 `json:"total,omitempty"`
	ID    int64   `json:"id,omitempty"`
	Rate  float64 `json:"rate,omitempty"`
	Code  string  `json:"code,omitempty"`
}

Service is an addition to any reservation that is not tangible.

type Shipyard added in v0.1.0

type Shipyard struct {
	ID        int64  `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
	ShortName string `json:"shortName,omitempty"`
}

Shipyard is a place where ships are built and repaired.

type ShortAvailabilityFormat

type ShortAvailabilityFormat int

ShortAvailabilityFormat supported by MMK.

const (
	Binary ShortAvailabilityFormat = iota + 1
	Hex
	Status
)

Supported short availability formats.

type ShortAvailabilityOptions

type ShortAvailabilityOptions struct {
	CompanyID int64                   `url:"companyId,omitempty"`
	YachtID   int64                   `url:"yachtId,omitempty"`
	Format    ShortAvailabilityFormat `url:"format,omitempty"`
}

ShortAvailabilityOptions available on MMK's API.

type ShortAvailabilityResponse

type ShortAvailabilityResponse struct {
	YatchID int64  `json:"y,omitempty"`
	BS      string `json:"bs,omitempty"`
}

ShortAvailabilityResponse descriptor.

type VAT

type VAT struct {
	Base     float64
	Rate     float64
	Total    float64
	BaseAlt  float64
	TotalAlt float64
}

VAT calculation values.

type ValidForBases added in v0.1.0

type ValidForBases struct {
	From int64 `json:"from,omitempty"`
	To   int64 `json:"to,omitempty"`
}

ValidForBases contains a range of bases where any given product or extra is valid as departure and destination.

type WorldRegion added in v0.1.0

type WorldRegion struct {
	ID   int64  `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

WorldRegion describes a single world region in Booking Manager.

type Yatch added in v0.1.0

type Yatch struct {
	ID                   int64      `json:"id,omitempty"`
	ModelID              int64      `json:"modelID,omitempty"`
	ShipyardID           int64      `json:"shipyardID,omitempty"`
	CompanyID            int64      `json:"companyID,omitempty"`
	WC                   int64      `json:"wc,omitempty"`
	Berths               int64      `json:"berths,omitempty"`
	Cabins               int64      `json:"cabins,omitempty"`
	DefaultCheckInDay    int64      `json:"defaultCheckInDay,omitempty"`
	EquipmentIDs         []int64    `json:"equipmentIDs,omitempty"`
	Draught              float64    `json:"draught,omitempty"`
	Beam                 float64    `json:"beam,omitempty"`
	Length               float64    `json:"length,omitempty"`
	WaterCapacity        float64    `json:"waterCapacity,omitempty"`
	FuelCapacity         float64    `json:"fuelCapacity,omitempty"`
	Deposit              float64    `json:"deposit,omitempty"`
	CommissionPercentage float64    `json:"commissionPercentage,omitempty"`
	MainsailArea         float64    `json:"mainsailArea,omitempty"`
	GenoaArea            float64    `json:"genoaArea,omitempty"`
	Name                 string     `json:"name,omitempty"`
	Model                string     `json:"model,omitempty"`
	Year                 string     `json:"year,omitempty"`
	Kind                 string     `json:"kind,omitempty"`
	HomeBase             string     `json:"homeBase,omitempty"`
	Company              string     `json:"company,omitempty"`
	Engine               string     `json:"engine,omitempty"`
	MainsailType         string     `json:"mainsailType,omitempty"`
	GenoaType            string     `json:"genoaType,omitempty"`
	Images               []*Image   `json:"images,omitempty"`
	Products             []*Product `json:"products,omitempty"`
	CabinLayout          []*Layout  `json:"cabinLayout,omitempty"`
	BerthsLayout         []*Layout  `json:"berthsLayout,omitempty"`
}

Yatch describes an offered YatchType product.

Jump to

Keyboard shortcuts

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