apiclient

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiRequest

type ApiRequest struct {
	Headers     map[string]string
	QueryParams map[string]string
	Url         string
	Method      string
	Body        interface{}
}

type Client

type Client struct {
	ApiUrl  string
	ApiKey  string
	PostUrl string
	Logger  *log.Logger
}

func NewClient

func NewClient(apikey string) Client

NewClient returns a Client instance with the `apikey` set. It is using the endpoints specified in the environment variables `OB_API_URL` and `OB_POST_URL`. If unspecified, the default endpoints are used.

func NewClientWithURL

func NewClientWithURL(apikey, apiURL, postURL string) Client

NewClient returns a Client instance with the `apikey` set and endpoints defined explicitly.

func (*Client) CountAccommodations

func (c *Client) CountAccommodations() (int, error)

CountAccommodations retrieves the total number of accommodations.

func (*Client) CountAccommodationsWithFilter

func (c *Client) CountAccommodationsWithFilter(filter map[string]string) (int, error)

CountAccommodationsWithFilter retrieves only the number of accommodations matching `filter` parameters.

func (*Client) CountReferences

func (c *Client) CountReferences() (int, error)

CountReferences retrieves a number of references for a group.

func (*Client) GetAccommodation

func (c *Client) GetAccommodation(accoid string) (obtypes.AccommodationReference, error)

GetAccommodation retrieves a single accommodation.

func (*Client) GetAccommodations

func (c *Client) GetAccommodations(queryParams map[string]string) ([]obtypes.AccommodationReference, error)

GetAccommodations queries for accommodation with search parameters. It only retrieves a single result set as specified with the `limit` and `skip` parameters.

func (*Client) GetAllAccommodations

func (c *Client) GetAllAccommodations(queryParams map[string]string) ([]obtypes.AccommodationReference, []error)

GetAllAccommodations queries for accommodation with search parameters. It automatically pages through the results until all accommodations are fetched.

func (*Client) GetAllPlaces

func (c *Client) GetAllPlaces() ([]obtypes.Place, error)

GetAllPlaces retrieves all places.

func (*Client) GetAllProviders

func (c *Client) GetAllProviders(engine *string) (obtypes.Providers, error)

GetAllProviders retrieves either all providers when `engine` is nil, or all providers for multiple group. A super key is necessary for this endpoint.

func (*Client) GetCitiFacts

func (c *Client) GetCitiFacts(provider string) ([]obtypes.CitiFact, error)

GetCitiFacts retrieves specific information of CITI references.

func (*Client) GetMinimalReferences

func (c *Client) GetMinimalReferences(queryParams map[string]string) ([]obtypes.MinimalReference, error)

GetMinimalReferences retrieves a minimal version of references matching `queryParams`. This is used by other importers to get external IDs etc.

func (*Client) GetProvider

func (c *Client) GetProvider(providerID string) (*obtypes.Provider, error)

GetProvider retrieves a single provider by ID.

func (*Client) GetProviders

func (c *Client) GetProviders(engine *string) (obtypes.Providers, error)

GetProviders retrieves either all providers when `engine` is nil, or all providers.

func (*Client) PostAcco

func (c *Client) PostAcco(acco obtypes.AccommodationReference) (string, error)

PostAcco posts a single reference.

func (*Client) PostAccoForGroup

func (c *Client) PostAccoForGroup(acco obtypes.AccommodationReference, group string) (string, error)

PostAccoForGroup allows posting with a super key for any group.

func (*Client) PostBooking

func (c *Client) PostBooking(b obtypes.Booking) (string, error)

PostBooking posts a single booking instance.

func (*Client) PostOccupanciesConcurrently

func (c *Client) PostOccupanciesConcurrently(jobconfig JobConfig, occupancies []obtypes.PostableOccupancies) []error

PostOccupanciesConcurrently is like `PutOccupancy` but processes multiple calendars concurrently.

func (*Client) PostOccupancy

func (c *Client) PostOccupancy(occupancy obtypes.PostableOccupanciesExternal) (string, error)

PostOccupancy posts an availability calendar for a reference, but by specifying the `provider_id` and `external_id`.

func (*Client) PostProviderFeatures

func (c *Client) PostProviderFeatures(providerID string, payload PostProviderFeaturesPayload) error

PostProviderFeatures posts provider features for a single provider.

func (*Client) PostProviderFeaturesForGroup

func (c *Client) PostProviderFeaturesForGroup(group, providerID string, payload PostProviderFeaturesPayload) error

PostProviderFeaturesForGroup is like PostProviderFeatures but allows to post for any group. A super key is necessary for this endpoint.

func (*Client) PutOccupancy

func (c *Client) PutOccupancy(occupancy obtypes.PostableOccupancies) (string, error)

PutOccupancy posts an availability calendar for a reference using the reference ID.

type Job

type Job struct {
	Acco   obtypes.AccommodationReference
	Client *Client
	// contains filtered or unexported fields
}

type JobAllAccos

type JobAllAccos struct {
	Skip        int
	Limit       int
	QueryParams map[string]string
	Client      *Client
	// contains filtered or unexported fields
}

type JobConfig

type JobConfig struct {
	ApiKey string
	Worker int
}

type JobConfigOccupancy

type JobConfigOccupancy struct {
	ApiKey string
	Worker int
}

type JobOccupancy

type JobOccupancy struct {
	Occupancy obtypes.PostableOccupancies
	Client    *Client
	// contains filtered or unexported fields
}

type JobResult

type JobResult struct {
	Jobid    int
	Error    error
	Response string
	Request  RequestResult
}

type JobResultAllAccos

type JobResultAllAccos struct {
	Jobid int
	Error error
	Accos []obtypes.AccommodationReference
}

type JobResultOccupancy

type JobResultOccupancy struct {
	Jobid    int
	Error    error
	Response string
	Request  RequestResult
}

type PostProviderFeaturesPayload

type PostProviderFeaturesPayload []ProviderFeature

func (*PostProviderFeaturesPayload) AddDistinct

func (s *PostProviderFeaturesPayload) AddDistinct(pf ProviderFeature)

AddDistinct adds the feature only if it doesn't already exist

func (*PostProviderFeaturesPayload) HasKey

func (s *PostProviderFeaturesPayload) HasKey(key string) bool

func (*PostProviderFeaturesPayload) UpdateTranslation

func (s *PostProviderFeaturesPayload) UpdateTranslation(id, lang, value string)

UpdateTranslation updates the translation of a feature if it exists otherwise discarded

type ProviderFeature

type ProviderFeature struct {
	ID           string          `json:"id"`
	Translations obtypes.TextMap `json:"translations"`
	Category     string          `json:"category"`
	Comment      string          `json:"comment"`
	Icon         string          `json:"icon"`
}

type RequestResult

type RequestResult struct {
	RequestUrl  string
	Requesttime int
	Statuscode  int
	RequestBody string
	Error       error
}

type RequestResultOccupancy

type RequestResultOccupancy struct {
	RequestUrl  string
	Requesttime int
	Statuscode  int
	RequestBody string
	Error       error
}

Jump to

Keyboard shortcuts

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