Documentation
¶
Overview ¶
Package gohighlevel provides a Go SDK for the GoHighLevel API with OAuth 2.0 authentication.
Index ¶
- Constants
- type AttributionSource
- type Client
- func (c *Client) AuthorizeWithCode(code, redirectURI string) error
- func (c *Client) AuthorizeWithRefreshToken(refreshToken string) error
- func (c *Client) GetAccessToken() string
- func (c *Client) GetLocationID() string
- func (c *Client) GetRefreshToken() string
- func (c *Client) SetAccessToken(token string)
- func (c *Client) SetLocationID(locationID string)
- func (c *Client) SetTokens(accessToken, refreshToken string, expiresIn int)
- type Config
- type Contact
- type ContactResponse
- type ContactsResponse
- type ContactsService
- func (s *ContactsService) AddTags(contactID string, tags []string) error
- func (s *ContactsService) Create(req *CreateContactRequest) (*Contact, error)
- func (s *ContactsService) Delete(contactID string) error
- func (s *ContactsService) Get(contactID string) (*Contact, error)
- func (s *ContactsService) GetByBusinessID(businessID string) (*ContactsResponse, error)
- func (s *ContactsService) List(opts *GetContactsOptions) (*ContactsResponse, error)
- func (s *ContactsService) RemoveTags(contactID string, tags []string) error
- func (s *ContactsService) Update(contactID string, req *UpdateContactRequest) (*Contact, error)
- func (s *ContactsService) Upsert(req *UpsertContactRequest) (*Contact, error)
- type CreateContactRequest
- type CustomField
- type DNDSetting
- type DNDSettings
- type GetContactsOptions
- type TokenRefreshCallback
- type TokenResponse
- type UpdateContactRequest
- type UpsertContactRequest
Constants ¶
const ( // DefaultBaseURL is the default base URL for the GoHighLevel API DefaultBaseURL = "https://services.leadconnectorhq.com" // OAuthTokenURL is the OAuth token endpoint OAuthTokenURL = "https://services.leadconnectorhq.com/oauth/token" // DefaultTimeout is the default HTTP client timeout DefaultTimeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttributionSource ¶
type AttributionSource struct {
Campaign string `json:"campaign,omitempty"`
CampaignID string `json:"campaignId,omitempty"`
Medium string `json:"medium,omitempty"`
MediumID string `json:"mediumId,omitempty"`
Source string `json:"source,omitempty"`
Referrer string `json:"referrer,omitempty"`
AdGroup string `json:"adGroup,omitempty"`
AdGroupID string `json:"adGroupId,omitempty"`
FBCLId string `json:"fbclid,omitempty"`
GCLId string `json:"gclid,omitempty"`
MSCLKId string `json:"msclkid,omitempty"`
DCLID string `json:"dclid,omitempty"`
FBC string `json:"fbc,omitempty"`
FBP string `json:"fbp,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
GAPClientID string `json:"gapClientId,omitempty"`
GoogleAnalyticsID string `json:"googleAnalyticsId,omitempty"`
}
AttributionSource represents the attribution source for a contact
type Client ¶
type Client struct {
// BaseURL is the base URL for API requests
BaseURL string
// HTTPClient is the underlying HTTP client used for requests
HTTPClient *http.Client
// Resources
Contacts *ContactsService
// contains filtered or unexported fields
}
Client is the main GoHighLevel API client
func NewClient ¶
NewClient creates a new GoHighLevel API client. ClientID and ClientSecret are optional - only required for OAuth flows and token refresh. If you only need to make API calls with an existing access token, you can omit them.
func (*Client) AuthorizeWithCode ¶
AuthorizeWithCode exchanges an authorization code for an access token. Requires ClientID and ClientSecret to be set in the client config.
func (*Client) AuthorizeWithRefreshToken ¶
AuthorizeWithRefreshToken refreshes the access token using a refresh token. Requires ClientID and ClientSecret to be set in the client config.
func (*Client) GetAccessToken ¶
GetAccessToken returns the current access token
func (*Client) GetLocationID ¶
GetLocationID returns the current default location ID
func (*Client) GetRefreshToken ¶
GetRefreshToken returns the current refresh token
func (*Client) SetAccessToken ¶
SetAccessToken manually sets the access token
func (*Client) SetLocationID ¶
SetLocationID sets the default location ID for API requests
type Config ¶
type Config struct {
ClientID string
ClientSecret string
AccessToken string
RefreshToken string
LocationID string
BaseURL string
HTTPClient *http.Client
OnTokenRefresh TokenRefreshCallback // Called when tokens are automatically refreshed on 401
AutoRefreshOn401 bool // Enable automatic token refresh on 401 errors (default: false)
}
Config holds configuration for the GoHighLevel client
type Contact ¶
type Contact struct {
ID string `json:"id,omitempty"`
LocationID string `json:"locationId,omitempty"`
ContactName string `json:"contactName,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
Type string `json:"type,omitempty"`
Source string `json:"source,omitempty"`
AssignedTo string `json:"assignedTo,omitempty"`
Address1 string `json:"address1,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
Country string `json:"country,omitempty"`
PostalCode string `json:"postalCode,omitempty"`
CompanyName string `json:"companyName,omitempty"`
Website string `json:"website,omitempty"`
Tags []string `json:"tags,omitempty"`
DateOfBirth string `json:"dateOfBirth,omitempty"`
DateAdded time.Time `json:"dateAdded,omitempty"`
DateUpdated time.Time `json:"dateUpdated,omitempty"`
CustomFields []CustomField `json:"customField,omitempty"`
BusinessID string `json:"businessId,omitempty"`
AttributionSource *AttributionSource `json:"attributionSource,omitempty"`
AdditionalEmails []string `json:"additionalEmails,omitempty"`
AdditionalPhones []string `json:"additionalPhones,omitempty"`
SSN string `json:"ssn,omitempty"`
Gender string `json:"gender,omitempty"`
Timezone string `json:"timezone,omitempty"`
DND bool `json:"dnd,omitempty"`
DNDSettings *DNDSettings `json:"dndSettings,omitempty"`
InboundDNDSettings *DNDSettings `json:"inboundDndSettings,omitempty"`
ConversationID string `json:"conversationId,omitempty"`
ConversationProvider string `json:"conversationProvider,omitempty"`
ConversationAgencyID string `json:"conversationAgencyId,omitempty"`
Followers []string `json:"followers,omitempty"`
}
Contact represents a GoHighLevel contact
type ContactResponse ¶
type ContactResponse struct {
Contact *Contact `json:"contact,omitempty"`
}
ContactResponse represents a single contact API response
type ContactsResponse ¶
type ContactsResponse struct {
Contacts []Contact `json:"contacts,omitempty"`
Total int `json:"total,omitempty"`
Count int `json:"count,omitempty"`
}
ContactsResponse represents a list of contacts API response
type ContactsService ¶
type ContactsService struct {
// contains filtered or unexported fields
}
ContactsService handles operations related to contacts
func (*ContactsService) AddTags ¶
func (s *ContactsService) AddTags(contactID string, tags []string) error
AddTags adds tags to a contact Required scope: contacts.write
func (*ContactsService) Create ¶
func (s *ContactsService) Create(req *CreateContactRequest) (*Contact, error)
Create creates a new contact Required scope: contacts.write
func (*ContactsService) Delete ¶
func (s *ContactsService) Delete(contactID string) error
Delete deletes a contact Required scope: contacts.write
func (*ContactsService) Get ¶
func (s *ContactsService) Get(contactID string) (*Contact, error)
Get retrieves a contact by ID Required scope: contacts.readonly
func (*ContactsService) GetByBusinessID ¶
func (s *ContactsService) GetByBusinessID(businessID string) (*ContactsResponse, error)
GetByBusinessID retrieves contacts by business ID Required scope: contacts.readonly
func (*ContactsService) List ¶
func (s *ContactsService) List(opts *GetContactsOptions) (*ContactsResponse, error)
List retrieves a list of contacts with optional filters Required scope: contacts.readonly Note: This endpoint is deprecated, use Search instead for new implementations
func (*ContactsService) RemoveTags ¶
func (s *ContactsService) RemoveTags(contactID string, tags []string) error
RemoveTags removes tags from a contact Required scope: contacts.write
func (*ContactsService) Update ¶
func (s *ContactsService) Update(contactID string, req *UpdateContactRequest) (*Contact, error)
Update updates an existing contact Required scope: contacts.write
func (*ContactsService) Upsert ¶
func (s *ContactsService) Upsert(req *UpsertContactRequest) (*Contact, error)
Upsert creates or updates a contact based on duplicate detection settings Required scope: contacts.write
type CreateContactRequest ¶
type CreateContactRequest struct {
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
LocationID string `json:"locationId"`
Phone string `json:"phone,omitempty"`
Address1 string `json:"address1,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
PostalCode string `json:"postalCode,omitempty"`
Country string `json:"country,omitempty"`
CompanyName string `json:"companyName,omitempty"`
Website string `json:"website,omitempty"`
Source string `json:"source,omitempty"`
Tags []string `json:"tags,omitempty"`
CustomFields []CustomField `json:"customField,omitempty"`
AttributionSource *AttributionSource `json:"attributionSource,omitempty"`
}
CreateContactRequest represents a request to create a contact
type CustomField ¶
type CustomField struct {
ID string `json:"id,omitempty"`
Key string `json:"key,omitempty"`
Value interface{} `json:"field_value,omitempty"`
}
CustomField represents a custom field on a contact
type DNDSetting ¶
type DNDSetting struct {
Status string `json:"status,omitempty"`
Message string `json:"message,omitempty"`
Code string `json:"code,omitempty"`
}
DNDSetting represents individual DND setting
type DNDSettings ¶
type DNDSettings struct {
Call *DNDSetting `json:"Call,omitempty"`
SMS *DNDSetting `json:"SMS,omitempty"`
Email *DNDSetting `json:"Email,omitempty"`
WhatsApp *DNDSetting `json:"WhatsApp,omitempty"`
GMB *DNDSetting `json:"GMB,omitempty"`
FB *DNDSetting `json:"FB,omitempty"`
}
DNDSettings represents do not disturb settings
type GetContactsOptions ¶
type GetContactsOptions struct {
LocationID string
Query string
Limit int
Skip int
StartAfter string
StartAfterID string
}
GetContactsOptions represents query options for listing contacts
type TokenRefreshCallback ¶
type TokenRefreshCallback func(tokenResponse TokenResponse)
TokenRefreshCallback is called whenever tokens are automatically refreshed due to 401 errors. This allows you to save the new tokens to your external storage (database, cache, etc.). The callback receives the complete token response with all metadata.
type TokenResponse ¶ added in v0.0.2
type TokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
ExpiresIn int `json:"expires_in"`
RefreshToken string `json:"refresh_token"`
Scope string `json:"scope"`
RefreshTokenID string `json:"refreshTokenId"`
UserType string `json:"userType"`
CompanyID string `json:"companyId"`
IsBulkInstall bool `json:"isBulkInstallation"`
UserID string `json:"userId"`
LocationID string `json:"locationId,omitempty"` // Only present in some responses
AgencyID string `json:"agencyId,omitempty"` // Only present in some responses
PlanID string `json:"planId,omitempty"` // Only present in some responses
ApprovalRequestID string `json:"approvalRequestId,omitempty"` // Only present in some responses
}
TokenResponse represents the complete OAuth token response from GoHighLevel
type UpdateContactRequest ¶
type UpdateContactRequest struct {
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
Address1 string `json:"address1,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
PostalCode string `json:"postalCode,omitempty"`
Country string `json:"country,omitempty"`
CompanyName string `json:"companyName,omitempty"`
Website string `json:"website,omitempty"`
Source string `json:"source,omitempty"`
Tags []string `json:"tags,omitempty"`
CustomFields []CustomField `json:"customField,omitempty"`
AttributionSource *AttributionSource `json:"attributionSource,omitempty"`
}
UpdateContactRequest represents a request to update a contact
type UpsertContactRequest ¶
type UpsertContactRequest struct {
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
LocationID string `json:"locationId"`
Phone string `json:"phone,omitempty"`
Address1 string `json:"address1,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
PostalCode string `json:"postalCode,omitempty"`
Country string `json:"country,omitempty"`
CompanyName string `json:"companyName,omitempty"`
Website string `json:"website,omitempty"`
Source string `json:"source,omitempty"`
Tags []string `json:"tags,omitempty"`
CustomFields []CustomField `json:"customField,omitempty"`
AttributionSource *AttributionSource `json:"attributionSource,omitempty"`
}
UpsertContactRequest represents a request to upsert a contact