Skip to content

Commit b4062c1

Browse files
feat: new services added in sdk, changes to support v3 of api
1 parent 48bb9ca commit b4062c1

127 files changed

Lines changed: 26404 additions & 3441 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "gohighlevel-api-client"
7-
version = "1.0.0-beta.1"
7+
version = "3.0.0"
88
description = "GoHighLevel Python SDK - Official API client for GoHighLevel platform"
99
readme = "README.md"
1010
license = {text = "MIT"}

src/highlevel/error.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# @generated
2+
# File generated from our OpenAPI spec
3+
14
from typing import Any, Optional
25

36

src/highlevel/highlevel.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1+
# @generated
2+
# File generated from our OpenAPI spec
3+
14
from typing import Any, Dict, Optional, Awaitable
25
import asyncio
36
import inspect
47
import copy
58
import httpx
69
import time
710
import json
11+
from .services.ad_publishing.ad_publishing import AdPublishing
12+
from .services.affiliate_manager.affiliate_manager import AffiliateManager
13+
from .services.agent_studio.agent_studio import AgentStudio
814
from .services.associations.associations import Associations
915
from .services.blogs.blogs import Blogs
16+
from .services.brand_boards.brand_boards import BrandBoards
1017
from .services.businesses.businesses import Businesses
1118
from .services.calendars.calendars import Calendars
1219
from .services.campaigns.campaigns import Campaigns
20+
from .services.chat_widget.chat_widget import ChatWidget
1321
from .services.companies.companies import Companies
1422
from .services.contacts.contacts import Contacts
23+
from .services.conversation_ai.conversation_ai import ConversationAi
1524
from .services.conversations.conversations import Conversations
1625
from .services.courses.courses import Courses
1726
from .services.custom_fields.custom_fields import CustomFields
@@ -21,6 +30,7 @@
2130
from .services.forms.forms import Forms
2231
from .services.funnels.funnels import Funnels
2332
from .services.invoices.invoices import Invoices
33+
from .services.knowledge_base.knowledge_base import KnowledgeBase
2434
from .services.links.links import Links
2535
from .services.locations.locations import Locations
2636
from .services.marketplace.marketplace import Marketplace
@@ -32,9 +42,9 @@
3242
from .services.phone_system.phone_system import PhoneSystem
3343
from .services.products.products import Products
3444
from .services.proposals.proposals import Proposals
35-
from .services.saas_api.saas_api import SaasApi
45+
from .services.saas.saas import Saas
3646
from .services.snapshots.snapshots import Snapshots
37-
from .services.social_media_posting.social_media_posting import SocialMediaPosting
47+
from .services.social_planner.social_planner import SocialPlanner
3848
from .services.store.store import Store
3949
from .services.surveys.surveys import Surveys
4050
from .services.users.users import Users
@@ -45,12 +55,20 @@
4555
from .logging import Logger
4656
from .webhook import WebhookManager
4757
from .constants import UserType
58+
from importlib.metadata import version as _pkg_version, PackageNotFoundError
59+
60+
# SDK version, read from the installed package metadata and sent in each request
61+
try:
62+
SDK_VERSION = _pkg_version("gohighlevel-api-client")
63+
except PackageNotFoundError:
64+
SDK_VERSION = "unknown"
4865

4966

5067
class HighLevel:
5168
"""HighLevel SDK Client"""
5269

5370
BASE_URL = "https://services.leadconnectorhq.com"
71+
API_VERSION = "v3"
5472

