Konumlar
client.locations aracılığıyla konumları listeleyin, oluşturun, güncelleyin, arşivleyin, arayın ve alın.
Tüm konum metotları client.locations altında yer alır. Bunları kullanmadan önce SDK'yı yükleyin ve anahtarınızı yapılandırın; Kurulum ve Hızlı başlangıç bölümlerine bakın.
Konum ID'leri
location_id alan metotlar, sayısal bir ID'yi (16808) veya bunun base64 ile kodlanmış karşılığını ("TG9jYXRpb246MTY4MDg=") kabul eder. SDK, sayısal ID'leri otomatik olarak kodladığı için her iki biçim de birbirinin yerine kullanılabilir:
# These are equivalentclient.locations.retrieve(16808)client.locations.retrieve("TG9jYXRpb246MTY4MDg=")locations.add
Tüm zorunlu alanları adlandırılmış argüman olarak ileterek tek çağrıda bir konum oluşturun. Konum oluşturmak için önerilen yöntem budur. SDK, API'nin oluşturma gereksinimlerini istemci tarafında doğrular ve herhangi bir ağ çağrısından önce ValidationError istisnasını oluşturur; böylece geçersiz bir veri yükü, açık bir mesajla hemen hata verir.
client.locations.add( *, name: str, description: str, sub_category_id: int, country_iso: str, city: str | None = None, street: str | None = None, state_iso: str | None = None, postal_code: str | None = None, phone: str | None = None, website: str | None = None, store_id: str | None = None, hide_address: bool | None = None, business_hours: list[dict] | None = None, service_area: dict | None = None, place_action_links: list[dict] | None = None, enabled_site_ids: list[int] | None = None, additional_fields: dict | None = None,) -> APIObjectİstemci tarafındaki doğrulama kontrolleri: name 2-150 karakter olmalı, description en az 200 karakter olmalı, sub_category_id ve country_iso bulunmalı ve hide_address=True koşulu sağlanmadıkça city bulunmalıdır.
Dönüş değeri, oluşturma veri yüküdür: .location yeni konumu içerir. Başarı bayraklarını hiçbir zaman kontrol etmeniz gerekmez; API veri yükünü reddettiğinde SDK, ValidationError istisnasını oluşturur.
result = client.locations.add( name="Acme Dental", description=( "Acme Dental is a family-owned dental practice offering general, " "cosmetic, and pediatric dentistry in the heart of New York. Our " "team provides cleanings, fillings, crowns, whitening, and same-day " "emergency care in a modern, comfortable office with weekend hours " "and easy online booking for new and returning patients." ), sub_category_id=1432, country_iso="US", city="New York", street="123 Jump Street", state_iso="NY", postal_code="10013", phone="6443859313", website="https://acmedental.example.com", store_id="NYC-001", place_action_links=[ {"placeActionType": "APPOINTMENT", "uri": "https://acmedental.example.com/book", "isPreferred": True}, ], enabled_site_ids=[1, 24, 87],)print("Created:", result.location.id, result.location.name)locations.list
Konumları imleç tabanlı sayfalama ile listeleyin. Bir SyncPage döndürür.
client.locations.list( *, first: int | None = None, after: str | None = None, before: str | None = None, last: int | None = None,) -> SyncPage# First page of 25page = client.locations.list(first=25)for loc in page: print(loc.name, loc.city) # Next page manuallyif page.has_more: page2 = page.next_page() # Auto-paginate all locationsfor loc in client.locations.list(first=100).auto_paging_iter(): print(loc.name)locations.retrieve
ID ile tek bir konum alın. ID mevcut değilse NotFoundError istisnasını oluşturur.
client.locations.retrieve(location_id: str | int) -> APIObjectloc = client.locations.retrieve(16808)print(loc.name, loc.street, loc.city)locations.list_by_ids
Bir ID listesi (sayısal veya base64) kullanarak tek çağrıda birden fazla konum alın.
client.locations.list_by_ids(location_ids: list[str | int]) -> list[APIObject]locs = client.locations.list_by_ids([16808, 16809, "TG9jYXRpb246MTQwMjQ="])for loc in locs: print(loc.id, loc.name)locations.list_by_store_codes
Verilen mağaza kodlarıyla eşleşen konumları alın.
client.locations.list_by_store_codes(store_codes: list[str]) -> list[APIObject]locs = client.locations.list_by_store_codes(["SF-001", "NYC-042"])for loc in locs: print(loc.storeId, loc.name)locations.search
Ad, adres veya mağaza ID'si alanlarında anahtar kelimeyle konum arayın. Bir SyncPage döndürür.
client.locations.search( query: str, *, fields: list[str] | None = None, first: int | None = None, after: str | None = None, before: str | None = None, last: int | None = None,) -> SyncPage# Search all fieldspage = client.locations.search("downtown dental", first=10) # Restrict to name onlypage = client.locations.search("Acme Dental", fields=["name"], first=10) for loc in page: print(loc.name, loc.city)locations.create
camelCase alan adlarını içeren ham bir girdi dict'inden konum oluşturun. Adlandırılmış argümanlar ve istemci tarafında doğrulama için locations.add kullanmayı tercih edin; elinizde zaten bir camelCase veri yükü varsa create kullanın.
client.locations.create(input: dict) -> APIObjectAPI'nin zorunlu tuttuğu alanlar: name, description (en az 200 karakter), subCategoryId, countryIso ve city (şehir düzeyinde adresleme kullanan ülkeler için).
result = client.locations.create({ "name": "Acme Dental Brooklyn", "description": ( "Acme Dental Brooklyn is a family-owned dental practice offering " "general, cosmetic, and pediatric dentistry. Our team provides " "cleanings, fillings, crowns, whitening, and same-day emergency " "care in a modern, comfortable office with weekend hours and easy " "online booking for new and returning patients across Brooklyn." ), "subCategoryId": 1432, "countryIso": "US", "city": "Brooklyn", "street": "88 Court St", "stateIso": "NY", "postalCode": "11201", "phone": "6443859314", "storeId": "NYC-002",})print("Created:", result.location.id)locations.update
Bir konumu güncelleyin. id ile birlikte değiştirmek istediğiniz alanları (camelCase) iletin. id sayısal veya base64 biçiminde olabilir; SDK bunu otomatik olarak kodlar.
client.locations.update(input: dict) -> APIObjectresult = client.locations.update({ "id": 16808, "phone": "6443859399", "street": "125 Jump Street",})print("Updated:", result.location.id)locations.archive
Bir veya daha fazla konumu arşivleyin.
client.locations.archive(location_ids: list[str | int]) -> APIObjectresult = client.locations.archive([16808, 16809])print(result.to_dict())locations.cancel_archive
Planlanmış bir arşivleme işlemini iptal edin.
client.locations.cancel_archive( location_ids: list[str | int], selection_type: str, changed_by: str,) -> APIObjectclient.locations.cancel_archive( [16808], selection_type="manual", changed_by="admin@example.com",)Ayrıca bkz.
- Gönderiler: duyurular, etkinlikler ve teklifler yayımlayın
- İşletme kayıtları: konum başına senkronizasyon durumunu kontrol edin
- Yorumlar: yorumları listeleyin ve yanıtlayın
- Analizler: Google, Bing, Facebook profil analizleri