Documentation
¶
Overview ¶
Package hostex provides a Go client library for the Hostex API v3.0.0
Index ¶
- Constants
- type APIResponse
- type AvailabilitiesResponse
- type Availability
- type Channel
- type Client
- func (c *Client) CancelReservation(ctx context.Context, reservationCode string) error
- func (c *Client) CreateReservation(ctx context.Context, data CreateReservationData) (*CreateReservationResponse, error)
- func (c *Client) CreateReview(ctx context.Context, reservationCode string, data CreateReviewData) error
- func (c *Client) CreateWebhook(ctx context.Context, webhookURL string) (*CreateWebhookResponse, error)
- func (c *Client) DeleteWebhook(ctx context.Context, webhookID int) error
- func (c *Client) GetConversation(ctx context.Context, conversationID string) (*ConversationDetails, error)
- func (c *Client) GetCustomFields(ctx context.Context, stayCode string) (*CustomFieldsResponse, error)
- func (c *Client) GetListingCalendar(ctx context.Context, data GetListingCalendarData) (*ListingCalendarResponse, error)
- func (c *Client) ListAvailabilities(ctx context.Context, params ListAvailabilitiesParams) (*AvailabilitiesResponse, error)
- func (c *Client) ListConversations(ctx context.Context, params *ListConversationsParams) (*ConversationsResponse, error)
- func (c *Client) ListCustomChannels(ctx context.Context) (*CustomChannelsResponse, error)
- func (c *Client) ListIncomeMethods(ctx context.Context) (*IncomeMethodsResponse, error)
- func (c *Client) ListProperties(ctx context.Context, params *ListPropertiesParams) (*PropertiesResponse, error)
- func (c *Client) ListReservations(ctx context.Context, params *ListReservationsParams) (*ReservationsResponse, error)
- func (c *Client) ListReviews(ctx context.Context, params *ListReviewsParams) (*ReviewsResponse, error)
- func (c *Client) ListRoomTypes(ctx context.Context, params *ListRoomTypesParams) (*RoomTypesResponse, error)
- func (c *Client) ListWebhooks(ctx context.Context) (*WebhooksResponse, error)
- func (c *Client) SendMessage(ctx context.Context, conversationID string, data SendMessageData) error
- func (c *Client) UpdateAvailabilities(ctx context.Context, data UpdateAvailabilitiesData) error
- func (c *Client) UpdateCustomFields(ctx context.Context, stayCode string, customFields map[string]interface{}) error
- func (c *Client) UpdateListingInventories(ctx context.Context, data UpdateListingInventoriesData) error
- func (c *Client) UpdateListingPrices(ctx context.Context, data UpdateListingPricesData) error
- func (c *Client) UpdateListingRestrictions(ctx context.Context, data UpdateListingRestrictionsData) error
- func (c *Client) UpdateLockCode(ctx context.Context, stayCode, lockCode string) error
- type Config
- type Conversation
- type ConversationDetails
- type ConversationsResponse
- type CreateReservationData
- type CreateReservationResponse
- type CreateReviewData
- type CreateWebhookResponse
- type CustomChannel
- type CustomChannelsResponse
- type CustomFieldsResponse
- type GetListingCalendarData
- type Guest
- type IncomeMethod
- type IncomeMethodsResponse
- type Inventory
- type ListAvailabilitiesParams
- type ListConversationsParams
- type ListPropertiesParams
- type ListReservationsParams
- type ListReviewsParams
- type ListRoomTypesParams
- type Listing
- type ListingCalendarResponse
- type Message
- type Price
- type PropertiesResponse
- type Property
- type ReplyData
- type Reservation
- type ReservationsResponse
- type Restriction
- type Review
- type ReviewData
- type ReviewsResponse
- type RoomType
- type RoomTypesResponse
- type SendMessageData
- type UpdateAvailabilitiesData
- type UpdateListingInventoriesData
- type UpdateListingPricesData
- type UpdateListingRestrictionsData
- type Webhook
- type WebhooksResponse
Constants ¶
const ( // DefaultBaseURL is the default Hostex API base URL DefaultBaseURL = "https://api.hostex.io/v3" // DefaultTimeout is the default HTTP client timeout DefaultTimeout = 30 * time.Second // UserAgent is the user agent string sent with requests UserAgent = "hostex-go/1.0.0" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
type APIResponse struct {
RequestID string `json:"request_id"`
ErrorCode int `json:"error_code"`
ErrorMsg string `json:"error_msg"`
Data interface{} `json:"data,omitempty"`
}
APIResponse represents a standard Hostex API response
type AvailabilitiesResponse ¶
type AvailabilitiesResponse struct {
Listings []struct {
ID int `json:"id"`
ChannelType string `json:"channel_type"`
ListingID string `json:"listing_id"`
Availabilities []Availability `json:"availabilities,omitempty"`
} `json:"listings"`
}
AvailabilitiesResponse represents the response from listing availabilities
type Availability ¶
Availability represents property availability
type Channel ¶
type Channel struct {
ChannelType string `json:"channel_type"`
ListingID string `json:"listing_id"`
}
Channel represents a booking channel for a property
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Hostex API client
func (*Client) CancelReservation ¶
CancelReservation cancels a direct booking reservation
func (*Client) CreateReservation ¶
func (c *Client) CreateReservation(ctx context.Context, data CreateReservationData) (*CreateReservationResponse, error)
CreateReservation creates a new direct booking reservation
func (*Client) CreateReview ¶
func (c *Client) CreateReview(ctx context.Context, reservationCode string, data CreateReviewData) error
CreateReview creates a review or reply for a reservation
func (*Client) CreateWebhook ¶
func (c *Client) CreateWebhook(ctx context.Context, webhookURL string) (*CreateWebhookResponse, error)
CreateWebhook creates a new webhook
func (*Client) DeleteWebhook ¶
DeleteWebhook deletes a webhook by ID
func (*Client) GetConversation ¶
func (c *Client) GetConversation(ctx context.Context, conversationID string) (*ConversationDetails, error)
GetConversation retrieves detailed information about a specific conversation
func (*Client) GetCustomFields ¶
func (c *Client) GetCustomFields(ctx context.Context, stayCode string) (*CustomFieldsResponse, error)
GetCustomFields retrieves custom fields for a stay
func (*Client) GetListingCalendar ¶
func (c *Client) GetListingCalendar(ctx context.Context, data GetListingCalendarData) (*ListingCalendarResponse, error)
GetListingCalendar retrieves calendar information for multiple listings
func (*Client) ListAvailabilities ¶
func (c *Client) ListAvailabilities(ctx context.Context, params ListAvailabilitiesParams) (*AvailabilitiesResponse, error)
ListAvailabilities retrieves availability information for properties
func (*Client) ListConversations ¶
func (c *Client) ListConversations(ctx context.Context, params *ListConversationsParams) (*ConversationsResponse, error)
ListConversations retrieves a list of conversations
func (*Client) ListCustomChannels ¶
func (c *Client) ListCustomChannels(ctx context.Context) (*CustomChannelsResponse, error)
ListCustomChannels retrieves custom channels from Custom Options Page
func (*Client) ListIncomeMethods ¶
func (c *Client) ListIncomeMethods(ctx context.Context) (*IncomeMethodsResponse, error)
ListIncomeMethods retrieves income methods from Custom Options Page
func (*Client) ListProperties ¶
func (c *Client) ListProperties(ctx context.Context, params *ListPropertiesParams) (*PropertiesResponse, error)
ListProperties retrieves a list of properties
func (*Client) ListReservations ¶
func (c *Client) ListReservations(ctx context.Context, params *ListReservationsParams) (*ReservationsResponse, error)
ListReservations retrieves a list of reservations
func (*Client) ListReviews ¶
func (c *Client) ListReviews(ctx context.Context, params *ListReviewsParams) (*ReviewsResponse, error)
ListReviews retrieves a list of reviews
func (*Client) ListRoomTypes ¶
func (c *Client) ListRoomTypes(ctx context.Context, params *ListRoomTypesParams) (*RoomTypesResponse, error)
ListRoomTypes retrieves a list of room types
func (*Client) ListWebhooks ¶
func (c *Client) ListWebhooks(ctx context.Context) (*WebhooksResponse, error)
ListWebhooks retrieves a list of configured webhooks
func (*Client) SendMessage ¶
func (c *Client) SendMessage(ctx context.Context, conversationID string, data SendMessageData) error
SendMessage sends a message to a conversation
func (*Client) UpdateAvailabilities ¶
func (c *Client) UpdateAvailabilities(ctx context.Context, data UpdateAvailabilitiesData) error
UpdateAvailabilities updates property availability status
func (*Client) UpdateCustomFields ¶
func (c *Client) UpdateCustomFields(ctx context.Context, stayCode string, customFields map[string]interface{}) error
UpdateCustomFields updates custom fields for a stay
func (*Client) UpdateListingInventories ¶
func (c *Client) UpdateListingInventories(ctx context.Context, data UpdateListingInventoriesData) error
UpdateListingInventories updates inventory levels for channel listings
func (*Client) UpdateListingPrices ¶
func (c *Client) UpdateListingPrices(ctx context.Context, data UpdateListingPricesData) error
UpdateListingPrices updates listing prices for channel listings
func (*Client) UpdateListingRestrictions ¶
func (c *Client) UpdateListingRestrictions(ctx context.Context, data UpdateListingRestrictionsData) error
UpdateListingRestrictions updates listing restrictions for channel listings
type Config ¶
type Config struct {
// AccessToken is your Hostex API access token (required)
AccessToken string
// BaseURL is the Hostex API base URL (optional, defaults to DefaultBaseURL)
BaseURL string
// HTTPClient is a custom HTTP client (optional)
HTTPClient *http.Client
// Timeout is the HTTP request timeout (optional, defaults to DefaultTimeout)
Timeout time.Duration
}
Config holds client configuration options
type Conversation ¶
type Conversation struct {
ID string `json:"id"`
ChannelType string `json:"channel_type"`
Guest Guest `json:"guest"`
PropertyID int `json:"property_id,omitempty"`
PropertyTitle string `json:"property_title,omitempty"`
CheckInDate string `json:"check_in_date,omitempty"`
CheckOutDate string `json:"check_out_date,omitempty"`
LastMessageAt time.Time `json:"last_message_at,omitempty"`
UnreadCount int `json:"unread_count,omitempty"`
}
Conversation represents a guest conversation
type ConversationDetails ¶
type ConversationDetails struct {
Guest Guest `json:"guest"`
ChannelType string `json:"channel_type"`
Messages []Message `json:"messages"`
}
ConversationDetails represents detailed conversation information
type ConversationsResponse ¶
type ConversationsResponse struct {
Conversations []Conversation `json:"conversations"`
Total int `json:"total"`
}
ConversationsResponse represents the response from listing conversations
type CreateReservationData ¶
type CreateReservationData struct {
PropertyID string `json:"property_id"`
CustomChannelID int `json:"custom_channel_id"`
CheckInDate string `json:"check_in_date"`
CheckOutDate string `json:"check_out_date"`
GuestName string `json:"guest_name"`
Currency string `json:"currency"`
RateAmount int `json:"rate_amount"`
CommissionAmount int `json:"commission_amount"`
ReceivedAmount int `json:"received_amount"`
IncomeMethodID int `json:"income_method_id"`
NumberOfGuests int `json:"number_of_guests,omitempty"`
Email string `json:"email,omitempty"`
Mobile string `json:"mobile,omitempty"`
Remarks string `json:"remarks,omitempty"`
}
CreateReservationData contains data for creating a new reservation
type CreateReservationResponse ¶
type CreateReservationResponse struct {
Reservation Reservation `json:"reservation"`
}
CreateReservationResponse represents the response from creating a reservation
type CreateReviewData ¶
type CreateReviewData struct {
HostReviewScore int `json:"host_review_score,omitempty"`
HostReviewContent string `json:"host_review_content,omitempty"`
HostReplyContent string `json:"host_reply_content,omitempty"`
}
CreateReviewData contains data for creating a review
type CreateWebhookResponse ¶
type CreateWebhookResponse struct {
Webhook Webhook `json:"webhook"`
}
CreateWebhookResponse represents the response from creating a webhook
type CustomChannel ¶
CustomChannel represents a custom booking channel
type CustomChannelsResponse ¶
type CustomChannelsResponse struct {
CustomChannels []CustomChannel `json:"custom_channels"`
}
CustomChannelsResponse represents the response from listing custom channels
type CustomFieldsResponse ¶
type CustomFieldsResponse struct {
CustomFields map[string]interface{} `json:"custom_fields"`
}
CustomFieldsResponse represents the response from getting custom fields
type GetListingCalendarData ¶
type GetListingCalendarData struct {
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
Listings []Listing `json:"listings"`
}
ListingCalendarData contains data for getting listing calendar
type Guest ¶
type Guest struct {
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
Mobile string `json:"mobile,omitempty"`
}
Guest represents a guest
type IncomeMethod ¶
IncomeMethod represents a payment method
type IncomeMethodsResponse ¶
type IncomeMethodsResponse struct {
IncomeMethods []IncomeMethod `json:"income_methods"`
}
IncomeMethodsResponse represents the response from listing income methods
type ListAvailabilitiesParams ¶
type ListAvailabilitiesParams struct {
PropertyIDs string // Comma-separated property IDs
StartDate string // YYYY-MM-DD
EndDate string // YYYY-MM-DD
}
ListAvailabilitiesParams contains required parameters for listing availabilities
type ListConversationsParams ¶
ListConversationsParams contains optional parameters for listing conversations
type ListPropertiesParams ¶
ListPropertiesParams contains optional parameters for listing properties
type ListReservationsParams ¶
type ListReservationsParams struct {
ReservationCode string
PropertyID int
Status string
StartCheckInDate string
EndCheckInDate string
StartCheckOutDate string
EndCheckOutDate string
OrderBy string
Offset int
Limit int
}
ListReservationsParams contains optional parameters for listing reservations
type ListReviewsParams ¶
type ListReviewsParams struct {
ReservationCode string
PropertyID int
ReviewStatus string
StartCheckOutDate string
EndCheckOutDate string
Offset int
Limit int
}
ListReviewsParams contains optional parameters for listing reviews
type ListRoomTypesParams ¶
ListRoomTypesParams contains optional parameters for listing room types
type Listing ¶
type Listing struct {
ChannelType string `json:"channel_type"`
ListingID string `json:"listing_id"`
}
Listing represents a listing on a channel
type ListingCalendarResponse ¶
type ListingCalendarResponse struct {
Listings []struct {
ChannelType string `json:"channel_type"`
ListingID string `json:"listing_id"`
Calendar []struct {
Date string `json:"date"`
Price int `json:"price,omitempty"`
Inventory int `json:"inventory,omitempty"`
Available bool `json:"available,omitempty"`
MinStay int `json:"min_stay,omitempty"`
MaxStay int `json:"max_stay,omitempty"`
ClosedToArrival bool `json:"closed_to_arrival,omitempty"`
ClosedToDeparture bool `json:"closed_to_departure,omitempty"`
} `json:"calendar"`
} `json:"listings"`
}
ListingCalendarResponse represents the response from getting listing calendar
type Message ¶
type Message struct {
ID string `json:"id"`
SenderRole string `json:"sender_role"` // "host" or "guest"
Content string `json:"content"`
CreatedAt time.Time `json:"created_at"`
ImageURL string `json:"image_url,omitempty"`
}
Message represents a conversation message
type PropertiesResponse ¶
type PropertiesResponse struct {
Properties []Property `json:"properties"`
Total int `json:"total"`
}
PropertiesResponse represents the response from listing properties
type Property ¶
type Property struct {
ID int `json:"id"`
Title string `json:"title"`
Address string `json:"address,omitempty"`
Longitude float64 `json:"longitude,omitempty"`
Latitude float64 `json:"latitude,omitempty"`
Channels []Channel `json:"channels,omitempty"`
}
Property represents a Hostex property
type ReplyData ¶
type ReplyData struct {
Content string `json:"content,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
}
ReplyData contains reply details
type Reservation ¶
type Reservation struct {
ReservationCode string `json:"reservation_code"`
StayCode string `json:"stay_code"`
ChannelID string `json:"channel_id,omitempty"`
PropertyID int `json:"property_id"`
ChannelType string `json:"channel_type"`
ListingID string `json:"listing_id,omitempty"`
CheckInDate string `json:"check_in_date"`
CheckOutDate string `json:"check_out_date"`
NumberOfGuests int `json:"number_of_guests,omitempty"`
NumberOfAdults int `json:"number_of_adults,omitempty"`
NumberOfChildren int `json:"number_of_children,omitempty"`
NumberOfInfants int `json:"number_of_infants,omitempty"`
NumberOfPets int `json:"number_of_pets,omitempty"`
Status string `json:"status"`
GuestName string `json:"guest_name,omitempty"`
GuestPhone string `json:"guest_phone,omitempty"`
GuestEmail string `json:"guest_email,omitempty"`
CancelledAt *time.Time `json:"cancelled_at,omitempty"`
BookedAt *time.Time `json:"booked_at,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
Creator string `json:"creator,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
Tags []string `json:"tags,omitempty"`
CustomFields any `json:"custom_fields,omitempty"`
InReservationBox bool `json:"in_reservation_box,omitempty"`
}
Reservation represents a booking reservation
type ReservationsResponse ¶
type ReservationsResponse struct {
Reservations []Reservation `json:"reservations"`
Total int `json:"total"`
}
ReservationsResponse represents the response from listing reservations
type Restriction ¶
type Restriction struct {
Date string `json:"date"`
MinStay int `json:"min_stay,omitempty"`
MaxStay int `json:"max_stay,omitempty"`
ClosedToArrival bool `json:"closed_to_arrival,omitempty"`
ClosedToDeparture bool `json:"closed_to_departure,omitempty"`
}
Restriction represents restrictions for a specific date
type Review ¶
type Review struct {
ReservationCode string `json:"reservation_code"`
PropertyID int `json:"property_id"`
ChannelType string `json:"channel_type"`
CheckOutDate string `json:"check_out_date"`
ReviewStatus string `json:"review_status"`
HostReview *ReviewData `json:"host_review,omitempty"`
GuestReview *ReviewData `json:"guest_review,omitempty"`
HostReply *ReplyData `json:"host_reply,omitempty"`
}
Review represents a guest or host review
type ReviewData ¶
type ReviewData struct {
Score int `json:"score,omitempty"`
Content string `json:"content,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
}
ReviewData contains review details
type ReviewsResponse ¶
ReviewsResponse represents the response from listing reviews
type RoomType ¶
type RoomType struct {
ID int `json:"id"`
Title string `json:"title"`
Properties []Property `json:"properties,omitempty"`
Channels []Channel `json:"channels,omitempty"`
}
RoomType represents a room type in Hostex
type RoomTypesResponse ¶
RoomTypesResponse represents the response from listing room types
type SendMessageData ¶
type SendMessageData struct {
Message string `json:"message,omitempty"`
JpegBase64 string `json:"jpeg_base64,omitempty"`
}
SendMessageData contains data for sending a message
type UpdateAvailabilitiesData ¶
type UpdateAvailabilitiesData struct {
PropertyIDs []int `json:"property_ids"`
StartDate string `json:"start_date,omitempty"`
EndDate string `json:"end_date,omitempty"`
Dates []string `json:"dates,omitempty"`
Available bool `json:"available"`
}
UpdateAvailabilitiesData contains data for updating availability
type UpdateListingInventoriesData ¶
type UpdateListingInventoriesData struct {
ChannelType string `json:"channel_type"`
ListingID string `json:"listing_id"`
Inventories []Inventory `json:"inventories"`
}
UpdateListingInventoriesData contains data for updating listing inventories
type UpdateListingPricesData ¶
type UpdateListingPricesData struct {
ChannelType string `json:"channel_type"`
ListingID string `json:"listing_id"`
Prices []Price `json:"prices"`
}
UpdateListingPricesData contains data for updating listing prices
type UpdateListingRestrictionsData ¶
type UpdateListingRestrictionsData struct {
ChannelType string `json:"channel_type"`
ListingID string `json:"listing_id"`
Restrictions []Restriction `json:"restrictions"`
}
UpdateListingRestrictionsData contains data for updating listing restrictions
type Webhook ¶
type Webhook struct {
ID int `json:"id"`
URL string `json:"url"`
Manageable bool `json:"manageable"`
CreatedAt time.Time `json:"created_at"`
}
Webhook represents a webhook configuration
type WebhooksResponse ¶
type WebhooksResponse struct {
Webhooks []Webhook `json:"webhooks"`
}
WebhooksResponse represents the response from listing webhooks