5573
def __init__(
5674
self,
@@ -60,8 +78,7 @@ def __init__(
6078
agency_access_token: Optional[str] = None,
6179
location_access_token: Optional[str] = None,
6280
session_storage: Optional[SessionStorage] = None,
63-
log_level: Optional[str] = None,
64-
api_version: Optional[str] = None
81+
log_level: Optional[str] = None
6582
):
6683
# Validate configuration
6784
if not private_integration_token and (not client_id or not client_secret):
@@ -74,7 +91,6 @@ def __init__(
7491

7592
# Set default configuration
7693
self.config = {
77-
"api_version": api_version or "2021-07-28",
7894
"private_integration_token": private_integration_token,
7995
"agency_access_token": agency_access_token,
8096
"location_access_token": location_access_token,
@@ -114,7 +130,8 @@ def _get_default_headers(self) -> Dict[str, str]:
114130
"""Generate default headers for HTTP requests"""
115131
headers = {
116132
"Content-Type": "application/json",
117-
"Version": self.config["api_version"]
133+
"Version": self.API_VERSION,
134+
"GHL-SDK-Version": f"python/{SDK_VERSION}",
118135
}
119136

120137
# Priority 1: private_integration_token
@@ -214,7 +231,7 @@ async def _refresh_token_if_needed(self, resource_id: str, session_data: ISessio
214231
})
215232

216233
self.logger.info(f"Token refreshed successfully for {resource_id}")
217-
return f"Bearer {new_token_data['access_token']}"
234+
return f"Bearer {new_token_data.get('access_token') or new_token_data.get('accessToken')}"
218235

219236
except Exception as error:
220237
self.logger.error(f"Failed to refresh token for {resource_id}: {error}")
@@ -276,7 +293,7 @@ async def _handle_location_token_fallback(self, location_id: str, location_sessi
276293
})
277294

278295
self.logger.info(f"Location token fetched successfully using company token fallback for location_id: {location_id}")
279-
return f"Bearer {new_location_token_data['access_token']}"
296+
return f"Bearer {new_location_token_data.get('access_token') or new_location_token_data.get('accessToken')}"
280297

281298
except Exception as error:
282299
self.logger.error(f"Failed to handle location token fallback for location_id: {location_id}: {error}")
@@ -388,13 +405,19 @@ def extract_resource_id(
388405

389406
def _initialize_services(self) -> None:
390407
"""Initialize all service instances with the HighLevel instance"""
408+
self.ad_publishing = AdPublishing(self)
409+
self.affiliate_manager = AffiliateManager(self)
410+
self.agent_studio = AgentStudio(self)
391411
self.associations = Associations(self)
392412
self.blogs = Blogs(self)
413+
self.brand_boards = BrandBoards(self)
393414
self.businesses = Businesses(self)
394415
self.calendars = Calendars(self)
395416
self.campaigns = Campaigns(self)
417+
self.chat_widget = ChatWidget(self)
396418
self.companies = Companies(self)
397419
self.contacts = Contacts(self)
420+
self.conversation_ai = ConversationAi(self)
398421
self.conversations = Conversations(self)
399422
self.courses = Courses(self)
400423
self.custom_fields = CustomFields(self)
@@ -404,6 +427,7 @@ def _initialize_services(self) -> None:
404427
self.forms = Forms(self)
405428
self.funnels = Funnels(self)
406429
self.invoices = Invoices(self)
430+
self.knowledge_base = KnowledgeBase(self)
407431
self.links = Links(self)
408432
self.locations = Locations(self)
409433
self.marketplace = Marketplace(self)
@@ -415,9 +439,9 @@ def _initialize_services(self) -> None:
415439
self.phone_system = PhoneSystem(self)
416440
self.products = Products(self)
417441
self.proposals = Proposals(self)
418-
self.saas_api = SaasApi(self)
442+
self.saas = Saas(self)
419443
self.snapshots = Snapshots(self)
420-
self.social_media_posting = SocialMediaPosting(self)
444+
self.social_planner = SocialPlanner(self)
421445
self.store = Store(self)
422446
self.surveys = Surveys(self)
423447
self.users = Users(self)
@@ -551,10 +575,6 @@ def get_client_secret(self) -> Optional[str]:
551575
"""Get current client secret"""
552576
return self.config.get("client_secret")
553577

554-
def set_api_version(self, version: str) -> None:
555-
"""Set API version"""
556-
self.update_config({"api_version": version})
557-
558578
def get_config(self) -> Dict[str, Any]:
559579
"""Get current configuration"""
560580
return {**self.config}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""AdPublishing Service"""
2+
3+
from .ad_publishing import AdPublishing
4+
5+
__all__ = ['AdPublishing']

0 commit comments

Comments
 (0)