Documentation
¶
Index ¶
- Constants
- Variables
- func InList[T comparable](val T, list []T) bool
- func SetDefaultContentEncoding(contentEncoding *string)
- func SetDefaultDomain(domain *oxylabs.Domain)
- func SetDefaultHotelOccupancy(ctx oxylabs.ContextOption)
- func SetDefaultHttpMethod(ctx oxylabs.ContextOption)
- func SetDefaultLimit(limit *int, defaultLimit int)
- func SetDefaultPages(pages *int)
- func SetDefaultSortBy(ctx oxylabs.ContextOption)
- func SetDefaultStartPage(startPage *int)
- func SetDefaultUserAgent(userAgent *oxylabs.UserAgent)
- func ValidateUrl(inputUrl string, host string) error
- type ApiCredentials
- type Client
- func (c *Client) GetHttpResp(jobID string, httpChan chan *http.Response, errChan chan error)
- func (c *Client) GetJobID(jsonPayload []byte) (string, error)
- func (c *Client) PollJobStatus(ctx context.Context, jobID string, pollInterval time.Duration, ...)
- func (c *Client) Req(ctx context.Context, jsonPayload []byte, method string) (*http.Response, error)
- type Job
Constants ¶
const ( DefaultUserAgent oxylabs.UserAgent = oxylabs.UA_DESKTOP DefaultDomain oxylabs.Domain = oxylabs.DOMAIN_COM DefaultStartPage int = 1 DefaultPages int = 1 DefaultLimit_SERP int = 10 DefaultLimit_ECOMMERCE int = 48 SyncBaseUrl string = "https://realtime.oxylabs.io/v1/queries" AsyncBaseUrl string = "https://data.oxylabs.io/v1/queries" )
Variables ¶
var ( DefaultTimeout = 50 * time.Second DefaultPollInterval = 2 * time.Second )
Functions ¶
func InList ¶
func InList[T comparable](val T, list []T) bool
InList checks if a value is present in the given slice.
func SetDefaultContentEncoding ¶
func SetDefaultContentEncoding(contentEncoding *string)
SetDefaultContentEncoding sets the content_encoding parameter if it is not set.
func SetDefaultDomain ¶
SetDefaultDomain sets the domain parameter if it is not set.
func SetDefaultHotelOccupancy ¶
func SetDefaultHotelOccupancy(ctx oxylabs.ContextOption)
SetDefaultHotelOccupancy sets the hotel_occupancy parameter if it is not set.
func SetDefaultHttpMethod ¶
func SetDefaultHttpMethod(ctx oxylabs.ContextOption)
SetDefaultHttpMethod sets the http_method parameter in the ctx if it is not set.
func SetDefaultLimit ¶
SetDefaultLimit sets the limit parameter if it is not set.
func SetDefaultPages ¶
func SetDefaultPages(pages *int)
SetDefaultPages sets the pages parameter if it is not set.
func SetDefaultSortBy ¶
func SetDefaultSortBy(ctx oxylabs.ContextOption)
SetDefaultSortBy sets the sort_by parameter in the ctx if it is not set.
func SetDefaultStartPage ¶
func SetDefaultStartPage(startPage *int)
SetDefaultStartPage sets the start_page parameter if it is not set.
func SetDefaultUserAgent ¶
SetDefaultUserAgent sets the user_agent_type parameter if it is not set.
func ValidateUrl ¶
ValidateUrl validates non-empty URL's scheme, host, and matches expected domain or host.
Types ¶
type ApiCredentials ¶
type Client ¶
type Client struct { BaseUrl string ApiCredentials *ApiCredentials HttpClient *http.Client }
func (*Client) GetHttpResp ¶
Helper function for getting the http response from the request.
func (*Client) PollJobStatus ¶
func (c *Client) PollJobStatus( ctx context.Context, jobID string, pollInterval time.Duration, httpRespChan chan *http.Response, errChan chan error, )
PollJobStatus polls the job status and manages the resp/error channels. ctx is the context of the req. jsonPayload is the payload for the req. pollInterval is the time to wait between each subsequent polling req. httpRespChan and errChan are the channels for the http resp and error respectively.